Skip to content

Commit

Permalink
make toplo specific phase, theme and skin management dynamically inst…
Browse files Browse the repository at this point in the history
…alled
  • Loading branch information
plantec committed Jul 29, 2023
1 parent 4d0b413 commit f6fc635
Show file tree
Hide file tree
Showing 22 changed files with 286 additions and 178 deletions.
10 changes: 6 additions & 4 deletions src/Toplo-LookAndFeel/ToAbstractTheme.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ ToAbstractTheme class >> cleanUp: anObject [
{ #category : #current }
ToAbstractTheme class >> current [

current ifNil: [ current := ToTheme blue ].
^ current
^ current ifNil: [ current := ToTheme blue ]
]

{ #category : #dresser }
Expand Down Expand Up @@ -101,12 +100,15 @@ ToAbstractTheme >> installOnSpace: aSpace [

aSpace ifNil:[ ^ self ].

"Tag installation complete"
aSpace root userData at: #isToThemeInstalled put: true.
Toplo useLookAndFeel ifFalse: [ ^ self ].

"Update root background color depending theme"
self flag:'labordep : this code should not be here but in a dresser dedicated to root element (to be coherent with dresser pattern)'.
aSpace root background: self backgroundColor.

"Tag installation complete"
aSpace root userData at: #isToThemeInstalled put: true

]

{ #category : #colors }
Expand Down
6 changes: 3 additions & 3 deletions src/Toplo-LookAndFeel/ToDashedButtonSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ToDashedButtonSkin >> builtBorderBuilder [

| builder |
builder := super builtBorderBuilder.
builder dashArray: self theme dashed.
builder dashArray: self theme dashArray.
^ builder
]

Expand All @@ -46,7 +46,7 @@ ToDashedButtonSkin >> builtBorderHoverBuilder [
| builder |
builder := super builtBorderHoverBuilder.
builder paint: self theme colorPrimaryHover.
builder dashArray: self theme dashed.
builder dashArray: self theme dashArray.
^ builder
]

Expand All @@ -56,7 +56,7 @@ ToDashedButtonSkin >> builtBorderPressedBuilder [
| builder |
builder := super builtBorderPressedBuilder.
builder paint: self theme colorPrimaryPressed.
builder dashArray: self theme dashed.
builder dashArray: self theme dashArray.
^ builder
]

Expand Down
59 changes: 31 additions & 28 deletions src/Toplo-LookAndFeel/ToLAFButtonDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ToLAFButtonDresser >> hover: anElement event: anEvent [
super mouseEnterEvent: anEvent in: anElement.

"update main element"
self background: self skin backgroundHover in: anElement.
self border: self skin borderHover in: anElement.
anElement background: self skin backgroundHover.
anElement border: self skin borderHover.

"label event dispatch"
label := anElement label.
Expand All @@ -41,20 +41,22 @@ ToLAFButtonDresser >> hover: anElement event: anEvent [
{ #category : #'events handling' }
ToLAFButtonDresser >> initialState: anElement [

| label image|
| label image |
super initialState: anElement.

"update main element"
self background: self skin background in: anElement.
self border: self skin border in: anElement.
anElement background: self skin background.
anElement border: self skin border.

"label event dispatch"
label := anElement label.
(label notNil and:[label dresser notNil]) ifTrue:[ label dresser initialState: label ].

(label notNil and: [ label dresser notNil ]) ifTrue: [
label dresser initialState: label ].

"icon event dispatch"
image := anElement icon.
(image notNil and:[image dresser notNil]) ifTrue:[ image dresser initialState: image ].
(image notNil and: [ image dresser notNil ]) ifTrue: [
image dresser initialState: image ]
]

{ #category : #accessing }
Expand All @@ -80,8 +82,8 @@ ToLAFButtonDresser >> leftClickEvent: anEvent in: anElement [

super leftClickEvent: anEvent in: anElement.
"self restoreUnpressedState."
self hover: anElement event: anEvent

self mouseEnterEvent: anEvent in: anElement
]

{ #category : #deprecated }
Expand All @@ -100,21 +102,21 @@ ToLAFButtonDresser >> leftClicked: anElement event: anEvent [

{ #category : #'events handling' }
ToLAFButtonDresser >> leftMouseDownEvent: anEvent in: anElement [
| label image |

"self savePressedState"

"update main element"
self background: self skin backgroundPressed in: anElement.
self border: self skin borderPressed in: anElement.
| label image |
"self savePressedState""update main element"
anElement background: self skin backgroundPressed.
anElement border: self skin borderPressed.

"label event dispatch"
label := anElement label.
(label notNil and:[label dresser notNil]) ifTrue:[ label dresser leftMouseDownEvent: anEvent in: label ].

(label notNil and: [ label dresser notNil ]) ifTrue: [
label dresser leftMouseDownEvent: anEvent in: label ].

"icon event dispatch"
image := anElement icon.
(image notNil and:[image dresser notNil]) ifTrue:[ image dresser leftMouseDownEvent: anEvent in: image ].
(image notNil and: [ image dresser notNil ]) ifTrue: [
image dresser leftMouseDownEvent: anEvent in: image ]
]

{ #category : #'events handling' }
Expand Down Expand Up @@ -162,21 +164,22 @@ ToLAFButtonDresser >> leftUp: anElement event: anEvent [
{ #category : #'events handling' }
ToLAFButtonDresser >> mouseEnterEvent: anEvent in: anElement [


| label image|
| label image |
super mouseEnterEvent: anEvent in: anElement.

"update main element"
self background: self skin backgroundHover in: anElement.
self border: self skin borderHover in: anElement.
anElement background: self skin backgroundHover.
anElement border: self skin borderHover.

"label event dispatch"
label := anElement label.
(label notNil and:[label dresser notNil]) ifTrue:[ label dresser hover: label event: anEvent ].

(label notNil and: [ label dresser notNil ]) ifTrue: [
label dresser hover: label event: anEvent ].

"icon event dispatch"
image := anElement icon.
(image notNil and:[image dresser notNil]) ifTrue:[ image dresser hover: image event: anEvent ].
(image notNil and: [ image dresser notNil ]) ifTrue: [
image dresser hover: image event: anEvent ]
]

{ #category : #'events handling' }
Expand Down
31 changes: 16 additions & 15 deletions src/Toplo-LookAndFeel/ToLAFExamples.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ ToLAFExamples class >> example_ButtonSkins [

| space button1 button2 button3 button4 button5 pane |
space := BlSpace new.
space root layout: (BlLinearLayout vertical cellSpacing: 10).


space root layout: (BlLinearLayout vertical).

pane := ToPane horizontal.
pane layout: (BlLinearLayout horizontal cellSpacing: 10).

pane background: Color random.
button1 := ToButton skinType: #primary.
button1 labelText: 'Primary button'.
button2 := ToButton skinType: #default.
Expand All @@ -28,8 +28,8 @@ ToLAFExamples class >> example_ButtonSkins [
pane addChild: button1; addChild: button2; addChild: button3; addChild: button4; addChild: button5.
space root addChild: pane.

pane := ToPane horizontal.
pane layout: (BlLinearLayout horizontal cellSpacing: 10).
pane := ToPane horizontal.
pane background: Color random.

button1 := ToButton skinType: #primary.
button1 labelText: 'Primary button'.
Expand All @@ -50,8 +50,8 @@ ToLAFExamples class >> example_ButtonSkins [
pane addChild: button1; addChild: button2; addChild: button3; addChild: button4; addChild: button5.
space root addChild: pane.

pane := ToPane horizontal.
pane layout: (BlLinearLayout horizontal cellSpacing: 10).
pane := ToPane horizontal.
pane background: Color random.

button1 := ToButton skinType: #primary.
button1 icon: (ToImage new innerImage: (ToThemeIcons iconSearchOutlined16x16)).
Expand All @@ -68,8 +68,8 @@ ToLAFExamples class >> example_ButtonSkins [
pane addChild: button1; addChild: button2; addChild: button3; addChild: button4; addChild: button5.
space root addChild: pane.

pane := ToPane horizontal.
pane layout: (BlLinearLayout horizontal cellSpacing: 10).
pane := ToPane horizontal.
pane background: Color random.

button1 := ToButton skinType: #dangerPrimary .
button1 labelText: 'Danger primary'.
Expand All @@ -85,8 +85,8 @@ ToLAFExamples class >> example_ButtonSkins [
pane addChild: button1; addChild: button2; addChild: button3; addChild: button4; addChild: button5.
space root addChild: pane.

pane := ToPane horizontal.
pane layout: (BlLinearLayout horizontal cellSpacing: 10).
pane := ToPane horizontal.
pane background: Color random.

button1 := ToButton skinType: #dangerPrimary .
button1 labelText: 'Danger primary'.
Expand All @@ -107,8 +107,8 @@ ToLAFExamples class >> example_ButtonSkins [
pane addChild: button1; addChild: button2; addChild: button3; addChild: button4; addChild: button5.
space root addChild: pane.

pane := ToPane horizontal.
pane layout: (BlLinearLayout horizontal cellSpacing: 10).
pane := ToPane horizontal.
pane background: Color random.

button1 := ToButton skinType: #dangerPrimary .
button1 icon: (ToImage new innerImage: (ToThemeIcons iconSearchOutlined16x16)).
Expand All @@ -125,8 +125,9 @@ ToLAFExamples class >> example_ButtonSkins [
space root addChild: pane.

space show.
space root inspect.

^space
^space
]

{ #category : #buttons }
Expand Down
6 changes: 6 additions & 0 deletions src/Toplo-LookAndFeel/ToLAFImageDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ ToLAFImageDresser >> isSkinCompatible: aSkin [
^ aSkin isKindOf: ToAbstractImageSkin
]

{ #category : #'events handling' }
ToLAFImageDresser >> leftMouseDownEvent: anEvent in: anElement [

self leftPressed: anElement event: anEvent
]

{ #category : #'events handling' }
ToLAFImageDresser >> leftPressed: anElement event: aBlMouseDownEvent [

Expand Down
6 changes: 6 additions & 0 deletions src/Toplo-LookAndFeel/ToLAFLabelDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ ToLAFLabelDresser >> isSkinCompatible: aSkin [
^ aSkin isKindOf: ToAbstractLabelSkin
]

{ #category : #'events handling' }
ToLAFLabelDresser >> leftMouseDownEvent: anEvent in: anElement [

self leftPressed: anElement event: anEvent
]

{ #category : #'events handling' }
ToLAFLabelDresser >> leftPressed: anElement event: aBlMouseDownEvent [

Expand Down
20 changes: 12 additions & 8 deletions src/Toplo-LookAndFeel/ToLAFRadioButtonDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,23 @@ ToLAFRadioButtonDresser >> hover: anElement event: anEvent [

{ #category : #accessing }
ToLAFRadioButtonDresser >> initialState: anElement [

"update main element"
self background: self skin background in: anElement.
self border: self skin border in: anElement.


anElement background: self skin background.
anElement border: self skin border.

"update checked/unchecked icon"
anElement checked
ifTrue: [
self skin checkedBorder ifNotNil: [:e | anElement icon innerImage border: e].
self skin checkedBackground ifNotNil: [:e | anElement icon innerImage background: e]]
self skin checkedBorder ifNotNil: [ :e |
anElement icon innerImage border: e ].
self skin checkedBackground ifNotNil: [ :e |
anElement icon innerImage background: e ] ]
ifFalse: [
self skin uncheckedBorder ifNotNil: [:e | anElement icon innerImage border: e].
self skin uncheckedBackground ifNotNil: [:e | anElement icon innerImage background: e]]
self skin uncheckedBorder ifNotNil: [ :e |
anElement icon innerImage border: e ].
self skin uncheckedBackground ifNotNil: [ :e |
anElement icon innerImage background: e ] ]
]

{ #category : #accessing }
Expand Down
Loading

0 comments on commit f6fc635

Please sign in to comment.