Skip to content

Commit

Permalink
ToSegmentedNodeManager simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Sep 30, 2024
1 parent 6bcfead commit 0af0f42
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
21 changes: 18 additions & 3 deletions src/Toplo-Widget-Segmented/ToSegmentedNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,36 @@ ToSegmentedNode >> autoDistribute: aBoolean [

super autoDistribute: aBoolean.
aBoolean ifTrue: [
self content constraintsDo: [ :c |
self checkableElement constraintsDo: [ :c |
c horizontal matchParent.
c vertical matchParent ] ]
]

{ #category : #accessing }
ToSegmentedNode >> checkableElement [

^ self firstChild
]

{ #category : #accessing }
ToSegmentedNode >> checkableElement: aCheckable [

^ self addChild: aCheckable
]

{ #category : #'t - list node' }
ToSegmentedNode >> clickEventHandlerClasses [

^ { ToSegmentedNodeEventHandler }
]

{ #category : #accessing }
ToSegmentedNode >> content [
ToSegmentedNode >> content [

^ self firstChild
self
deprecated: 'Use #checkableElement instead'
transformWith: '`@rcvr content' -> '`@rcvr checkableElement'.
^ self checkableElement
]

{ #category : #testing }
Expand Down
9 changes: 9 additions & 0 deletions src/Toplo-Widget-Segmented/ToSegmentedNodeHolder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ ToSegmentedNodeHolder >> segmentedBarElement [
^ self listElement
]

{ #category : #accessing }
ToSegmentedNodeHolder >> setDataItemAndBuildNode: aDataItem [

super setDataItemAndBuildNode: aDataItem.
" aDataItem is a checkable element.
It must be registered in the checkable group managed by the segmented bar"
aDataItem registerInGroup: self segmentedBarElement group
]

{ #category : #'t - checkable - accessing' }
ToSegmentedNodeHolder >> updateSelection [

Expand Down
14 changes: 5 additions & 9 deletions src/Toplo-Widget-Segmented/ToSegmentedNodeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ ToSegmentedNodeManager >> defaultHolderClass [
{ #category : #initialization }
ToSegmentedNodeManager >> defaultNodeBuilder [

^ [ :node :contentElement :holder |
node isFake ifFalse: [
contentElement registerInGroup: holder segmentedBarElement group.
contentElement constraints infinite holder: holder.
contentElement constraintsDo: [ :c | c horizontal matchParent ] ].
node addChild: contentElement ]
^ [ :node :checkableElement :holder |
" in a segmented, the dataItem is a checkable element "
node checkableElement: checkableElement ]
]

{ #category : #initialization }
Expand All @@ -36,8 +33,7 @@ ToSegmentedNodeManager >> defaultNodeFactory [
{ #category : #initialization }
ToSegmentedNodeManager >> unbuildNode: aNode [

aNode isFake ifFalse: [
aNode content unregisterFromGroup ].
aNode content removeFromParent.
aNode isFake ifFalse: [ aNode checkableElement unregisterFromGroup ].
aNode checkableElement removeFromParent.
super unbuildNode: aNode
]

0 comments on commit 0af0f42

Please sign in to comment.