Skip to content

Commit

Permalink
toggle skin with animation
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Jul 19, 2023
1 parent 2713e6f commit d2bfe13
Show file tree
Hide file tree
Showing 21 changed files with 486 additions and 705 deletions.
33 changes: 0 additions & 33 deletions src/Toplo/ToCheckBoxDresser.class.st

This file was deleted.

151 changes: 0 additions & 151 deletions src/Toplo/ToCheckBoxDresserDep.class.st

This file was deleted.

2 changes: 1 addition & 1 deletion src/Toplo/ToCheckMenuItem.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class {
{ #category : #'t - initialization dresser' }
ToCheckMenuItem >> defaultDresser [

^ ToBasicMenuItemDresser next: (ToCheckBoxDresser new)
^ ToBasicMenuItemDresser next: (ToCheckableButtonDresser new)
]

{ #category : #initialization }
Expand Down
40 changes: 40 additions & 0 deletions src/Toplo/ToCheckableButtonDresser.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Class {
#name : #ToCheckableButtonDresser,
#superclass : #ToGeneralButtonDresser,
#instVars : [
'checkableHandler'
],
#category : #'Toplo-Widget-Button'
}

{ #category : #'api - install/uninstall hook' }
ToCheckableButtonDresser >> checkEvent: anEvent in: anElement [

anElement dispatchEvent: ToClickLookEvent new.
anEvent current ifTrue: [self hoveredState: anElement]

]

{ #category : #'events handling' }
ToCheckableButtonDresser >> clicked: anElement [

" ask the button, my checkableHandler (see onInstalledIn:) with send the click look event so don't send to super to avoid unnecessary change "
anElement switchToNextState.
self hoveredState: anElement

]

{ #category : #'api - install/uninstall hook' }
ToCheckableButtonDresser >> onInstalledIn: anElement [

super onInstalledIn: anElement.
checkableHandler := BlEventHandler on: ToCheckableCheckEvent do: [ :event | self checkEvent: event in: anElement ].
anElement addEventHandler: checkableHandler
]

{ #category : #'api - install/uninstall hook' }
ToCheckableButtonDresser >> onUninstalledIn: anElement [

super onUninstalledIn: anElement.
anElement removeEventHandler: checkableHandler
]
2 changes: 1 addition & 1 deletion src/Toplo/ToCheckbox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class {
{ #category : #'t - initialization dresser' }
ToCheckbox >> defaultDresser [

^ ToCheckBoxDresser new
^ ToCheckableButtonDresser new
]

{ #category : #'t - skin accessing' }
Expand Down
6 changes: 4 additions & 2 deletions src/Toplo/ToGeneralButtonDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Class {
{ #category : #'events handling' }
ToGeneralButtonDresser >> clicked: anElement [

anElement dispatchEvent: ToClickLookEvent new
anElement dispatchEvent: ToClickLookEvent new.
self hoveredState: anElement

]

{ #category : #deprecated }
Expand Down Expand Up @@ -142,7 +144,7 @@ ToGeneralButtonDresser >> mouseUpOutsideEvent: anEvent in: anElement [
"Outside event can have a button element as target.
In that case, no action is triggered "
anEvent consumed: true.
(anEvent originalEvent target hasParent: anElement) ifTrue: [
(anEvent originalEvent target notNil and: [anEvent originalEvent target hasParent: anElement]) ifTrue: [
^ self ].
self initialState: anElement
]
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToRadioButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
{ #category : #'t - initialization dresser' }
ToRadioButton >> defaultDresser [

^ ToCheckBoxDresser new
^ ToCheckableButtonDresser new
]

{ #category : #'t - skin accessing' }
Expand Down
29 changes: 0 additions & 29 deletions src/Toplo/ToRadioButtonDresserDep.class.st

This file was deleted.

2 changes: 1 addition & 1 deletion src/Toplo/ToRadioMenuItem.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Class {
{ #category : #'t - initialization dresser' }
ToRadioMenuItem >> defaultDresser [

^ ToBasicMenuItemDresser next: ToCheckBoxDresser new
^ ToBasicMenuItemDresser next: ToCheckableButtonDresser new
]
29 changes: 19 additions & 10 deletions src/Toplo/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3332,20 +3332,29 @@ ToSandBox class >> example_toggle [
{ #category : #'toggle button' }
ToSandBox class >> example_toggle2 [

| th win |
| th |
th := ToToggleButton new
labelText: 'Cheesecake';
beLabelFirst.
th onElement: (ToLabel text: 'ON').
th offElement: (ToLabel text: 'OFF').
th switchBarOnElement: (ToLabel text: ('Yes!' asRopedText foreground: Color white; bold)).
th switchBarOffElement: (ToLabel text: ('No :('asRopedText bold) ).
th when: ToCheckableCheckEvent do: [ :event | event current traceCr ].
th checked: true.
win := ToInnerWindow new
position: 10 @ 10;
size: 400 @ 200;
yourself.
win root layout: BlLinearLayout vertical.
win root addChild: th.
win openInSpace
th openInSpace
]

{ #category : #'toggle button' }
ToSandBox class >> example_toggle3 [

| th |
th := ToToggleButton new
labelText: 'Cheesecake';
beLabelFirst.
th switchButtonOnElement: (ToImage inner: (Smalltalk ui icons iconNamed: #glamorousAccept)).
th switchButtonOffElement: (ToImage inner: (Smalltalk ui icons iconNamed: #glamorousClose)).
th when: ToCheckableCheckEvent do: [ :event | event current traceCr ].
th checked: true.
th openInSpace
]

{ #category : #pane }
Expand Down
Loading

0 comments on commit d2bfe13

Please sign in to comment.