From b75ff298b21101327182f2618e2c5b6b10739f62 Mon Sep 17 00:00:00 2001 From: plantec Date: Mon, 30 Sep 2024 12:09:27 +0200 Subject: [PATCH] ToMultiSelectElement: more consistent fake node implementation --- src/Toplo-Examples/ToSandBox.class.st | 1 + .../ToBarNodeManager.class.st | 7 --- .../ToInnerBarElement.class.st | 2 +- .../ToSegmentedNodeManager.class.st | 2 +- ....st => ToAbstractMultiSelectItem.class.st} | 12 ++--- .../ToMultiSelectBarNodeManager.class.st | 10 +++- .../ToMultiSelectCompositeItem.class.st | 2 +- .../ToMultiSelectFakeItem.class.st | 50 +++++++++++++++++++ .../ToMultiSelectItem.class.st | 16 +++--- 9 files changed, 77 insertions(+), 25 deletions(-) rename src/Toplo-Widget-Select/{ToAbstractMultiSelectDataItem.class.st => ToAbstractMultiSelectItem.class.st} (53%) create mode 100644 src/Toplo-Widget-Select/ToMultiSelectFakeItem.class.st diff --git a/src/Toplo-Examples/ToSandBox.class.st b/src/Toplo-Examples/ToSandBox.class.st index e4e80c70..b04e9780 100644 --- a/src/Toplo-Examples/ToSandBox.class.st +++ b/src/Toplo-Examples/ToSandBox.class.st @@ -1729,6 +1729,7 @@ ToSandBox class >> example_SelectAntDesignIconMultiFiltrable [ ('Select icons' asRopedText foreground: Color red). select inputTextField requestFocus. + select inspect. select openInSpace ] diff --git a/src/Toplo-Widget-List/ToBarNodeManager.class.st b/src/Toplo-Widget-List/ToBarNodeManager.class.st index 79414ac7..5050f202 100644 --- a/src/Toplo-Widget-List/ToBarNodeManager.class.st +++ b/src/Toplo-Widget-List/ToBarNodeManager.class.st @@ -7,12 +7,6 @@ Class { #category : #'Toplo-Widget-List-Core-BarElement' } -{ #category : #'instance creation' } -ToBarNodeManager >> buildFakeNode: aFakeNode inHolder: anHolder [ - - nodeBuilder cull: aFakeNode cull: fakeDataItem cull: anHolder -] - { #category : #initialization } ToBarNodeManager >> constraintFakeNode: aNode [ @@ -37,7 +31,6 @@ ToBarNodeManager >> constraintFakeNode: aNode [ ToBarNodeManager >> constraintNode: aNode [ | bar | - aNode isFake ifTrue: [ ^ self ]. bar := aNode holder listElement. aNode constraintsDo: [ :c | c horizontal fitContent. diff --git a/src/Toplo-Widget-List/ToInnerBarElement.class.st b/src/Toplo-Widget-List/ToInnerBarElement.class.st index 8d0e6393..e1ca056c 100644 --- a/src/Toplo-Widget-List/ToInnerBarElement.class.st +++ b/src/Toplo-Widget-List/ToInnerBarElement.class.st @@ -166,7 +166,7 @@ ToInnerBarElement >> installFakeNode [ " add the fake node (to keep a constant minimum size ). Pay attention to add the fake node ** before ** the fake node building " self scrollableElement addFakeNode: fakeNode. - self nodeManager buildFakeNode: fakeNode inHolder: holder. + self nodeManager buildNode: fakeNode inHolder: holder. diff --git a/src/Toplo-Widget-Segmented/ToSegmentedNodeManager.class.st b/src/Toplo-Widget-Segmented/ToSegmentedNodeManager.class.st index f3da0b32..19df271d 100644 --- a/src/Toplo-Widget-Segmented/ToSegmentedNodeManager.class.st +++ b/src/Toplo-Widget-Segmented/ToSegmentedNodeManager.class.st @@ -33,7 +33,7 @@ ToSegmentedNodeManager >> defaultNodeFactory [ { #category : #initialization } ToSegmentedNodeManager >> unbuildNode: aNode [ - aNode isFake ifFalse: [ aNode checkableElement unregisterFromGroup ]. + aNode checkableElement unregisterFromGroup. aNode checkableElement removeFromParent. super unbuildNode: aNode ] diff --git a/src/Toplo-Widget-Select/ToAbstractMultiSelectDataItem.class.st b/src/Toplo-Widget-Select/ToAbstractMultiSelectItem.class.st similarity index 53% rename from src/Toplo-Widget-Select/ToAbstractMultiSelectDataItem.class.st rename to src/Toplo-Widget-Select/ToAbstractMultiSelectItem.class.st index 397c7047..fc2a7a93 100644 --- a/src/Toplo-Widget-Select/ToAbstractMultiSelectDataItem.class.st +++ b/src/Toplo-Widget-Select/ToAbstractMultiSelectItem.class.st @@ -1,35 +1,35 @@ Class { - #name : #ToAbstractMultiSelectDataItem, + #name : #ToAbstractMultiSelectItem, #superclass : #Object, #category : #'Toplo-Widget-Select-Multi' } { #category : #'node building' } -ToAbstractMultiSelectDataItem >> buildNode: aNode inHolder: aNodeHolder withManager: aNodeManager [ +ToAbstractMultiSelectItem >> buildNode: aNode inHolder: aNodeHolder withManager: aNodeManager [ self subclassResponsibility ] { #category : #accessing } -ToAbstractMultiSelectDataItem >> indexes [ +ToAbstractMultiSelectItem >> indexes [ ^ self subclassResponsibility ] { #category : #testing } -ToAbstractMultiSelectDataItem >> isComposite [ +ToAbstractMultiSelectItem >> isComposite [ ^ false ] { #category : #accessing } -ToAbstractMultiSelectDataItem >> items [ +ToAbstractMultiSelectItem >> items [ ^ self subclassResponsibility ] { #category : #accessing } -ToAbstractMultiSelectDataItem >> nodesCount [ +ToAbstractMultiSelectItem >> nodesCount [ ^ self subclassResponsibility ] diff --git a/src/Toplo-Widget-Select/ToMultiSelectBarNodeManager.class.st b/src/Toplo-Widget-Select/ToMultiSelectBarNodeManager.class.st index f25f098e..4eb65177 100644 --- a/src/Toplo-Widget-Select/ToMultiSelectBarNodeManager.class.st +++ b/src/Toplo-Widget-Select/ToMultiSelectBarNodeManager.class.st @@ -41,7 +41,7 @@ ToMultiSelectBarNodeManager >> defaultCompositeNodeBuilder [ { #category : #initialization } ToMultiSelectBarNodeManager >> defaultFakeDataItem [ - ^ ToMultiSelectItem index: 0 + ^ ToMultiSelectFakeItem new ] { #category : #initialization } @@ -69,6 +69,14 @@ ToMultiSelectBarNodeManager >> defaultNodeFactory [ ^ [ :holder | ToMultiSelectBarNode new ] ] +{ #category : #accessing } +ToMultiSelectBarNodeManager >> fakeDataItem: aDataItem [ + + fakeDataItem := ToMultiSelectFakeItem new + dataItem: aDataItem; + yourself +] + { #category : #initialization } ToMultiSelectBarNodeManager >> initialize [ diff --git a/src/Toplo-Widget-Select/ToMultiSelectCompositeItem.class.st b/src/Toplo-Widget-Select/ToMultiSelectCompositeItem.class.st index 8fa1c29d..5b012f71 100644 --- a/src/Toplo-Widget-Select/ToMultiSelectCompositeItem.class.st +++ b/src/Toplo-Widget-Select/ToMultiSelectCompositeItem.class.st @@ -1,6 +1,6 @@ Class { #name : #ToMultiSelectCompositeItem, - #superclass : #ToAbstractMultiSelectDataItem, + #superclass : #ToAbstractMultiSelectItem, #instVars : [ 'indexes', 'content', diff --git a/src/Toplo-Widget-Select/ToMultiSelectFakeItem.class.st b/src/Toplo-Widget-Select/ToMultiSelectFakeItem.class.st new file mode 100644 index 00000000..ad7e1c63 --- /dev/null +++ b/src/Toplo-Widget-Select/ToMultiSelectFakeItem.class.st @@ -0,0 +1,50 @@ +Class { + #name : #ToMultiSelectFakeItem, + #superclass : #ToAbstractMultiSelectItem, + #instVars : [ + 'dataItem' + ], + #category : #'Toplo-Widget-Select-Multi' +} + +{ #category : #'instance creation' } +ToMultiSelectFakeItem class >> index: anIndex [ + + ^ self new index: anIndex; yourself +] + +{ #category : #'node building' } +ToMultiSelectFakeItem >> buildNode: aNode inHolder: aNodeHolder withManager: aNodeManager [ + + aNodeManager nodeBuilder value: aNode value: dataItem value: aNodeHolder +] + +{ #category : #accessing } +ToMultiSelectFakeItem >> dataItem [ + + ^ dataItem +] + +{ #category : #accessing } +ToMultiSelectFakeItem >> dataItem: aDataItem [ + + dataItem := aDataItem +] + +{ #category : #accessing } +ToMultiSelectFakeItem >> indexes [ + + ^ { } +] + +{ #category : #accessing } +ToMultiSelectFakeItem >> items [ + + ^ { } +] + +{ #category : #accessing } +ToMultiSelectFakeItem >> nodesCount [ + + ^ 0 +] diff --git a/src/Toplo-Widget-Select/ToMultiSelectItem.class.st b/src/Toplo-Widget-Select/ToMultiSelectItem.class.st index a6245b24..9aebe57c 100644 --- a/src/Toplo-Widget-Select/ToMultiSelectItem.class.st +++ b/src/Toplo-Widget-Select/ToMultiSelectItem.class.st @@ -1,6 +1,6 @@ Class { #name : #ToMultiSelectItem, - #superclass : #ToAbstractMultiSelectDataItem, + #superclass : #ToAbstractMultiSelectItem, #instVars : [ 'index', 'pickOrder' @@ -25,43 +25,43 @@ ToMultiSelectItem >> buildNode: aNode inHolder: aNodeHolder withManager: aNodeMa aNode removeFromBar ] ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } ToMultiSelectItem >> index [ ^ index ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } ToMultiSelectItem >> index: anInteger [ index := anInteger ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } ToMultiSelectItem >> indexes [ ^ Array with: index ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } ToMultiSelectItem >> items [ ^ { self } ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } ToMultiSelectItem >> nodesCount [ ^ 1 ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } ToMultiSelectItem >> pickOrder [ ^ pickOrder ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } ToMultiSelectItem >> pickOrder: anInteger [ pickOrder := anInteger