Skip to content

Commit

Permalink
working on ToggleButton
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Jul 18, 2023
1 parent 6eb2bd0 commit 2713e6f
Show file tree
Hide file tree
Showing 22 changed files with 684 additions and 217 deletions.
61 changes: 0 additions & 61 deletions src/Toplo/TToCheckableWithIndeterminate.trait.st

This file was deleted.

6 changes: 3 additions & 3 deletions src/Toplo/ToBackgroundLook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ToBackgroundLook >> hoveredLookEvent: anEvent [

super hoveredLookEvent: anEvent.
anEvent elementDo: [ :e |
self hoverBg ifNotNil: [ :bg | e background: bg ] ]
self hoverBg ifNotNil: [ :bg | e background: (bg value: e)] ]
]

{ #category : #accessing }
Expand All @@ -46,7 +46,7 @@ ToBackgroundLook >> initialLookEvent: anEvent [

super initialLookEvent: anEvent.
anEvent elementDo: [ :e |
self initialBg ifNotNil: [ :bg | e background: bg ] ]
self initialBg ifNotNil: [ :bg | e background: (bg value: e)] ]
]

{ #category : #accessing }
Expand All @@ -66,5 +66,5 @@ ToBackgroundLook >> pressedLookEvent: anEvent [

super pressedLookEvent: anEvent.
anEvent elementDo: [ :e |
self pressedBg ifNotNil: [ :bg | e background: bg ] ]
self pressedBg ifNotNil: [ :bg | e background: (bg value: e)] ]
]
43 changes: 21 additions & 22 deletions src/Toplo/ToButtonDefaultType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ Class {
#category : #'Toplo-Widget-Button-Skins'
}

