Skip to content

Commit

Permalink
ToBackgroundLook, ToImageFormLook and ToBorderLook take valuable as p…
Browse files Browse the repository at this point in the history
…roperty values instead of fixed values
  • Loading branch information
plantec committed Jul 24, 2023
1 parent feea14b commit 818eca1
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 50 deletions.
15 changes: 14 additions & 1 deletion src/Toplo-LookAndFeel/ToTheme.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,25 @@ ToTheme >> controlHeightSM [
]

{ #category : #border }
ToTheme >> dashed [
ToTheme >> dashArray [
"dashed rendering equivalent in web UI"

^ #( 3 3 )
]

{ #category : #border }
ToTheme >> dashed [
"dashed rendering equivalent in web UI"


self
deprecated: 'Please use dashArray instead.'
transformWith: '`@receiver dashed'
-> '`@receiver dashArray'.

^ self dashArray
]

{ #category : #settings }
ToTheme >> defaultColorPrimary [

Expand Down
12 changes: 6 additions & 6 deletions src/Toplo/ToBackgroundLook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ ToBackgroundLook >> hoverBg [
]

{ #category : #accessing }
ToBackgroundLook >> hoverBg: aBackground [
ToBackgroundLook >> hoverBg: aValuable [

hoverBg := aBackground
hoverBg := aValuable
]

{ #category : #'event handling' }
Expand All @@ -36,9 +36,9 @@ ToBackgroundLook >> initialBg [
]

{ #category : #accessing }
ToBackgroundLook >> initialBg: anObject [
ToBackgroundLook >> initialBg: aValuable [

initialBg := anObject
initialBg := aValuable
]

{ #category : #'event handling' }
Expand All @@ -56,9 +56,9 @@ ToBackgroundLook >> pressedBg [
]

{ #category : #accessing }
ToBackgroundLook >> pressedBg: aBackground [
ToBackgroundLook >> pressedBg: aValuable [

pressedBg := aBackground
pressedBg := aValuable
]

{ #category : #'event handling' }
Expand Down
46 changes: 34 additions & 12 deletions src/Toplo/ToBorderLook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Class {
'builder',
'pressedPaint',
'hoverPaint',
'initialPaint'
'initialPaint',
'width',
'dashArray'
],
#category : #'Toplo-Core-Theme-Looks'
}
Expand Down Expand Up @@ -41,9 +43,15 @@ ToBorderLook >> clickLookEvent: anEvent [
]

{ #category : #accessing }
ToBorderLook >> dashArray: anArray [
ToBorderLook >> dashArray [

self builder dashArray: anArray
^ dashArray
]

{ #category : #accessing }
ToBorderLook >> dashArray: aValuable [

dashArray := aValuable
]

{ #category : #initialization }
Expand All @@ -64,9 +72,9 @@ ToBorderLook >> hoverPaint [
]

{ #category : #accessing }
ToBorderLook >> hoverPaint: aPaint [
ToBorderLook >> hoverPaint: aValuable [

hoverPaint := aPaint
hoverPaint := aValuable
]

{ #category : #'event handling' }
Expand All @@ -76,6 +84,8 @@ ToBorderLook >> hoveredLookEvent: anEvent [
self hoverPaint ifNil: [ ^ self ].
anEvent elementDo: [ :e |
e border: (self builder
dashArray: (self dashArray value: e);
width: (self width value: e);
paint: (self hoverPaint value: e);
build) ]
]
Expand All @@ -87,6 +97,8 @@ ToBorderLook >> initialLookEvent: anEvent [
self initialPaint ifNil: [ ^ self ].
anEvent elementDo: [ :e |
e border: (self builder
dashArray: (self dashArray value: e);
width: (self width value: e);
paint: (self initialPaint value: e);
build) ]
]
Expand All @@ -98,16 +110,18 @@ ToBorderLook >> initialPaint [
]

{ #category : #accessing }
ToBorderLook >> initialPaint: aPaint [
ToBorderLook >> initialPaint: aValuable [

initialPaint := aPaint
initialPaint := aValuable
]

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

super initialize.
builder := self defaultBuilder
builder := self defaultBuilder.
dashArray := [ :e | #() ].
width := [ :e | 0 ]
]

{ #category : #'event handling' }
Expand All @@ -117,6 +131,8 @@ ToBorderLook >> pressedLookEvent: anEvent [
self pressedPaint ifNil: [ ^ self ].
anEvent elementDo: [ :e |
e border: (self builder
dashArray: (self dashArray value: e);
width: (self width value: e);
paint: (self pressedPaint value: e);
build) ]
]
Expand All @@ -128,13 +144,19 @@ ToBorderLook >> pressedPaint [
]

{ #category : #accessing }
ToBorderLook >> pressedPaint: aPaint [
ToBorderLook >> pressedPaint: aValuable [

pressedPaint := aPaint
pressedPaint := aValuable
]

{ #category : #accessing }
ToBorderLook >> width: aNumber [
ToBorderLook >> width [

self builder width: aNumber
^ width
]

{ #category : #accessing }
ToBorderLook >> width: aValuable [

width := aValuable
]
21 changes: 11 additions & 10 deletions src/Toplo/ToButtonDefaultType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ ToButtonDefaultType >> borderLookIn: anElement [

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

Expand All @@ -46,9 +47,9 @@ ToButtonDefaultType >> regularFormLookIn: anElement [
| formLook |
formLook := ToImageFormLook new.
formLook
initialColor: anElement toTheme colorText;
hoverColor: anElement toTheme colorPrimary;
pressedColor: anElement toTheme colorPrimaryPressed.
initialColor: [ :e | e toTheme colorText];
hoverColor: [ :e | e toTheme colorPrimary];
pressedColor: [ :e | e toTheme colorPrimaryPressed].
^ formLook
]

Expand Down
6 changes: 3 additions & 3 deletions src/Toplo/ToButtonLinkType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ToButtonLinkType >> regularFormLookIn: anElement [
| formLook |
formLook := ToImageFormLook new.
formLook
initialColor: anElement toTheme colorLink;
hoverColor: anElement toTheme colorLinkHover;
pressedColor: anElement toTheme colorPrimaryPressed.
initialColor: [ :e | e toTheme colorLink];
hoverColor: [ :e | e toTheme colorLinkHover];
pressedColor: [ :e | e toTheme colorPrimaryPressed].
^ formLook
]

Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToButtonPrimaryType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ToButtonPrimaryType >> labelLookIn: anElement [
ToButtonPrimaryType >> regularFormLookIn: anElement [

^ ToImageFormLook new
initialColor: anElement toTheme colorImageLightSolid;
initialColor: [ :e | e toTheme colorImageLightSolid ];
yourself
]

Expand Down
6 changes: 3 additions & 3 deletions src/Toplo/ToButtonTextType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ ToButtonTextType >> regularFormLookIn: anElement [
| formLook |
formLook := ToImageFormLook new.
formLook
initialColor: anElement toTheme colorText;
hoverColor: anElement toTheme colorText;
pressedColor: anElement toTheme colorText.
initialColor: [ :e | e toTheme colorText];
hoverColor: [ :e | e toTheme colorText];
pressedColor: [ :e | e toTheme colorText].
^ formLook
]

Expand Down
6 changes: 3 additions & 3 deletions src/Toplo/ToButtonType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ ToButtonType >> dangerFormLookIn: anElement [
| formLook |
formLook := ToImageFormLook new.
formLook
initialColor: anElement toTheme colorError;
hoverColor: anElement toTheme colorErrorHover;
pressedColor: anElement toTheme colorError darker.
initialColor: [ :e | e toTheme colorError];
hoverColor: [ :e | e toTheme colorErrorHover];
pressedColor: [ :e | e toTheme colorError darker].
^ formLook
]

Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToCheckboxImageSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ToCheckboxImageSkin >> onSkinInstalledIn: anElement [
initialPaint: [ :e | e toTheme colorBorder];
hoverPaint: [ :e | e toTheme colorPrimaryHover];
pressedPaint: [ :e | e toTheme colorPrimaryPressed];
width: 1.
width: [ :e | e toTheme lineWidth ].
self addLook: borderLook.


Expand Down
18 changes: 9 additions & 9 deletions src/Toplo/ToImageFormLook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ ToImageFormLook >> hoverColor [
]

{ #category : #accessing }
ToImageFormLook >> hoverColor: aColor [
ToImageFormLook >> hoverColor: aValuable [

hoverColor := aColor
hoverColor := aValuable
]

{ #category : #'event handling' }
Expand All @@ -38,7 +38,7 @@ ToImageFormLook >> hoveredLookEvent: anEvent [
super hoveredLookEvent: anEvent.
self hoverColor ifNil: [ ^ self ].
anEvent elementDo: [ :e |
self adaptForegroundIn: e withColor: self hoverColor ]
self adaptForegroundIn: e withColor: (self hoverColor value: e) ]
]

{ #category : #accessing }
Expand All @@ -48,9 +48,9 @@ ToImageFormLook >> initialColor [
]

{ #category : #accessing }
ToImageFormLook >> initialColor: aColor [
ToImageFormLook >> initialColor: aValuable [

initialColor := aColor
initialColor := aValuable
]

{ #category : #'event handling' }
Expand All @@ -59,7 +59,7 @@ ToImageFormLook >> initialLookEvent: anEvent [
super initialLookEvent: anEvent.
self initialColor ifNil: [ ^ self ].
anEvent elementDo: [ :e |
self adaptForegroundIn: e withColor: self initialColor ]
self adaptForegroundIn: e withColor: (self initialColor value: e) ]
]

{ #category : #accessing }
Expand All @@ -69,9 +69,9 @@ ToImageFormLook >> pressedColor [
]

{ #category : #accessing }
ToImageFormLook >> pressedColor: aColor [
ToImageFormLook >> pressedColor: aValuable [

pressedColor := aColor
pressedColor := aValuable
]

{ #category : #'event handling' }
Expand All @@ -80,5 +80,5 @@ ToImageFormLook >> pressedLookEvent: anEvent [
super pressedLookEvent: anEvent.
self pressedColor ifNil: [ ^ self ].
anEvent elementDo: [ :e |
self adaptForegroundIn: e withColor: self pressedColor ]
self adaptForegroundIn: e withColor: (self pressedColor value: e)]
]
2 changes: 1 addition & 1 deletion src/Toplo/ToRadioImageSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ToRadioImageSkin >> onSkinInstalledIn: anElement [
initialPaint: [ :e | e toTheme colorBorder];
hoverPaint: [ :e | e toTheme colorPrimaryHover];
pressedPaint: [ :e | e toTheme colorPrimaryPressed];
width: 1.
width: [ :e | e toTheme lineWidth ].
self addLook: borderLook.


Expand Down

0 comments on commit 818eca1

Please sign in to comment.