Skip to content

Commit

Permalink
avoid infinite recusrsion while installing a skin (requestSkin can be…
Browse files Browse the repository at this point in the history
… sent while installing)

tuned raw skin
  • Loading branch information
plantec committed Nov 17, 2023
1 parent f3618c7 commit a4c2a6b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/Toplo-Widget-Button/ToButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ ToButton >> initialize [
ToButton >> installRawStyle [

super installRawStyle.
self labeledIcon hMatchParent
self labeledIcon hMatchParent.
self iconDo: [ :ic | ic formColor: Color black ].

]

{ #category : 't - element with labeled icon - accessing' }
Expand Down
9 changes: 8 additions & 1 deletion src/Toplo-Widget-Button/ToButtonSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ToButtonSkin >> disabledLookEvent: anEvent [

super disabledLookEvent: anEvent.
anEvent elementDo: [ :e |
e iconDo: [ :ic | ic formColor: Color lightGray ].
e labelDo: [ :lab |
lab text attributes: { (BlTextForegroundAttribute paint: Color lightGray) }.
lab textChanged ] ]
Expand All @@ -21,6 +22,7 @@ ToButtonSkin >> enabledLookEvent: anEvent [

super enabledLookEvent: anEvent.
anEvent elementDo: [ :e |
e iconDo: [ :ic | ic formColor: Color black ].
e labelDo: [ :lab |
lab text attributes: { (BlTextForegroundAttribute paint: Color black) }.
lab textChanged ] ]
Expand All @@ -31,6 +33,7 @@ ToButtonSkin >> hoveredLookEvent: anEvent [

super hoveredLookEvent: anEvent.
anEvent elementDo: [ :e |
e iconDo: [ :ic | ic formColor: Color blue ].
e labelDo: [ :lab |
lab text attributes: { (BlTextForegroundAttribute paint: Color blue) }.
lab textChanged ] ]
Expand All @@ -40,7 +43,9 @@ ToButtonSkin >> hoveredLookEvent: anEvent [
ToButtonSkin >> initialLookEvent: anEvent [

super initialLookEvent: anEvent.
anEvent elementDo: [ :e | e labelDo: [ :lab |
anEvent elementDo: [ :e |
e iconDo: [ :ic | ic formColor: Color black ].
e labelDo: [ :lab |
lab text attributes: { (BlTextForegroundAttribute paint: Color black) }.
lab textChanged ] ]
]
Expand All @@ -50,6 +55,7 @@ ToButtonSkin >> leavedLookEvent: anEvent [

super leavedLookEvent: anEvent.
anEvent elementDo: [ :e |
e iconDo: [ :ic | ic formColor: Color black ].
e labelDo: [ :lab |
lab text attributes: { (BlTextForegroundAttribute paint: Color black) }.
lab textChanged ] ]
Expand All @@ -60,6 +66,7 @@ ToButtonSkin >> pressedLookEvent: anEvent [

super pressedLookEvent: anEvent.
anEvent elementDo: [ :e |
e iconDo: [ :ic | ic formColor: Color blue darker ].
e labelDo: [ :lab |
lab text attributes: { (BlTextForegroundAttribute paint: Color blue darker) }.
lab textChanged ] ]
Expand Down
1 change: 0 additions & 1 deletion src/Toplo-Widget-Button/ToCheckbox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ ToCheckbox >> indeterminateChild [
ToCheckbox >> installRawStyle [

super installRawStyle.

self iconImage: self defaultBlankCheckboxImage.
self icon geometry: self iconGeometry
]
Expand Down
10 changes: 10 additions & 0 deletions src/Toplo-Widget-Image/ToImage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ ToImage >> errorInnerFormNotFound [
NotFound signalFor: self
]

{ #category : 'form accessing' }
ToImage >> formColor: aColor [

self
withInnerFormDo: [ :form |
self innerImage:
(form collectColors: [ :color | aColor alpha: color alpha ]) ]
ifNone: [ ]
]

{ #category : 'testing' }
ToImage >> hasInnerImage [ ^ self innerImage id asSymbol ~= #emptyImage
]
Expand Down
4 changes: 3 additions & 1 deletion src/Toplo-Widget-Select/ToSelectInnerButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ ToSelectInnerButton >> installRawStyle [
self beLabelFirst.
self flexible: true.
self hMatchParent.
self icon: (ToImage inner: (Smalltalk ui icons iconNamed: #bottom))
self icon: (ToImage inner: (Smalltalk ui icons iconNamed: #bottom)).
self iconDo: [ :ic | ic formColor: Color black ].

]
2 changes: 1 addition & 1 deletion src/Toplo/TToElementWithLabeledIcon.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TToElementWithLabeledIcon >> icon: anElement [

self icon = anElement ifTrue: [ ^ self ].
self labeledIcon icon: anElement.
self requestNewSkin
self requestNewSkin
]

{ #category : 't - element with labeled icon - accessing' }
Expand Down
11 changes: 5 additions & 6 deletions src/Toplo/ToSkinInstaller.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ Class {

{ #category : 'hook' }
ToSkinInstaller >> applyOn: anElement [

anElement skinInstaller: nil.
" if there is an installed skin -> nothing to do "
anElement installedSkinDo: [ :s |
^ self ].
anElement defaultSkin ifNotNil: [ :found |
anElement skinManager installSkin: found in: anElement ]

anElement installedSkin ifNil: [
anElement defaultSkin ifNotNil: [ :found |
anElement skinManager installSkin: found in: anElement ] ].
anElement skinInstaller: nil
]

{ #category : 'hook' }
Expand Down
4 changes: 4 additions & 0 deletions src/Toplo/ToSkinManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ ToSkinManager >> requestInstallSkinIn: anElement [
{ #category : 'accessing - skin' }
ToSkinManager >> requestUninstallSkinIn: anElement [

" having an installer means that the element is already installing a skin.
and a #requestNewSkin can be sent during a skin instalation.
Thus, to avoid infinite recurssion, do nothing if a skin installer is already set"
self skinInstaller ifNotNil: [ ^ self ].
self skinUninstaller ifNotNil: [
^ self ].
self skinUninstaller: ToSkinUninstaller new
Expand Down
5 changes: 3 additions & 2 deletions src/Toplo/ToSkinUninstaller.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ Class {
{ #category : 'hook' }
ToSkinUninstaller >> applyOn: anElement [

anElement skinUninstaller: nil.
" if there is not an installed skin -> nothing to do "
anElement installedSkinDo: [ :skin |
anElement skinManager uninstallSkin: skin in: anElement]
anElement skinManager uninstallSkin: skin in: anElement].
anElement skinUninstaller: nil.

]

{ #category : 'hook' }
Expand Down
7 changes: 1 addition & 6 deletions src/Toplo/ToStyleSheet.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ ToStyleSheet class >> defaultWritablePropertyList [
(ToFeatureProperty new name: #iconImage).
(ToPseudoProperty new
name: #'image-inner-form-color';
writer: [ :e :v |
e
withInnerFormDo: [ :form |
e innerImage:
(form collectColors: [ :color | v alpha: color alpha ]) ]
ifNone: [ ] ]).
writer: [ :e :v | e formColor: v ]).
(ToFeatureProperty name: #layout).
(ToPseudoProperty
name: #'layout-direction'
Expand Down

0 comments on commit a4c2a6b

Please sign in to comment.