diff --git a/src/Toplo-Examples/ToSandBox.class.st b/src/Toplo-Examples/ToSandBox.class.st index 635d06391..91ceb6f5f 100644 --- a/src/Toplo-Examples/ToSandBox.class.st +++ b/src/Toplo-Examples/ToSandBox.class.st @@ -1114,12 +1114,11 @@ ToSandBox class >> example_OpenSaveSaveAsCloseWithSubmenu [ size: 400 @ 200; yourself. menu := ToMenu new. - menu label: (ToLabel text: 'Menu'). + "menu label: (ToLabel text: 'Menu')." menu icon: (ToImage inner: (self iconNamed: #solidMenu)). menu addItem: (ToMenuItem new icon: (ToImage inner: (self iconNamed: #solidMenu)); label: (ToLabel text: 'Open')). - menu items last rightLabelAlignment: 20. lbl := ToLabel new text: ('Save stuffs' asRopedText fontSize: 12; foreground: (Color black alpha: 0.7)). @@ -1129,7 +1128,6 @@ ToSandBox class >> example_OpenSaveSaveAsCloseWithSubmenu [ menu addItem: (ToMenuItem new icon: (ToImage inner: (self iconNamed: #solidMenu)); label: (ToLabel text: 'Save')). - menu items last rightLabelAlignment: 20. saveAs := ToMenu new label: (ToLabel text: 'Save as'). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.pdf')). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.doc')). @@ -1137,23 +1135,19 @@ ToSandBox class >> example_OpenSaveSaveAsCloseWithSubmenu [ menu addItem: saveAs. "menu items last when: BlMouseDownEvent do: [ :event | event currentTarget inspect ]." - menu items last rightLabelAlignment: 20. saveAs := ToMenu new label: (ToLabel text: 'Save as'). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.pdf')). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.doc')). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.xml')). menu addItem: saveAs. - menu items last rightLabelAlignment: 20. saveAs := ToMenu new label: (ToLabel text: 'Save as'). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.pdf')). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.doc')). saveAs addItem: (ToMenuItem new label: (ToLabel text: '.xml')). menu addItem: (ToMenu new label: (ToLabel text: 'Save as again...')). menu items last addItem: saveAs. - menu items last rightLabelAlignment: 20. menu addSeparator. menu addItem: (ToMenuItem new label: (ToLabel text: 'Close')). - menu items last rightLabelAlignment: 20. container pane addChild: menu. "menu window inspect." container openInSpace @@ -1366,23 +1360,19 @@ ToSandBox class >> example_SimpleOpenSaveSaveAsClose [ menu addItem: (ToMenuItem new icon: ((ToImage inner: (self iconNamed: #solidMenu))); label: (ToLabel text: 'Open')). - menu items last rightLabelAlignment: 40. menu addItem: (ToMenuItem new icon: ((ToImage inner: (self iconNamed: #solidMenu))); label: (ToLabel text: 'Save'); background: Color random). - menu items last rightLabelAlignment: 40. menu addItem: (ToMenuItem new icon: ((ToImage inner: (self iconNamed: #solidMenu))); label: (ToLabel text: 'Save as'); background: Color random). - menu items last rightLabelAlignment: 40. menu items last whenClickedDo: [ :event | event currentTarget inspect ]. menu addSeparator. menu addItem: (ToMenuItem new label: (ToLabel text: 'Close'); background: Color random). - menu items last rightLabelAlignment: 40. menu items last whenClickedDo: [ :event | event currentTarget inspect ]. container pane addChild: menu. @@ -2129,18 +2119,17 @@ ToSandBox class >> example_menuBar2 [ | stream selector | stream := String streamContents: [ :out | out - nextPutAll: 'Level'; + nextPutAll: 'Level '; space; print: i ]. selector := String streamContents: [ :out | out - nextPutAll: 'level'; + nextPutAll: 'level '; print: index; - nextPutAll: 'Grid'; + nextPutAll: ' Grid '; print: i ]. subMenu addItem: ((ToMenuItem new labelText: stream) when: BlPrimaryMouseUpEvent do: [ :event | self inform: selector asSymbol ]) ]. - "subMenu defaultColumnWidth: 0." menu addItem: subMenu ]. bar addMenu: menu ]. @@ -2203,6 +2192,7 @@ ToSandBox class >> example_rootFrameWithContextMenu [ win pane contextMenu: [ :menu :element | menu addItem: (ToMenuItem new + id: #openFile; labelText: 'Open file'; icon: (ToImage inner: (Smalltalk ui icons iconNamed: #config))). menu addItem: (ToMenuItem new labelText: 'Export'). @@ -2218,7 +2208,9 @@ ToSandBox class >> example_rootFrameWithContextMenu [ (ToImage inner: (Smalltalk ui icons iconNamed: #solidMenu)). - subsub addItem: (ToMenuItem new id: #here; labelText: 'Here'). + subsub addItem: (ToMenuItem new + id: #here; + labelText: 'Here'). sub addItem: subsub. @@ -3138,10 +3130,8 @@ ToSandBox class >> example_withCheckBox [ menu := ToMenu new. menu labelText: 'File'. menu addItem: (ToMenuItem new labelText: 'Open file'). - menu items last rightLabelAlignment: 20. menu items last icon: ((ToImage inner: (self iconNamed: #solidMenu))). menu addItem: (ToMenuItem new labelText: 'Export'). - menu items last rightLabelAlignment: 20. grp := ToCheckableGroup new. right := ToCheckMenuItem new labelText: 'Right'; @@ -3162,23 +3152,19 @@ ToSandBox class >> example_withCheckBox [ grp add: left. menu addSeparator. - menu addAllItems: (grp buttons collect: [:b | b rightLabelAlignment: 20; yourself]). + menu addAllItems: (grp buttons). . menu addSeparator. sub := ToMenu new labelText: 'Save All'. sub addItem: (ToMenuItem new labelText: 'Locally'). - sub items last rightLabelAlignment: 20. subsub := ToMenu new labelText: 'Externally'. subsub addItem: (ToMenuItem new labelText: 'Here'). - subsub items last rightLabelAlignment: 20. sub addItem: subsub. - sub items last rightLabelAlignment: 20. menu addItem: sub. - menu items last rightLabelAlignment: 20. menu position: 10 @ 10. menu openInInnerWindow ] diff --git a/src/Toplo-Theme/ToSkinStateQueue.class.st b/src/Toplo-Theme/ToSkinStateQueue.class.st index 2109e4d69..acf03e7f2 100644 --- a/src/Toplo-Theme/ToSkinStateQueue.class.st +++ b/src/Toplo-Theme/ToSkinStateQueue.class.st @@ -39,7 +39,7 @@ ToSkinStateQueue >> enqueueState: aState [ ToSkinStateQueue >> enqueueState: aState in: anElement [ " declare the element as dirty " - anElement spaceDo: [ :space | space elementWithUnappliedStates: anElement ]. + anElement spaceDo: [ :space | space requestSkinApplicationFor: anElement ]. self enqueueState: aState ] @@ -86,8 +86,7 @@ ToSkinStateQueue >> skinChangedEvent: anEvent [ installed ifTrue: [ Error signal: 'A skin can be installed only once.' ]. target := anEvent currentTarget. installed := true. - self enqueueState: (ToInstallState sourceEvent: anEvent) in: target. - target requestSkin + self enqueueState: (ToInstallState sourceEvent: anEvent) in: target ] { #category : 'initialization' } diff --git a/src/Toplo-Widget-Album/ToLabelMonoLineInnerElement.class.st b/src/Toplo-Widget-Album/ToLabelMonoLineInnerElement.class.st index 5f90a2576..e32ee4d9c 100644 --- a/src/Toplo-Widget-Album/ToLabelMonoLineInnerElement.class.st +++ b/src/Toplo-Widget-Album/ToLabelMonoLineInnerElement.class.st @@ -32,7 +32,8 @@ ToLabelMonoLineInnerElement >> initialize [ super initialize. " Need Label measurement to ensure right vertical alignement with labels/menus " self labelMeasurement. - self preventMouseEvents + self preventMouseEvents. + self withoutSkin. ] { #category : 'api - editor' } diff --git a/src/Toplo-Widget-Album/ToLabelMultiLineInnerElement.class.st b/src/Toplo-Widget-Album/ToLabelMultiLineInnerElement.class.st index e48421e0d..246b0e6f5 100644 --- a/src/Toplo-Widget-Album/ToLabelMultiLineInnerElement.class.st +++ b/src/Toplo-Widget-Album/ToLabelMultiLineInnerElement.class.st @@ -42,7 +42,8 @@ ToLabelMultiLineInnerElement >> initialize [ self fitContent. self layout: BlLinearLayout vertical. self whenTextReplacedDo: [ :t | self textReplaced ]. - self preventMouseEvents + self preventMouseEvents. + self withoutSkin. ] { #category : 'api - editor' } diff --git a/src/Toplo-Widget-Button/ToButton.class.st b/src/Toplo-Widget-Button/ToButton.class.st index 6e24f8fa3..c5629238b 100644 --- a/src/Toplo-Widget-Button/ToButton.class.st +++ b/src/Toplo-Widget-Button/ToButton.class.st @@ -15,8 +15,8 @@ Class { ToButton >> initialRawStyle [ super initialRawStyle. - "((self parent isKindOf: ToMenuItem) and: [ self parent isTopMenu not ]) - ifTrue: [ ^ self ]." + ((self parent isKindOf: ToMenuItem) and: [ self parent isTopMenu not ]) + ifTrue: [ ^ self ]. (self hasIcon and: [ self hasLabel ]) ifFalse: [ self interspace: 0. ^ self ]. diff --git a/src/Toplo-Widget-Button/ToCheckbox.class.st b/src/Toplo-Widget-Button/ToCheckbox.class.st index e35687232..bff8d4963 100644 --- a/src/Toplo-Widget-Button/ToCheckbox.class.st +++ b/src/Toplo-Widget-Button/ToCheckbox.class.st @@ -13,6 +13,7 @@ ToCheckbox >> defaultBlankCheckboxImage [ | bar im | bar := ToElement new id: #bar. + bar withoutSkin. bar constraintsDo: [ :c | c horizontal matchParent. c vertical exact: 3. @@ -25,6 +26,7 @@ ToCheckbox >> defaultBlankCheckboxImage [ im size: 16 asPoint. im addChild: bar. im geometry: self iconGeometry. + im withoutSkin. ^ im ] diff --git a/src/Toplo-Widget-Button/ToCheckboxSkin.class.st b/src/Toplo-Widget-Button/ToCheckboxSkin.class.st index 3e80acdf1..af044207b 100644 --- a/src/Toplo-Widget-Button/ToCheckboxSkin.class.st +++ b/src/Toplo-Widget-Button/ToCheckboxSkin.class.st @@ -54,7 +54,6 @@ ToCheckboxSkin >> initialLookEvent: anEvent [ super initialLookEvent: anEvent. anEvent elementDo: [ :e | - e hasLabel ifTrue: [ e interspace: 10 ]. e icon border: e iconDefaultBorder ] ] diff --git a/src/Toplo-Widget-Menu/ToContextMenu.class.st b/src/Toplo-Widget-Menu/ToContextMenu.class.st index 02c91a1ac..162835ec2 100644 --- a/src/Toplo-Widget-Menu/ToContextMenu.class.st +++ b/src/Toplo-Widget-Menu/ToContextMenu.class.st @@ -72,6 +72,12 @@ ToContextMenu >> openedEventClass [ ^ ToContextMenuOpenedEvent ] +{ #category : 'api - displaying' } +ToContextMenu >> popupEvent: anEvent [ + + ^ super popupEvent: anEvent +] + { #category : 't - menu window model' } ToContextMenu >> rootMenu [ diff --git a/src/Toplo-Widget-Menu/ToGeneralButtonMenuItem.class.st b/src/Toplo-Widget-Menu/ToGeneralButtonMenuItem.class.st index 7e5002fef..503e4020a 100644 --- a/src/Toplo-Widget-Menu/ToGeneralButtonMenuItem.class.st +++ b/src/Toplo-Widget-Menu/ToGeneralButtonMenuItem.class.st @@ -45,16 +45,6 @@ ToGeneralButtonMenuItem >> defaultLayout [ ^ BlLinearLayout horizontal ] -{ #category : 'skin' } -ToGeneralButtonMenuItem >> initialRawStyle [ - super initialRawStyle. - self isTopMenu ifTrue: [ ^ self ]. - self parentMenu ifNil: [ ^ self ]. - (self parentMenu items anySatisfy: [ :mi | mi hasIcon ]) ifFalse: [ ^ self ]. - self button rightLabelAlignment: 30 - -] - { #category : 'initialization' } ToGeneralButtonMenuItem >> initialize [ @@ -64,6 +54,17 @@ ToGeneralButtonMenuItem >> initialize [ self layout: self defaultLayout ] +{ #category : 'skin' } +ToGeneralButtonMenuItem >> installRawStyle [ + + super installRawStyle. + self isTopMenu ifTrue: [ ^ self ]. + self parentMenu ifNil: [ ^ self ]. + (self parentMenu items anySatisfy: [ :mi | mi hasIcon ]) ifFalse: [ + ^ self ]. + self button rightLabelAlignment: 25 +] + { #category : 't - clickable - click behavior' } ToGeneralButtonMenuItem >> whenClickedDo: aBlock [ "Inform that the widget has been clicked." diff --git a/src/Toplo-Widget-Menu/ToMenu.class.st b/src/Toplo-Widget-Menu/ToMenu.class.st index 31a8db850..660464595 100644 --- a/src/Toplo-Widget-Menu/ToMenu.class.st +++ b/src/Toplo-Widget-Menu/ToMenu.class.st @@ -44,16 +44,6 @@ ToMenu >> includes: anElement [ ^ super includes: anElement ] -{ #category : 'skin' } -ToMenu >> initialRawStyle [ - - super initialRawStyle. - 'initialRawStyle' traceCr. - self isSubmenu ifFalse: [ ^ self ]. - self parentMenu items do: [ :mi | - (mi isKindOf: ToMenuItem) ifTrue: [ mi filler width: 15] ] -] - { #category : 'initialization' } ToMenu >> initialize [ @@ -76,9 +66,12 @@ ToMenu >> installRawStyle [ super installRawStyle. self isSubmenu ifFalse: [ ^ self ]. + self parentMenu items do: [ :mi | + (mi isKindOf: ToMenuItem) ifTrue: [ mi filler width: 15] ]. self rightHandSide addChild: (ToLabel new text: '...'; - yourself) + yourself). + ] { #category : 'testing' } diff --git a/src/Toplo-Widget-Menu/ToMenuItem.class.st b/src/Toplo-Widget-Menu/ToMenuItem.class.st index fcae0bb67..c67e0a44b 100644 --- a/src/Toplo-Widget-Menu/ToMenuItem.class.st +++ b/src/Toplo-Widget-Menu/ToMenuItem.class.st @@ -37,6 +37,8 @@ ToMenuItem >> initialize [ self withStamp: #'menu-item'. filler := self newFiller. rightHandSide := self newRightHandSide. + filler withoutSkin. + rightHandSide withoutSkin. self button addChild: filler. self button addChild: rightHandSide ] diff --git a/src/Toplo-Widget-Menu/ToMenuItemElement.class.st b/src/Toplo-Widget-Menu/ToMenuItemElement.class.st index 94ee8b8a8..f061a8447 100644 --- a/src/Toplo-Widget-Menu/ToMenuItemElement.class.st +++ b/src/Toplo-Widget-Menu/ToMenuItemElement.class.st @@ -12,7 +12,9 @@ Class { { #category : 'adding-removing' } ToMenuItemElement >> addedInMenu: aMenu [ - self parentMenu: aMenu + self parentMenu: aMenu. + aMenu requestLayout. + aMenu requestSkin ] { #category : 'testing' } diff --git a/src/Toplo-Widget-Menu/ToMenuWindow.class.st b/src/Toplo-Widget-Menu/ToMenuWindow.class.st index c97127097..31b3472fd 100644 --- a/src/Toplo-Widget-Menu/ToMenuWindow.class.st +++ b/src/Toplo-Widget-Menu/ToMenuWindow.class.st @@ -81,7 +81,9 @@ ToMenuWindow >> popupEvent: anEvent [ Error signal: 'Can''t popup a menu if the element is not attached to a space' ]. self items ifEmpty: [ ^ self ]. + self requestSkin. self items do: [ :it | - self root addChild: it ]. + self root addChild: it. + it requestSkin ]. super popupEvent: anEvent ] diff --git a/src/Toplo-Widget-Pane/ToDivider.class.st b/src/Toplo-Widget-Pane/ToDivider.class.st index 799bb5566..23ad45621 100644 --- a/src/Toplo-Widget-Pane/ToDivider.class.st +++ b/src/Toplo-Widget-Pane/ToDivider.class.st @@ -129,6 +129,7 @@ ToDivider >> installRawStyle [ self geometry: self defaultGeometry. self margin: self defaultMargins. self padding: self defaultPadding + ] { #category : 'testing' } @@ -305,7 +306,8 @@ ToDivider >> thickness [ { #category : 'accessing' } ToDivider >> thickness: aNumber [ - thickness := aNumber + thickness := aNumber. + self requestSkin ] { #category : 'accessing' } diff --git a/src/Toplo/BlElement.extension.st b/src/Toplo/BlElement.extension.st index ba1ad9076..3f324f264 100644 --- a/src/Toplo/BlElement.extension.st +++ b/src/Toplo/BlElement.extension.st @@ -133,12 +133,22 @@ BlElement >> holder [ ^ self constraints infinite holder ] +{ #category : '*Toplo' } +BlElement >> ifNotWithNullSkinDo: aBlock [ + + (self userData at: #localDefaultSkin ifAbsent: [ ]) ifNotNil: [ :s | + s isNullSkin ifTrue: [ ^ self ] ]. + aBlock value +] + { #category : '*Toplo' } BlElement >> initialRawStyle [ ] { #category : '*Toplo' } BlElement >> installRawStyle [ + + self requestSkin ] { #category : '*Toplo' } @@ -289,9 +299,10 @@ BlElement >> requestDefaultSkin: aSkin [ { #category : '*Toplo' } BlElement >> requestSkin [ - self skinInstaller ifNotNil: [ ^ self ]. - self skinInstaller: ToSkinInstaller new. - self spaceDo: [ :space | space elementWithSkinInstaller: self ] + self ifNotWithNullSkinDo: [ + self skinInstaller ifNotNil: [ ^ self ]. + self skinInstaller: ToSkinInstaller new. + self spaceDo: [ :space | space elementWithSkinInstaller: self ] ] ] { #category : '*Toplo' } diff --git a/src/Toplo/BlSpace.extension.st b/src/Toplo/BlSpace.extension.st index 643868cb4..049adec74 100644 --- a/src/Toplo/BlSpace.extension.st +++ b/src/Toplo/BlSpace.extension.st @@ -14,21 +14,21 @@ BlSpace >> elementWithSkinInstaller: anElement [ ] { #category : '*Toplo' } -BlSpace >> elementWithUnappliedStates: anElement [ +BlSpace >> elementsWithSkinInstaller [ - self elementsWithUnappliedStates add: anElement + ^ self userData at: #elementsWithSkinInstaller ifAbsentPut: [ IdentitySet new ] ] { #category : '*Toplo' } -BlSpace >> elementsWithSkinInstaller [ +BlSpace >> elementsWithUnappliedStates [ - ^ self userData at: #elementsWithSkinInstaller ifAbsentPut: [ IdentitySet new ] + ^ self userData at: #elementsWithUnappliedStates ifAbsentPut: [ #() ] ] { #category : '*Toplo' } -BlSpace >> elementsWithUnappliedStates [ +BlSpace >> elementsWithUnappliedStates: anArray [ - ^ self userData at: #elementsWithUnappliedStates ifAbsentPut: [ IdentitySet new ] + ^ self userData at: #elementsWithUnappliedStates put: anArray ] { #category : '*Toplo' } @@ -66,6 +66,14 @@ BlSpace >> isSkinStatePhaseInstalled [ ^ self installedSkinStatePhase notNil ] +{ #category : '*Toplo' } +BlSpace >> requestSkinApplicationFor: anElement [ + + self elementsWithUnappliedStates: + ((self elementsWithUnappliedStates copyWithout: anElement) + copyWith: anElement) +] + { #category : '*Toplo' } BlSpace >> resetElementsWithSkinInstaller [ @@ -75,7 +83,8 @@ BlSpace >> resetElementsWithSkinInstaller [ { #category : '*Toplo' } BlSpace >> resetElementsWithUnappliedStates [ - ^ self userData at: #elementsWithUnappliedStates put: IdentitySet new + "self elementsWithUnappliedStates do: [ :e | e traceCr ]." + self userData at: #elementsWithUnappliedStates put: #() ] { #category : '*Toplo' } @@ -87,22 +96,22 @@ BlSpace >> rootSkinInstalled [ { #category : '*Toplo' } BlSpace >> startSkinInstallerPhase [ - | layoutPhase | + | phaseAfter | self isSkinInstallerPhaseInstalled ifTrue: [ ^ self ]. " The skin phase must be inserted before the layout phase (that must be present) " - layoutPhase := self frame detectPhase: [ :f | f class = BlSpaceFrameLayoutPhase ]. - self frame addPhase: ToSpaceSkinInstallerPhase new before: layoutPhase + phaseAfter := self frame detectPhase: [ :f | f class = BlSpaceFrameLayoutPhase ]. + self frame addPhase: ToSpaceSkinInstallerPhase new before: phaseAfter ] { #category : '*Toplo' } BlSpace >> startSkinStatePhase [ - | layoutPhase | + | phaseAfter | self isSkinStatePhaseInstalled ifTrue: [ ^ self ]. " The skin phase must be inserted before the layout phase (that must be present) " - layoutPhase := self frame detectPhase: [ :f | f class = BlSpaceFrameLayoutPhase ]. - self frame addPhase: ToSpaceSkinStatePhase new before: layoutPhase + phaseAfter := self frame detectPhase: [ :f | f class = BlSpaceFrameLayoutPhase ]. + self frame addPhase: ToSpaceSkinStatePhase new before: phaseAfter ] { #category : '*Toplo' } diff --git a/src/Toplo/TToElementWithLabeledIcon.trait.st b/src/Toplo/TToElementWithLabeledIcon.trait.st index 9c14e925a..66ee40949 100644 --- a/src/Toplo/TToElementWithLabeledIcon.trait.st +++ b/src/Toplo/TToElementWithLabeledIcon.trait.st @@ -225,7 +225,8 @@ TToElementWithLabeledIcon >> labeledIcon [ { #category : 't - element with labeled icon - accessing' } TToElementWithLabeledIcon >> rightLabelAlignment: anInteger [ - self labeledIcon rightLabelAlignment: anInteger + self labeledIcon rightLabelAlignment: anInteger. + self requestSkin ] { #category : 't - element with labeled icon - accessing' } diff --git a/src/Toplo/ToAnchoredWindow.class.st b/src/Toplo/ToAnchoredWindow.class.st index 19673928e..91261dd3c 100644 --- a/src/Toplo/ToAnchoredWindow.class.st +++ b/src/Toplo/ToAnchoredWindow.class.st @@ -26,7 +26,7 @@ ToAnchoredWindow >> applySizeHookFromEvent: anEvent [ ToAnchoredWindow >> checkBeforePopupEvent: anEvent [ self applyPositionHookFromEvent: anEvent. - self applySizeHookFromEvent: anEvent. + self applySizeHookFromEvent: anEvent ] { #category : 'api - displaying' } @@ -66,6 +66,7 @@ ToAnchoredWindow >> dispatchOpenedEvent: anEvent [ sourceEvent: anEvent; yourself. self dispatchEvent: event. + self requestSkin. self element ifNotNil: [ :w | w dispatchEvent: event copy ] ] @@ -111,21 +112,17 @@ ToAnchoredWindow >> popupEvent: anEvent [ " I have to set the position here " self element ifNil: [ - Error signal: - 'Can''t popup an anchored window without associate element' ]. + Error signal: 'Can''t popup an anchored window without associate element' ]. self element isAttachedToSceneGraph ifFalse: [ - Error signal: - 'Can''t popup an anchored window if the element is not attached to a space' ]. - self applyPositionHookFromEvent: anEvent. - self applySizeHookFromEvent: anEvent. - self hasParent ifTrue: [ ^ self ]. + Error signal: 'Can''t popup an anchored window if the element is not attached to a space' ]. + self visibility: BlVisibility hidden. self element space root addChild: self. - self dispatchOpenedEvent: anEvent. - popupTimestamp := DateAndTime now. - "I need to finalize my position as soon as my layout is up-to-date" + self checkBeforePopupEvent: anEvent. self whenLayoutedDoOnce: [ - self element isAttachedToSceneGraph ifTrue: [ - self checkBeforePopupEvent: anEvent ] ] + " I need to finalize my position as soon as my layout is up-to-date " + self visibility: BlVisibility visible. + self dispatchOpenedEvent: anEvent. + popupTimestamp := DateAndTime now ] ] { #category : 'accessing' } diff --git a/src/Toplo/ToLabeledIcon.class.st b/src/Toplo/ToLabeledIcon.class.st index 1996240f6..c12f09d2b 100644 --- a/src/Toplo/ToLabeledIcon.class.st +++ b/src/Toplo/ToLabeledIcon.class.st @@ -95,6 +95,7 @@ ToLabeledIcon >> icon: anElement [ icon := anElement. anElement ifNil: [ ^ self ]. self iconHolder addChild: anElement. + self requestSkin ] @@ -153,6 +154,8 @@ ToLabeledIcon >> initialize [ self class initializeSlots: self. super initialize. + self withoutSkin. + filler := ToElement new size: 0 @ 0; id: #filler; @@ -161,12 +164,18 @@ ToLabeledIcon >> initialize [ yourself. iconHolder := ToElement new fitContent; + id: #iconHolder; layout: BlFrameLayout new; yourself. labelHolder := ToElement new fitContent; + id: #labelHolder; layout: BlFrameLayout new; yourself. + iconHolder withoutSkin. + filler withoutSkin. + labelHolder withoutSkin. + self addChild: iconHolder. self addChild: filler. self addChild: labelHolder. @@ -202,7 +211,8 @@ ToLabeledIcon >> interspace: aPoint [ self filler constraints minWidth: size x; minHeight: size y. - self filler requestLayout + self filler requestLayout. + self requestSkin ] { #category : 'testing' } @@ -236,7 +246,8 @@ ToLabeledIcon >> label: anElement [ self label ifNotNil: [ :s | s removeFromParent]. label := anElement. anElement ifNil: [ ^ self ]. - self labelHolder addChild: anElement + self labelHolder addChild: anElement. + self requestSkin ] { #category : 'configurating' } @@ -266,5 +277,6 @@ ToLabeledIcon >> layoutStrategy [ { #category : 'accessing' } ToLabeledIcon >> rightLabelAlignment: anInteger [ - self iconHolderWidth: anInteger - self interspace x + self iconHolderWidth: anInteger. + self requestSkin ] diff --git a/src/Toplo/ToNullSkin.class.st b/src/Toplo/ToNullSkin.class.st index 2afecf0bf..ea02664fd 100644 --- a/src/Toplo/ToNullSkin.class.st +++ b/src/Toplo/ToNullSkin.class.st @@ -6,6 +6,18 @@ Class { #tag : 'Core-Skin' } +{ #category : 'event dispatch' } +ToNullSkin >> dispatchSkinChangedEventTo: anObject [ + + +] + +{ #category : 'event dispatch' } +ToNullSkin >> dispatchSkinRequestedEventTo: anObject [ + + +] + { #category : 'api - accessing' } ToNullSkin >> eventsToHandle [ diff --git a/src/Toplo/ToSkin.class.st b/src/Toplo/ToSkin.class.st index 3f3682548..75100f568 100644 --- a/src/Toplo/ToSkin.class.st +++ b/src/Toplo/ToSkin.class.st @@ -39,6 +39,18 @@ ToSkin >> disabledLookEvent: anEvent [ ] +{ #category : 'event dispatch' } +ToSkin >> dispatchSkinChangedEventTo: anObject [ + + anObject dispatchSkinChangedEvent +] + +{ #category : 'event dispatch' } +ToSkin >> dispatchSkinRequestedEventTo: anObject [ + + anObject dispatchSkinRequestedEvent +] + { #category : 'event handling' } ToSkin >> dragStartedLookEvent: anEvent [ diff --git a/src/Toplo/ToSkinInstaller.class.st b/src/Toplo/ToSkinInstaller.class.st index 7d972fdc4..18afd2d67 100644 --- a/src/Toplo/ToSkinInstaller.class.st +++ b/src/Toplo/ToSkinInstaller.class.st @@ -12,9 +12,9 @@ ToSkinInstaller >> applyOn: anElement [ anElement skinInstaller: nil. " is there an already installed skin" anElement installedSkin ifNotNil: [ :s | - ^ anElement dispatchSkinRequestedEvent ]. + ^ s dispatchSkinRequestedEventTo: anElement ]. anElement defaultSkin ifNotNil: [ :found | " add the skin as an element event handler" anElement addEventHandler: found. " event to update the state engine accordingly (add install or initial state)" - anElement dispatchSkinChangedEvent ] + found dispatchSkinChangedEventTo: anElement ] ] diff --git a/src/Toplo/ToSpaceSkinInstallerPhaseCheckerEventHandler.class.st b/src/Toplo/ToSpaceSkinInstallerPhaseCheckerEventHandler.class.st index e07d4c33a..5a858c7d5 100644 --- a/src/Toplo/ToSpaceSkinInstallerPhaseCheckerEventHandler.class.st +++ b/src/Toplo/ToSpaceSkinInstallerPhaseCheckerEventHandler.class.st @@ -8,13 +8,14 @@ Class { { #category : 'event handling' } ToSpaceSkinInstallerPhaseCheckerEventHandler >> elementAddedToSceneGraphEvent: anEvent [ - " add the skin installer and the skin state phases if necessary " - anEvent currentTarget space startSkinInstallerPhase. - anEvent currentTarget space startSkinStatePhase. - anEvent currentTarget space root requestSkin. - " one shot verification - i'm removed for the element event dispatcher " + anEvent currentTarget space isSkinInstallerPhaseInstalled ifFalse: [ + anEvent currentTarget space startSkinInstallerPhase. + anEvent currentTarget space startSkinStatePhase. + + anEvent currentTarget space root requestSkin ]. + " one shot verification done - i'm removed for the element event dispatcher " anEvent currentTarget removeEventHandler: self ]