Skip to content

Commit

Permalink
Merge pull request #162 from pharo-graphics/#155-
Browse files Browse the repository at this point in the history
lookEvent -> skinEvent
  • Loading branch information
plantec authored Jun 26, 2024
2 parents b122cf6 + bb21b3d commit 81c31b6
Show file tree
Hide file tree
Showing 174 changed files with 1,912 additions and 1,664 deletions.
10 changes: 5 additions & 5 deletions src/Toplo-Demo/ToBeetleTheme.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ToBeetleTheme >> initializeStyleRules [

" installation rules "
self
when: ToInstallLookEvent
when: ToInstallSkinEvent
write: (self property: #background)
with: [ :e | Color lightGray ].
self write: (self property: #geometry) with: BlCircleGeometry new.
Expand All @@ -27,21 +27,21 @@ ToBeetleTheme >> initializeStyleRules [

" hovered rules "
self
when: ToHoveredLookEvent
when: ToHoveredSkinEvent
write: (self property: #background)
with: Color white.
self
when: ToHoveredLookEvent
when: ToHoveredSkinEvent
write: (self property: #border)
with: (BlBorder paint: Color blue width: 4).

" leaved rules "
self
when: ToLeavedLookEvent
when: ToLeavedSkinEvent
write: (self property: #background)
with: Color lightGray.
self
when: ToLeavedLookEvent
when: ToLeavedSkinEvent
write: (self property: #border)
with: (BlBorder paint: Color yellow width: 4) ]
]
6 changes: 0 additions & 6 deletions src/Toplo-Demo/ToDemo1.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ ToDemo1 class >> example1 [

| dem |
dem := ToDemo1 new.
" setup the default skin ->
ask to install it.
then run:
ToDemo1>>installRawStyle then
ToDemo1Skin>>installLookEvent:
"
dem defaultRawSkin: ToDemoSkin1 new.
dem openInSpace
]
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Demo/ToDemo5.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ToDemo5 class >> example0 [
dem2 := ToDemo5 new.
dem2 defaultButterflySkin: ToDemoButterflySkin2 new.
dem2 addEventHandler: (BlEventHandler
on: ToElementLookEvent
on: ToSkinEvent
do: [ :evt | evt target = dem2 ifTrue: [ evt traceCr ] ]).
pane addChild: dem1.
pane addChild: dem2.
Expand Down
4 changes: 2 additions & 2 deletions src/Toplo-Demo/ToDemo7ButterflySkin1.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Class {
}

{ #category : #'event handling' }
ToDemo7ButterflySkin1 >> installLookEvent: anEvent [
ToDemo7ButterflySkin1 >> installSkinEvent: anEvent [

super installLookEvent: anEvent.
super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
e border: Color red.
e fitContent.
Expand Down
4 changes: 2 additions & 2 deletions src/Toplo-Demo/ToDemo7ButterflySkin2.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Class {
}

{ #category : #'event handling' }
ToDemo7ButterflySkin2 >> installLookEvent: anEvent [
ToDemo7ButterflySkin2 >> installSkinEvent: anEvent [

super installLookEvent: anEvent.
super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
e border: Color blue.
e padding: (BlInsets all: 15).
Expand Down
12 changes: 6 additions & 6 deletions src/Toplo-Demo/ToDemoButterflySkin1.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ Class {
}

{ #category : #'event handling' }
ToDemoButterflySkin1 >> hoveredLookEvent: anEvent [
ToDemoButterflySkin1 >> hoveredSkinEvent: anEvent [

super hoveredLookEvent: anEvent.
super hoveredSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: Color white.
e border: (BlBorder paint: Color blue width: 4) ]
]

{ #category : #'event handling' }
ToDemoButterflySkin1 >> installLookEvent: anEvent [
ToDemoButterflySkin1 >> installSkinEvent: anEvent [

super installLookEvent: anEvent.
super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
e geometry: BlCircleGeometry new.
e background: Color lightGray.
e border: (BlBorder paint: Color yellow width: 4) ]
]

{ #category : #'event handling' }
ToDemoButterflySkin1 >> leavedLookEvent: anEvent [
ToDemoButterflySkin1 >> leavedSkinEvent: anEvent [

super leavedLookEvent: anEvent.
super leavedSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: Color lightGray.
e border: (BlBorder paint: Color yellow width: 4) ]
Expand Down
16 changes: 8 additions & 8 deletions src/Toplo-Demo/ToDemoButterflySkin2.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Class {
}

{ #category : #'event handling' }
ToDemoButterflySkin2 >> hoveredLookEvent: anEvent [
ToDemoButterflySkin2 >> hoveredSkinEvent: anEvent [

super hoveredLookEvent: anEvent.
super hoveredSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: (e valueOfTokenNamed: #'color-success') ]
]

{ #category : #'event handling' }
ToDemoButterflySkin2 >> installLookEvent: anEvent [
ToDemoButterflySkin2 >> installSkinEvent: anEvent [

super installLookEvent: anEvent.
super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
| im |
e layout: BlFrameLayout new.
Expand All @@ -31,17 +31,17 @@ ToDemoButterflySkin2 >> installLookEvent: anEvent [
]

{ #category : #'event handling' }
ToDemoButterflySkin2 >> leavedLookEvent: anEvent [
ToDemoButterflySkin2 >> leavedSkinEvent: anEvent [

super leavedLookEvent: anEvent.
super leavedSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: (e valueOfTokenNamed: #'color-primary') ]
]

{ #category : #'event handling' }
ToDemoButterflySkin2 >> uninstallLookEvent: anEvent [
ToDemoButterflySkin2 >> uninstallSkinEvent: anEvent [

super uninstallLookEvent: anEvent.
super uninstallSkinEvent: anEvent.
anEvent elementDo: [ :e |
e removeChildren ]
]
4 changes: 2 additions & 2 deletions src/Toplo-Demo/ToDemoSkin1.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Class {
}

{ #category : #'event handling' }
ToDemoSkin1 >> installLookEvent: anEvent [
ToDemoSkin1 >> installSkinEvent: anEvent [

super installLookEvent: anEvent.
super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: Color blue.
e size: 50 @ 50 ]
Expand Down
12 changes: 6 additions & 6 deletions src/Toplo-Demo/ToDemoSkin2.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ Class {
}

{ #category : #'event handling' }
ToDemoSkin2 >> hoveredLookEvent: anEvent [
ToDemoSkin2 >> hoveredSkinEvent: anEvent [

super hoveredLookEvent: anEvent.
super hoveredSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: Color red.
e border: (BlBorder paint: Color blue width: 4) ]
]

{ #category : #'event handling' }
ToDemoSkin2 >> installLookEvent: anEvent [
ToDemoSkin2 >> installSkinEvent: anEvent [

super installLookEvent: anEvent.
super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: Color blue.
e border: (BlBorder paint: Color black width: 1) ]
]

{ #category : #'event handling' }
ToDemoSkin2 >> leavedLookEvent: anEvent [
ToDemoSkin2 >> leavedSkinEvent: anEvent [

super leavedLookEvent: anEvent.
super leavedSkinEvent: anEvent.
anEvent elementDo: [ :e |
e background: Color white.
e border: (BlBorder paint: Color red width: 1) ]
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Examples/ToListClassNodeExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ToListClassNodeExample >> forClassNameAssoc: aClassNameAssoc [
self
stillPressedStartDelay: 400 milliSeconds;
addEventHandler: (BlEventHandler
on: ToStillPressedLookEvent
on: ToStillPressedSkinEvent
do: [ :event |
event consume.
event currentTarget label addEditorEvent: event ]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Class {
}

{ #category : #'event handling' }
ToPicsumPhotosGallerySelectionSkin >> installLookEvent: anEvent [
ToPicsumPhotosGallerySelectionSkin >> installSkinEvent: anEvent [

super installLookEvent: anEvent.
super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
| im cont bar w |
w := 3.
Expand Down
48 changes: 24 additions & 24 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ ToSandBox class >> example_CheckboxChecked [
ToTheme cleanUp.
chb := ToCheckbox new label: (ToLabel text: 'Checkbox').
chb addEventHandler: (BlEventHandler
on: ToElementLookEvent
on: ToSkinEvent
do: [ :evt | evt target = chb ifTrue: [ evt traceCr ] ]).
chb whenClickedDo: [ :event |
event currentTarget isChecked traceCr.
Expand Down Expand Up @@ -570,7 +570,7 @@ ToSandBox class >> example_CheckboxVertical [
chb := ToCheckbox new label: (ToLabel text: 'Checkbox').
chb beVertical.
chb addEventHandler: (BlEventHandler
on: ToElementLookEvent
on: ToSkinEvent
do: [ :evt | evt target = chb ifTrue: [ evt traceCr ] ]).
chb checked: true.
chb openInInnerWindow.
Expand Down Expand Up @@ -1185,7 +1185,7 @@ ToSandBox class >> example_ListWithEditableAndContextMenu [
lab beEditable.
lab stillPressedStartDelay: 800 milliSeconds.
lab addEventHandler: (BlEventHandler
on: ToStillPressedLookEvent
on: ToStillPressedSkinEvent
do: [ :event |
event consume.
lab addEditorEvent: event ]).
Expand Down Expand Up @@ -2240,6 +2240,21 @@ ToSandBox class >> example_SimpleOpenSaveSaveAsClose [
container openInSpace
]

{ #category : #'look event' }
ToSandBox class >> example_SkinEventTrace [

| but |
but := ToButton new.
but icon: (ToImage new innerImage: (self iconNamed: #solidMenu)).
but label: (ToLabel text: 'Button with label').
but addEventHandler: (BlEventHandler
on: ToSkinEvent
do: [ :evt | evt target = but ifTrue: [ evt traceCr ] ]).
but stillPressedStartDelay: 3000 milliSeconds.
but inspect.
but openInSpace
]

{ #category : #image }
ToSandBox class >> example_Smalltalk_ui_icons [

Expand Down Expand Up @@ -2620,7 +2635,7 @@ ToSandBox class >> example_ToggleButtonChecked [
toggle := ToToggleButton new label: (ToLabel text: 'Toggle button').
toggle icon: (ToImage new innerImage: (self iconNamed: #solidMenu)).
toggle addEventHandler: (BlEventHandler
on: ToElementLookEvent
on: ToSkinEvent
do: [ :evt | evt target = toggle ifTrue: [ evt traceCr ] ]).
toggle whenClickedDo: [ :event |
event currentTarget isChecked traceCr.
Expand Down Expand Up @@ -3153,21 +3168,6 @@ ToSandBox class >> example_horizontalPaneWithDivider [
pane openInSpace
]

{ #category : #'look event' }
ToSandBox class >> example_lookEventTrace [

| but |
but := ToButton new.
but icon: (ToImage new innerImage: (self iconNamed: #solidMenu)).
but label: (ToLabel text: 'Button with label').
but addEventHandler: (BlEventHandler
on: ToElementLookEvent
do: [ :evt | evt target = but ifTrue: [ evt traceCr ] ]).
but stillPressedStartDelay: 3000 milliSeconds.
but inspect.
but openInSpace
]

{ #category : #'context menu + menubar' }
ToSandBox class >> example_menuBar1 [

Expand Down Expand Up @@ -3557,7 +3557,7 @@ ToSandBox class >> example_stillHoveredEvent [
e border: Color black.
count := 0.
e addEventHandler: (BlEventHandler
on: ToStillHoveredLookEvent
on: ToStillHoveredSkinEvent
do: [ :event |
lab text: count asString asRopedText.
count := count + 1.
Expand All @@ -3584,7 +3584,7 @@ ToSandBox class >> example_stillPressedEvent [
count := 0.
color := Color white alpha: 0.3.
e addEventHandler: (BlEventHandler
on: ToStillPressedLookEvent
on: ToStillPressedSkinEvent
do: [ :event |
e background: color.
lab text: count asString asRopedText.
Expand All @@ -3603,7 +3603,7 @@ ToSandBox class >> example_switchButton [
| th |
th := ToSwitchButton new.
th
addEventHandlerOn: ToElementLookEvent
addEventHandlerOn: ToSkinEvent
do: [ :event | event traceCr ].
th checked: true.
th wishedTrackSize: 100 @ 30.
Expand Down Expand Up @@ -3642,7 +3642,7 @@ ToSandBox class >> example_switchButton3 [
but hMatchParent.
but labelText: ('Something' asRopedText fontSize: 44).
handler := BlEventHandler
on: ToElementLookEvent
on: ToSkinEvent
do: [ :event | event traceCr ].
but addEventHandler: handler.
onLab := ToLabel text: ('In' asRopedText foreground: Color white; fontSize: 44).
Expand Down Expand Up @@ -4364,7 +4364,7 @@ ToSandBox class >> example_toKeepTooltipWindowOnMouseLeaveWithEditableLabel [
beEditable;
stillHoveredStartDelay: 800 milliSeconds;
addEventHandler: (BlEventHandler
on: ToStillHoveredLookEvent
on: ToStillHoveredSkinEvent
do: [ :event |
event consume.
event currentTarget addEditorEvent: event ]).
Expand Down
18 changes: 18 additions & 0 deletions src/Toplo-IDE/ToSkinEvent.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Extension { #name : #ToSkinEvent }

{ #category : #'*Toplo-IDE' }
ToSkinEvent >> eventName [

^ self class eventName
]

{ #category : #'*Toplo-IDE' }
ToSkinEvent class >> eventName [

| eventGroups |
eventGroups := self name
regex: '[A-Z][a-z]*'
matchesCollect: [ :each | each ].
eventGroups first = 'To' ifTrue: [eventGroups := eventGroups allButFirst].( (eventGroups last: 2) allSatisfy: [ :each | each = 'Skin' or: [ each = 'Event' ] ] ) ifTrue: [ eventGroups := eventGroups allButLast: 2 ].
^ Character space join: eventGroups
]
Loading

0 comments on commit 81c31b6

Please sign in to comment.