diff --git a/src/Toplo-Examples/ToSandBox.class.st b/src/Toplo-Examples/ToSandBox.class.st index f75f227e..5dddc8e2 100644 --- a/src/Toplo-Examples/ToSandBox.class.st +++ b/src/Toplo-Examples/ToSandBox.class.st @@ -3924,12 +3924,12 @@ ToSandBox class >> example_menuBar0 [ menu addItem: (ToMenuItem new labelText: 'item 1'). menu addItem: ToSeparatorMenuItem new. sub := ToMenuItem new labelText: 'item 2'. - sub disable. menu addItem: sub. + sub disable. bar addItem: menu. menu := ToMenuItem new labelText: 'Menu 1'. bar addItem: menu. - menu disable. + menu disabled: true. bar openInSpace ] diff --git a/src/Toplo-Widget-List-Tests/ToBarNodeHolderForTest.class.st b/src/Toplo-Widget-List-Tests/ToBarNodeHolderForTest.class.st new file mode 100644 index 00000000..ec0bd2d1 --- /dev/null +++ b/src/Toplo-Widget-List-Tests/ToBarNodeHolderForTest.class.st @@ -0,0 +1,5 @@ +Class { + #name : #ToBarNodeHolderForTest, + #superclass : #ToBarNodeHolder, + #category : #'Toplo-Widget-List-Tests-ItemList' +} diff --git a/src/Toplo-Widget-List-Tests/ToItemElementForTest.class.st b/src/Toplo-Widget-List-Tests/ToItemElementForTest.class.st new file mode 100644 index 00000000..bfac9451 --- /dev/null +++ b/src/Toplo-Widget-List-Tests/ToItemElementForTest.class.st @@ -0,0 +1,25 @@ +Class { + #name : #ToItemElementForTest, + #superclass : #ToElement, + #traits : 'TToItem', + #classTraits : 'TToItem classTrait', + #instVars : [ + 'label' + ], + #category : #'Toplo-Widget-List-Tests-ItemList' +} + +{ #category : #initialization } +ToItemElementForTest >> initialize [ + + super initialize. + label := ToLabel new. + self addChild: label. + self fitContent +] + +{ #category : #accessing } +ToItemElementForTest >> text: aText [ + + label text: aText +] diff --git a/src/Toplo-Widget-List-Tests/ToItemListElementForTest.class.st b/src/Toplo-Widget-List-Tests/ToItemListElementForTest.class.st new file mode 100644 index 00000000..a1d8cdda --- /dev/null +++ b/src/Toplo-Widget-List-Tests/ToItemListElementForTest.class.st @@ -0,0 +1,11 @@ +Class { + #name : #ToItemListElementForTest, + #superclass : #ToItemListElement, + #category : #'Toplo-Widget-List-Tests-ItemList' +} + +{ #category : #initialization } +ToItemListElementForTest >> defaultNodeManagerClass [ + + ^ ToItemNodeManagerForTest +] diff --git a/src/Toplo-Widget-List-Tests/ToItemListElementTest.class.st b/src/Toplo-Widget-List-Tests/ToItemListElementTest.class.st new file mode 100644 index 00000000..dac368e3 --- /dev/null +++ b/src/Toplo-Widget-List-Tests/ToItemListElementTest.class.st @@ -0,0 +1,67 @@ +" +A ToItemListElementTest is a test class for testing the behavior of ToItemListElement +" +Class { + #name : #ToItemListElementTest, + #superclass : #ToParameterizedHostTest, + #instVars : [ + 'l' + ], + #category : #'Toplo-Widget-List-Tests-ItemList' +} + +{ #category : #running } +ToItemListElementTest >> setUp [ + + super setUp. + l := ToItemListElementForTest new. + l vMatchParent. + space root addChild: l +] + +{ #category : #tests } +ToItemListElementTest >> test [ + + | n | + self assert: l nodes size equals: l dataAccessor size. + self assert: (l nodeManager isKindOf: ToItemNodeManagerForTest). + l dataAccessor addAll: + ((1 to: 10) collect: [ :i | ToItemElementForTest new text: i asString ]). + n := l nodes first. + self assert: (n isKindOf: ToItemNodeForTest). + self assert: (n holder isKindOf: ToBarNodeHolderForTest). + self assert: (n holder dataItem isKindOf: ToItemElementForTest) + +] + +{ #category : #tests } +ToItemListElementTest >> testDisableItemAfterAdding [ + + | n item | + self skip. + self assert: l nodes size equals: 0. + item := ToItemElementForTest new text: 'A'. + l dataAccessor add: item. + item disable. + n := l nodes first. + self waitTestingSpaces. + self assert: n holder dataItem identicalTo: item. + self assert: item isDisabled. + self assert: n isDisabled +] + +{ #category : #tests } +ToItemListElementTest >> testDisableItemBeforeAdding [ + + | n item | + self skip. + self assert: l nodes size equals: 0. + item := ToItemElementForTest new text: 'A'. + item disable. + l dataAccessor add: item. + n := l nodes first. + self waitTestingSpaces. + self assert: n holder dataItem identicalTo: item. + self assert: item isDisabled. + self assert: n isDisabled +] diff --git a/src/Toplo-Widget-List-Tests/ToItemNodeForTest.class.st b/src/Toplo-Widget-List-Tests/ToItemNodeForTest.class.st new file mode 100644 index 00000000..3c083ca6 --- /dev/null +++ b/src/Toplo-Widget-List-Tests/ToItemNodeForTest.class.st @@ -0,0 +1,5 @@ +Class { + #name : #ToItemNodeForTest, + #superclass : #ToItemNode, + #category : #'Toplo-Widget-List-Tests-ItemList' +} diff --git a/src/Toplo-Widget-List-Tests/ToItemNodeManagerForTest.class.st b/src/Toplo-Widget-List-Tests/ToItemNodeManagerForTest.class.st new file mode 100644 index 00000000..2faeaea4 --- /dev/null +++ b/src/Toplo-Widget-List-Tests/ToItemNodeManagerForTest.class.st @@ -0,0 +1,23 @@ +Class { + #name : #ToItemNodeManagerForTest, + #superclass : #ToItemNodeManager, + #category : #'Toplo-Widget-List-Tests-ItemList' +} + +{ #category : #initialization } +ToItemNodeManagerForTest >> defaultFakeDataItem [ + + ^ ToItemElementForTest new text: 'X' +] + +{ #category : #'instance creation' } +ToItemNodeManagerForTest >> newHolder [ + + ^ ToBarNodeHolderForTest new +] + +{ #category : #'instance creation' } +ToItemNodeManagerForTest >> newNodeForHolder: aNodeHolder [ + + ^ ToItemNodeForTest new +] diff --git a/src/Toplo-Widget-List/ToGenericBarNodeManager.class.st b/src/Toplo-Widget-List/ToGenericBarNodeManager.class.st index bad58339..5cd2f440 100644 --- a/src/Toplo-Widget-List/ToGenericBarNodeManager.class.st +++ b/src/Toplo-Widget-List/ToGenericBarNodeManager.class.st @@ -37,7 +37,7 @@ ToGenericBarNodeManager >> defaultNodeFactory [ { #category : #initialization } ToGenericBarNodeManager >> defaultNodeUnbuilder [ - ^ [ :node :dataItem :holder | ] + ^ [ :node :dataItem :holder | node removeChildren ] ] { #category : #initialization } diff --git a/src/Toplo-Widget-List/ToItemBarNodeHolder.class.st b/src/Toplo-Widget-List/ToItemBarNodeHolder.class.st index 03cef0d9..afe6d61c 100644 --- a/src/Toplo-Widget-List/ToItemBarNodeHolder.class.st +++ b/src/Toplo-Widget-List/ToItemBarNodeHolder.class.st @@ -7,7 +7,12 @@ Class { { #category : #accessing } ToItemBarNodeHolder >> initializeNode [ + self dataItem presetDataDo: [ :pd | - pd setupItem: dataItem ]. - super initializeNode + pd setupItem: self dataItem. + self disabled: self dataItem isDisabled. + self isHidden ifTrue: [ self node height: 0 ]. + ^ self ]. + super initializeNode + ] diff --git a/src/Toplo-Widget-List/ToSubSelecter.class.st b/src/Toplo-Widget-List/ToSubSelecter.class.st index 387022e2..ff4a1d8b 100644 --- a/src/Toplo-Widget-List/ToSubSelecter.class.st +++ b/src/Toplo-Widget-List/ToSubSelecter.class.st @@ -7,6 +7,12 @@ Class { #category : #'Toplo-Widget-List-Selection-Selecter' } +{ #category : #initialization } +ToSubSelecter >> defaultCommandApplicationStrategy [ + + ^ ToImmediateCommandApplicationStrategy new +] + { #category : #'api - hooks' } ToSubSelecter >> onInstalledIn: anEventTarget [ diff --git a/src/Toplo/BlElement.extension.st b/src/Toplo/BlElement.extension.st index 3aaee439..64ac714c 100644 --- a/src/Toplo/BlElement.extension.st +++ b/src/Toplo/BlElement.extension.st @@ -466,6 +466,15 @@ BlElement >> parentChainReverseDo: aBlock [ self parentChain reverseDo: aBlock ] +{ #category : #'*Toplo' } +BlElement >> presetDataDo: aValuable [ + + " do nothing at this level. + It redefined for an element that is used as a list data item. + This is the case for a menu or a segmented button as examples + ( see `TToItem` users )" +] + { #category : #'*Toplo' } BlElement >> preventSelectionSkinEvents [