{ #category : #accessing }
ToButtonDefaultType >> borderLookIn: anElement [

| borderLook |
borderLook := ToBorderLook new.
self dashed ifTrue: [ borderLook dashArray: anElement toTheme dashed ].
self danger
ifTrue: [
borderLook
initialPaint: anElement toTheme colorError;
hoverPaint: anElement toTheme colorErrorHover;
pressedPaint: anElement toTheme colorErrorHover darker ]
ifFalse: [
borderLook
initialPaint: anElement toTheme colorBorder;
hoverPaint: anElement toTheme colorPrimaryHover;
pressedPaint: anElement toTheme colorPrimaryPressed ].
borderLook width: anElement toTheme lineWidth.
^ borderLook
]

{ #category : #accessing }
ToButtonDefaultType >> dashed [

Expand Down Expand Up @@ -42,25 +63,3 @@ ToButtonDefaultType >> regularLabelLookIn: anElement [
pressedColor: anElement toTheme colorPrimaryPressed.
^ labelLook
]

{ #category : #'api - install/uninstall hook' }
ToButtonDefaultType >> whenAddedToSpace: anEvent in: anElement fromSkin: aSkin [

| borderLook |
super whenAddedToSpace: anEvent in: anElement fromSkin: aSkin.
borderLook := ToBorderLook new.
self dashed ifTrue: [ borderLook dashArray: anElement toTheme dashed ].
self danger
ifTrue: [
borderLook
initialPaint: anElement toTheme colorError;
hoverPaint: anElement toTheme colorErrorHover;
pressedPaint: anElement toTheme colorErrorHover darker ]
ifFalse: [
borderLook
initialPaint: anElement toTheme colorBorder;
hoverPaint: anElement toTheme colorPrimaryHover;
pressedPaint: anElement toTheme colorPrimaryPressed ].
borderLook width: anElement toTheme lineWidth.
aSkin addLook: borderLook
]
37 changes: 18 additions & 19 deletions src/Toplo/ToButtonPrimaryType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ Class {
#category : #'Toplo-Widget-Button-Skins'
}

{ #category : #'api - install/uninstall hook' }
ToButtonPrimaryType >> backgroundLookIn: anElement [

^ self danger
ifTrue: [
ToBackgroundLook new
initialBg: [:e | e toTheme colorError];
pressedBg: [:e | e toTheme colorErrorHover darker];
hoverBg: [:e | e toTheme colorErrorHover];
yourself ]
ifFalse: [
ToBackgroundLook new
initialBg: [:e | e toTheme colorPrimary];
pressedBg: [:e | e toTheme colorPrimaryPressed];
hoverBg: [:e | e toTheme colorPrimaryHover];
yourself ]
]

{ #category : #'api - install/uninstall hook' }
ToButtonPrimaryType >> iconLookIn: anElement [

Expand Down Expand Up @@ -32,22 +50,3 @@ ToButtonPrimaryType >> regularLabelLookIn: anElement [
labelLook initialColor: anElement toTheme colorTextLightSolid.
^ labelLook
]

{ #category : #'api - install/uninstall hook' }
ToButtonPrimaryType >> whenAddedToSpace: anEvent in: anElement fromSkin: aSkin [

super whenAddedToSpace: anEvent in: anElement fromSkin: aSkin.
self danger
ifTrue: [
aSkin addLook: (ToBackgroundLook new
initialBg: anElement toTheme colorError;
pressedBg: anElement toTheme colorErrorHover darker;
hoverBg: anElement toTheme colorErrorHover;
yourself) ]
ifFalse: [
aSkin addLook: (ToBackgroundLook new
initialBg: anElement toTheme colorPrimary;
pressedBg: anElement toTheme colorPrimaryPressed;
hoverBg: anElement toTheme colorPrimaryHover;
yourself) ]
]
17 changes: 7 additions & 10 deletions src/Toplo/ToButtonSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,19 @@ ToButtonSkin >> dashed: aBoolean [
self type dashed: aBoolean
]

{ #category : #'event handling' }
ToButtonSkin >> elementLookEvent: anEvent [

anEvent currentTarget icon ifNotNil: [ :ico | ico dispatchEvent: anEvent copy ].
anEvent currentTarget label ifNotNil: [ :lab | lab dispatchEvent: anEvent copy ].
super elementLookEvent: anEvent


]

{ #category : #'api - accessing' }
ToButtonSkin >> eventsToHandle [

^ super eventsToHandle, { ToButtonIconChanged. ToButtonLabelChanged }
]

{ #category : #'event handling' }
ToButtonSkin >> subElementsIn: anElement [

^ ((super subElementsIn: anElement), { anElement icon. anElement label }) reject: [ :e | e isNil ]

]

{ #category : #accessing }
ToButtonSkin >> type [

Expand Down
37 changes: 18 additions & 19 deletions src/Toplo/ToButtonTextType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ Class {
#category : #'Toplo-Widget-Button-Skins'
}

{ #category : #'api - install/uninstall hook' }
ToButtonTextType >> backgroundLookIn: anElement [

^ self danger
ifTrue: [
ToBackgroundLook new
initialBg: [:e | Color transparent];
pressedBg: [:e | e toTheme colorErrorBg];
hoverBg: [:e | e toTheme colorErrorBg];
yourself ]
ifFalse: [
ToBackgroundLook new
initialBg: [:e | Color transparent];
pressedBg: [:e | e toTheme colorBgTextActive];
hoverBg: [:e | e toTheme colorBgTextHover];
yourself ]
]

{ #category : #'api - install/uninstall hook' }
ToButtonTextType >> regularFormLookIn: anElement [

Expand All @@ -24,22 +42,3 @@ ToButtonTextType >> regularLabelLookIn: anElement [
labelLook initialColor: anElement toTheme colorText.
^ labelLook
]

{ #category : #'api - install/uninstall hook' }
ToButtonTextType >> whenAddedToSpace: anEvent in: anElement fromSkin: aSkin [

super whenAddedToSpace: anEvent in: anElement fromSkin: aSkin.
self danger
ifTrue: [
aSkin addLook: (ToBackgroundLook new
initialBg: Color transparent;
pressedBg: anElement toTheme colorErrorBg;
hoverBg: anElement toTheme colorErrorBg;
yourself) ]
ifFalse: [
aSkin addLook: (ToBackgroundLook new
initialBg: Color transparent;
pressedBg: anElement toTheme colorBgTextActive;
hoverBg: anElement toTheme colorBgTextHover;
yourself) ]
]
18 changes: 18 additions & 0 deletions src/Toplo/ToButtonType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ Class {
#category : #'Toplo-Widget-Button-Skins'
}

{ #category : #accessing }
ToButtonType >> backgroundLookIn: anElement [

^ nil
]

{ #category : #accessing }
ToButtonType >> borderLookIn: anElement [

^ nil
]

{ #category : #accessing }
ToButtonType >> danger [

Expand Down Expand Up @@ -80,13 +92,19 @@ ToButtonType >> regularLabelLookIn: anElement [
{ #category : #'api - install/uninstall hook' }
ToButtonType >> whenAddedToSpace: anEvent in: anElement fromSkin: aSkin [

| borderLook backgroundLook |
anElement geometry: (BlRoundedRectangleGeometry cornerRadius: anElement toTheme borderRadius).
anElement spacingWidth: anElement toTheme paddingContentHorizontal / 2.
anElement padding: (BlInsets
top: anElement toTheme paddingXS / 2
left: anElement toTheme paddingContentHorizontal
bottom: anElement toTheme paddingXS / 2
right: anElement toTheme paddingContentHorizontal).
backgroundLook := self backgroundLookIn: anElement.
backgroundLook ifNotNil: [ aSkin addLook: backgroundLook ].
borderLook := self borderLookIn: anElement.
borderLook ifNil: [ ^ self ].
aSkin addLook: borderLook
]

{ #category : #'api - install/uninstall hook' }
Expand Down
11 changes: 9 additions & 2 deletions src/Toplo/ToCheckMenuItem.class.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Class {
#name : #ToCheckMenuItem,
#superclass : #ToButtonMenuItem,
#traits : 'TToCheckable + TToCheckableWithIndeterminate',
#classTraits : 'TToCheckable classTrait + TToCheckableWithIndeterminate classTrait',
#traits : 'TToCheckable',
#classTraits : 'TToCheckable classTrait',
#category : #'Toplo-Widget-Menu'
}

Expand All @@ -11,3 +11,10 @@ ToCheckMenuItem >> defaultDresser [

^ ToBasicMenuItemDresser next: (ToCheckBoxDresser new)
]

{ #category : #initialization }
ToCheckMenuItem >> initialize [

super initialize.
self initializeCheckable
]
11 changes: 9 additions & 2 deletions src/Toplo/ToCheckNode.class.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Class {
#name : #ToCheckNode,
#superclass : #ToLabeledNode,
#traits : 'TToCheckable + TToCheckableWithIndeterminate',
#classTraits : 'TToCheckable classTrait + TToCheckableWithIndeterminate classTrait',
#traits : 'TToCheckable',
#classTraits : 'TToCheckable classTrait',
#category : #'Toplo-Core-Node'
}

Expand All @@ -11,3 +11,10 @@ ToCheckNode >> defaultDresser [

^ ToCheckNodeDresser new
]

{ #category : #initialization }
ToCheckNode >> initialize [

super initialize.
self initializeCheckable
]
2 changes: 1 addition & 1 deletion src/Toplo/ToCheckableGroupStrictStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
{ #category : #notifications }
ToCheckableGroupStrictStrategy >> buttonInserted: aCheckable in: aGroup [

aCheckable checked ifTrue: [
aCheckable isChecked ifTrue: [
(aGroup buttons select: [ :b | b ~= aCheckable and: [ b checked ] ])
do: [ :b | b privateChecked: false ] ].
super buttonInserted: aCheckable in: aGroup
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToCheckbox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ToCheckbox >> defaultSkin [
^ ToCheckboxSkin new
]

{ #category : #'as yet unclassified' }
{ #category : #initialization }
ToCheckbox >> initialize [

super initialize.
Expand Down
3 changes: 2 additions & 1 deletion src/Toplo/ToChoiceBoxMenuItem.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ ToChoiceBoxMenuItem >> defaultDresser [
^ ToBasicMenuItemDresser next: (ToChoiceBoxMenuItemDresser new)
]

{ #category : #'as yet unclassified' }
{ #category : #initialization }
ToChoiceBoxMenuItem >> initialize [

super initialize.
self initializeCheckable.
self whenClickedDo: [ self switchToNextState ]
]
Loading

0 comments on commit 2713e6f

Please sign in to comment.