Skip to content

Commit

Permalink
removed skin related stuffs in ToLabeledIcon
Browse files Browse the repository at this point in the history
fixed ToElementState>>applyOn: to work well with stillPressed and stillHover
  • Loading branch information
plantec committed Nov 1, 2023
1 parent 68c77a0 commit 92a5aa0
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 244 deletions.
6 changes: 3 additions & 3 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ ToSandBox class >> example_ListWithEditableAndContextMenu [
lab beMultiLine.
lab beEditable.
lab stillPressedStartDelay: 800 milliSeconds.
lab when: ToStillPressedLookEvent do: [ :event | event sourceEvent consumed: true. lab editor ifNotNil: [ :ed | self halt ]. lab addEditorEvent: event].
lab when: ToStillPressedLookEvent do: [ :event | event consumed: true. lab addEditorEvent: event].
lab whenTextReplacedDo: [
l data at: holder position put: lab text asString ].
node addChild: (ToLabeledIcon new
Expand Down Expand Up @@ -2347,7 +2347,7 @@ ToSandBox class >> example_stillHoveredEvent [
lab text: count asString asRopedText.
count := count + 1.
count > 50 ifTrue: [
event sourceEvent consumed: true.
event consumed: true.
count := 0 ] ].
e openInSpace
]
Expand All @@ -2374,7 +2374,7 @@ ToSandBox class >> example_stillPressedEvent [
count := count + 1.
color := color darker.
count > 50 ifTrue: [
event sourceEvent consumed: true.
event consumed: true.
count := 0.
color := Color white alpha: 0.3] ].
e openInSpace
Expand Down
14 changes: 7 additions & 7 deletions src/Toplo-Tests/ToElementTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ ToElementTest >> testWithoutSkin [
]

{ #category : 'test initialize' }
ToElementTest >> testWithoutSkinContamination [
ToElementTest >> testWithoutSkinNonContamination [

" NullSkin is contaminant: check if children are correctly impacted (withoutSkin must be applied recursively)"
" NullSkin is not contaminant: check if children are not impacted "

| e child childchild |

Expand All @@ -238,13 +238,13 @@ ToElementTest >> testWithoutSkinContamination [
self assert: e skinInstaller isNil.
self assert: e installedSkin isNullSkin.
self assert: child skinInstaller isNil.
self assert: child installedSkin isNullSkin.
self assert: child installedSkin isNil.
self assert: childchild skinInstaller isNil.
self assert: childchild installedSkin isNullSkin
self assert: childchild installedSkin isNil
]

{ #category : 'test initialize' }
ToElementTest >> testWithoutSkinContamination2 [
ToElementTest >> testWithoutSkinNonContamination2 [

" check if children are correctly impacted when they are added as child of their parent
(withoutSkin must be applied when a child is added )"
Expand All @@ -267,7 +267,7 @@ ToElementTest >> testWithoutSkinContamination2 [
child applySkinInstaller.
childchild applySkinInstaller.
self assert: child skinInstaller isNil.
self assert: child installedSkin isNullSkin.
self assert: child installedSkin isNil.
self assert: childchild skinInstaller isNil.
self assert: childchild installedSkin isNullSkin
self assert: childchild installedSkin isNil
]
168 changes: 0 additions & 168 deletions src/Toplo-Tests/ToLabeledIconEventHandlerTest.class.st

This file was deleted.

5 changes: 4 additions & 1 deletion src/Toplo-Theme/ToElementState.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ ToElementState class >> sourceEvent: anEvent [
{ #category : 'look event sending' }
ToElementState >> applyOn: anElement [

anElement dispatchLookEvent: (self newLookEventFromSourceEvent: self sourceEvent)
| lookEvent |
lookEvent := self newLookEventFromSourceEvent: self sourceEvent.
anElement dispatchLookEvent: lookEvent.
lookEvent isConsumed ifTrue: [ self sourceEvent consumed: true ]
]

{ #category : 'skin state engine' }
Expand Down
4 changes: 4 additions & 0 deletions src/Toplo-Widget-Button/ToButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Class {
ToButton >> initialRawStyle [

super initialRawStyle.
self labeledIcon childrenDo: [ :child |
child constraintsDo: [ :c |
c linear vertical alignCenter.
c linear horizontal alignCenter ] ].
((self parent isKindOf: ToMenuItem) and: [ self parent isTopMenu not ])
ifTrue: [ ^ self ].
(self hasIcon and: [ self hasLabel ]) ifFalse: [
Expand Down
10 changes: 10 additions & 0 deletions src/Toplo-Widget-Menu/ToMenuItem.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ ToMenuItem >> filler [
^ filler
]

{ #category : 'skin' }
ToMenuItem >> initialRawStyle [

super initialRawStyle.
self labeledIcon childrenDo: [ :child |
child constraintsDo: [ :c |
c linear vertical alignCenter.
c linear horizontal alignCenter ] ].
]

{ #category : 'initialization' }
ToMenuItem >> initialize [

Expand Down
1 change: 1 addition & 0 deletions src/Toplo-Widget-Menu/ToMenuWindow.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Class {
ToMenuWindow >> close [

openedSubmenuWindow ifNotNil: [ :w | w close ].
self root removeChildren.
super close
]

Expand Down
5 changes: 1 addition & 4 deletions src/Toplo/ToElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ ToElement >> onAddedToParent [

super onAddedToParent.
self hasEnablementFlag ifFalse: [
self enabled: self parent isEnabled ].
self parent isWithoutSkin
ifFalse: [ self parent requestSkin ]
ifTrue: [ self withoutSkin ]
self enabled: self parent isEnabled ]
]

{ #category : 'hooks - children' }
Expand Down
32 changes: 5 additions & 27 deletions src/Toplo/ToLabeledIcon.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ ToLabeledIcon >> beLabelFirst [
self requestLayout
]

{ #category : 'accessing' }
ToLabeledIcon >> defaultEventHandler [

^ ToLabeledIconEventHandler new
]

{ #category : 'initialization' }
ToLabeledIcon >> defaultLayout [

Expand Down Expand Up @@ -94,9 +88,7 @@ ToLabeledIcon >> icon: anElement [
self icon ifNotNil: [ :s | self icon removeFromParent ].
icon := anElement.
anElement ifNil: [ ^ self ].
self iconHolder addChild: anElement.
self requestSkin

self iconHolder addChild: anElement
]

{ #category : 'configurating' }
Expand Down Expand Up @@ -180,18 +172,7 @@ ToLabeledIcon >> initialize [
self addChild: filler.
self addChild: labelHolder.
self beIconFirst.
self fitContent.
self addEventHandler: self defaultEventHandler
]

{ #category : 'skin' }
ToLabeledIcon >> installRawStyle [

super installRawStyle.
self childrenDo: [ :child |
child constraintsDo: [ :c |
c linear vertical alignCenter.
c linear horizontal alignCenter ] ]
self fitContent
]

{ #category : 'accessing' }
Expand All @@ -211,8 +192,7 @@ ToLabeledIcon >> interspace: aPoint [
self filler constraints
minWidth: size x;
minHeight: size y.
self filler requestLayout.
self requestSkin
self filler requestLayout
]

{ #category : 'testing' }
Expand Down Expand Up @@ -246,8 +226,7 @@ ToLabeledIcon >> label: anElement [
self label ifNotNil: [ :s | s removeFromParent].
label := anElement.
anElement ifNil: [ ^ self ].
self labelHolder addChild: anElement.
self requestSkin
self labelHolder addChild: anElement
]

{ #category : 'configurating' }
Expand Down Expand Up @@ -277,6 +256,5 @@ ToLabeledIcon >> layoutStrategy [
{ #category : 'accessing' }
ToLabeledIcon >> rightLabelAlignment: anInteger [

self iconHolderWidth: anInteger.
self requestSkin
self iconHolderWidth: anInteger
]
Loading

0 comments on commit 92a5aa0

Please sign in to comment.