Skip to content

Commit

Permalink
ToListElement: clean-up NodeManager and NodeHolder hierarchies
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Sep 28, 2024
1 parent c9f9f61 commit 5bc8cf4
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 74 deletions.
2 changes: 1 addition & 1 deletion src/Toplo-Examples/ToBarNodeExamplePart.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ ToBarNodeExamplePart >> label: aLabel [
{ #category : #initialization }
ToBarNodeExamplePart >> removeFromBar [

self holder barElement dataAccessor removeAt: self holder position
self holder listElement dataAccessor removeAt: self holder position
]
6 changes: 2 additions & 4 deletions src/Toplo-Widget-List/ToAbstractListNodeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ Class {
{ #category : #'instance creation' }
ToAbstractListNodeManager >> buildNode: aNode inHolder: aNodeHolder [

aNodeHolder node: aNode.
nodeBuilder cull: aNode cull: aNodeHolder dataItem cull: aNodeHolder
]

{ #category : #initialization }
ToAbstractListNodeManager >> constraintNode: aNode [

aNode constraintsDo: [ :c |
c horizontal matchParent.
c vertical fitContent ]
self subclassResponsibility
]

{ #category : #initialization }
Expand Down Expand Up @@ -78,6 +75,7 @@ ToAbstractListNodeManager >> newNodeForHolder: aNodeHolder [
node := nodeFactory cull: aNodeHolder.
infiniteConstraints := node constraints infinite.
infiniteConstraints holder: aNodeHolder.
aNodeHolder node: node.
^ node
]

Expand Down
21 changes: 0 additions & 21 deletions src/Toplo-Widget-List/ToBarNodeHolder.class.st

This file was deleted.

4 changes: 2 additions & 2 deletions src/Toplo-Widget-List/ToBarNodeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ToBarNodeManager >> constraintNode: aNode [

| bar |
aNode isFake ifTrue: [ ^ self ].
bar := aNode holder barElement.
bar := aNode holder listElement.
aNode constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ].
Expand All @@ -49,7 +49,7 @@ ToBarNodeManager >> constraintNode: aNode [
{ #category : #initialization }
ToBarNodeManager >> defaultHolderClass [

^ ToBarNodeHolder
^ ToListNodeHolder
]

{ #category : #initialization }
Expand Down
6 changes: 4 additions & 2 deletions src/Toplo-Widget-List/ToInnerBarElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,10 @@ ToInnerBarElement >> onItemRangeChanged: aPositionStart itemCount: anItemCount [
self nodesDo: [ :node |
(node holder position
between: aPositionStart
and: aPositionStart + anItemCount - 1) ifTrue: [
node holder changeDataItem: (dataSource at: node holder position) ] ].
and: aPositionStart + anItemCount - 1) ifTrue: [ | dataItem |
node holder unbindDataItem.
dataItem := dataSource at: node holder position.
node holder setDataItemAndBuildNode: dataItem ] ].
self requestLayout
]

Expand Down
30 changes: 14 additions & 16 deletions src/Toplo-Widget-List/ToListNodeHolder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,9 @@ Class {
{ #category : #accessing }
ToListNodeHolder >> bindDataItem: aDataItem [

| nodeManager |
nodeManager := self nodeManager.
self dataItem: aDataItem.
self node: (nodeManager newNodeForHolder: self).
self build
]

{ #category : #accessing }
ToListNodeHolder >> build [
self node: (self nodeManager newNodeForHolder: self).
self setDataItemAndBuildNode: aDataItem.

| nodeManager |
nodeManager := self nodeManager.
nodeManager buildNode: self node inHolder: self.
nodeManager constraintNode: self node.
self node enabled: self isEnabled.
self isHidden ifTrue: [ self node height: 0 ]
]

{ #category : #accessing }
Expand Down Expand Up @@ -159,11 +146,22 @@ ToListNodeHolder >> selectionModel [
^ self listElement selectionModel
]

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

| nodeManager |
self dataItem: aDataItem.
nodeManager := self nodeManager.
nodeManager buildNode: self node inHolder: self.
nodeManager constraintNode: self node.
self node enabled: self isEnabled.
self isHidden ifTrue: [ self node height: 0 ]
]

{ #category : #accessing }
ToListNodeHolder >> unbindDataItem [

| nodeManager |

nodeManager := self listElement nodeManager.
nodeManager unbuildNode: self node
]
8 changes: 8 additions & 0 deletions src/Toplo-Widget-List/ToListNodeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Class {
#category : #'Toplo-Widget-List-Core-ListElement'
}

{ #category : #initialization }
ToListNodeManager >> constraintNode: aNode [

aNode constraintsDo: [ :c |
c horizontal matchParent.
c vertical fitContent ]
]

{ #category : #initialization }
ToListNodeManager >> defaultHolderClass [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ToSegmentedElementEventHandler >> eventsToHandle [
{ #category : #'event handling' }
ToSegmentedElementEventHandler >> layoutDirectionChangedEvent: anEvent [

anEvent currentTarget barElement leftToRight: anEvent currentTarget isLeftToRight
anEvent currentTarget listElement leftToRight: anEvent currentTarget isLeftToRight
]

{ #category : #'event handling' }
Expand Down
4 changes: 2 additions & 2 deletions src/Toplo-Widget-Segmented/ToSegmentedNodeHolder.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToSegmentedNodeHolder,
#superclass : #ToBarNodeHolder,
#superclass : #ToListNodeHolder,
#category : #'Toplo-Widget-Segmented'
}

Expand Down Expand Up @@ -32,7 +32,7 @@ ToSegmentedNodeHolder >> isChecked [
{ #category : #accessing }
ToSegmentedNodeHolder >> segmentedBarElement [

^ self barElement
^ self listElement
]

{ #category : #'t - checkable - accessing' }
Expand Down
5 changes: 3 additions & 2 deletions src/Toplo-Widget-Select/ToMultiSelectBarNodeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ ToMultiSelectBarNodeManager >> buildNode: aNode inHolder: aNodeHolder [
| multiSelectDataItem |
aNodeHolder node: aNode.
multiSelectDataItem := aNodeHolder dataItem.
" an holder can have a composite data item if not wraping and not scrolling "
multiSelectDataItem isComposite
ifFalse: [
| index data |
index := multiSelectDataItem index.
data := index isZero
ifTrue: [ self fakeDataItem ]
ifTrue: [ fakeDataItem ]
ifFalse: [ aNodeHolder dataAccessor at: index ].
nodeBuilder value: aNode value: data value: aNodeHolder.
aNode addEventHandlerOn: ToInnerElementRemovedEvent do: [ :event |
Expand Down Expand Up @@ -57,7 +58,7 @@ ToMultiSelectBarNodeManager >> defaultCompositeNodeBuilder [
{ #category : #initialization }
ToMultiSelectBarNodeManager >> defaultHolderClass [

^ ToMultiSelectBarNodeHolder
^ ToMultiSelectNodeHolder
]

{ #category : #initialization }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToMultiSelectListNodeHolder,
#superclass : #ToSelectListNodeHolder,
#superclass : #ToListNodeHolder,
#category : #'Toplo-Widget-Select-List'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Class {
#name : #ToMultiSelectBarNodeHolder,
#superclass : #ToBarNodeHolder,
#name : #ToMultiSelectNodeHolder,
#superclass : #ToListNodeHolder,
#category : #'Toplo-Widget-Select-Multi'
}

{ #category : #accessing }
ToMultiSelectBarNodeHolder >> dataAccessor [
ToMultiSelectNodeHolder >> dataAccessor [

^ self sieve originalData
]

{ #category : #removing }
ToMultiSelectBarNodeHolder >> removeNodeFromBar [
ToMultiSelectNodeHolder >> removeNodeFromBar [
"
since a select node is created by selecting and item in the list element,
removing the node is by deselecting the corresponding list item in the select list "
Expand All @@ -20,25 +20,25 @@ ToMultiSelectBarNodeHolder >> removeNodeFromBar [
]

{ #category : #accessing }
ToMultiSelectBarNodeHolder >> selectElement [
ToMultiSelectNodeHolder >> selectElement [

^ self barElement selectElement
^ self listElement selectElement
]

{ #category : #accessing }
ToMultiSelectBarNodeHolder >> selecter [
ToMultiSelectNodeHolder >> selecter [

^ self selectElement selecter
]

{ #category : #accessing }
ToMultiSelectBarNodeHolder >> selectionModel [
ToMultiSelectNodeHolder >> selectionModel [

^ self selectElement selectionModel
]

{ #category : #accessing }
ToMultiSelectBarNodeHolder >> sieve [
ToMultiSelectNodeHolder >> sieve [

^ self barElement sieve
^ self listElement sieve
]
11 changes: 0 additions & 11 deletions src/Toplo-Widget-Select/ToSelectListNodeHolder.class.st

This file was deleted.

2 changes: 1 addition & 1 deletion src/Toplo-Widget-Select/ToSelectListWindowManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ToSelectListWindowManager >> newListElement [
{ #category : #'api - hooks' }
ToSelectListWindowManager >> nodeHolderClass [

^ ToSelectListNodeHolder
^ ToListNodeHolder
]

{ #category : #'api - hooks' }
Expand Down

0 comments on commit 5bc8cf4

Please sign in to comment.