Skip to content

Commit

Permalink
Improved ToItemList
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Dec 18, 2024
1 parent 6016060 commit 4bbc3af
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 67 deletions.
2 changes: 1 addition & 1 deletion src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3869,7 +3869,7 @@ ToSandBox class >> example_menuBar2 [
bar addItem: menu ].

frame pane addChild: bar.
frame openInSpace
frame openInSpace
]

{ #category : #menu }
Expand Down
47 changes: 18 additions & 29 deletions src/Toplo-Widget-List/ToAbstractBarNodeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ ToAbstractBarNodeManager >> constraintFakeNode: aNode [
ifTrue: [
aNode constraintsDo: [ :c |
c horizontal exact: 0.
c vertical fitContent.
c vertical exact: 0.
c flow vertical alignCenter.
c linear vertical alignCenter ] ]
ifFalse: [
aNode constraintsDo: [ :c |
c vertical exact: 0.
c horizontal fitContent.
c horizontal exact: 0.
c flow horizontal alignCenter.
c linear horizontal alignCenter ] ].
]
Expand All @@ -37,38 +37,27 @@ ToAbstractBarNodeManager >> constraintNode: aNode [
bar isVertical
ifTrue: [
bar isHMatchParent
ifTrue: [
aNode constraintsDo: [ :c |
c horizontal matchParent.
c vertical fitContent ] ]
ifFalse: [
aNode constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ] ] ]
ifFalse: [
ifTrue: [ aNode hMatchParent ]
ifFalse: [ aNode hFitContent ].
aNode vFitContent ]
ifFalse: [
bar isVMatchParent
ifTrue: [
aNode constraintsDo: [ :c |
c vertical matchParent.
c horizontal fitContent ] ]
ifFalse: [
aNode constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ] ]] ]
ifTrue: [
aNode constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ] ].

ifTrue: [ aNode vMatchParent ]
ifFalse: [ aNode vFitContent ].
aNode hFitContent ] ]
ifTrue: [ aNode fitContent ].

aNode constraintsDo: [ :c |
c linear vertical alignCenter.
c flow vertical alignCenter ].


bar nodeWrapping ifTrue: [ ^ self ].
bar nodeScrolling ifTrue: [ ^ self ].
bar nodeAutoDistribution ifTrue: [
bar isHorizontal
ifTrue: [ aNode hMatchParent ]
ifFalse: [ aNode vMatchParent ] ]
bar nodeAutoDistribution ifFalse: [ ^ self ].

bar isHorizontal
ifTrue: [ aNode hMatchParent ]
ifFalse: [ aNode vMatchParent ]
]

{ #category : #initialization }
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Widget-List/ToItemNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ToItemNode >> item: aMenuItem [
aMenuItem ifNil: [ ^ self ].
aMenuItem parent = self ifTrue: [ ^ self ].
aMenuItem removeFromParent.
self addChild: aMenuItem
self addChild: aMenuItem at: 1
]

{ #category : #skin }
Expand Down
24 changes: 0 additions & 24 deletions src/Toplo-Widget-List/ToItemNodeManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,6 @@ ToItemNodeManager >> buildNode: aNode [
aNode item: holder dataItem
]

{ #category : #initialization }
ToItemNodeManager >> constraintFakeNode: aNode [

| bar |
bar := aNode holder listElement.
aNode visibility: BlVisibility hidden.
aNode constraintsDo: [ :c |
c horizontal exact: 0.
c vertical exact: 0 ]
]

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

| bar |
super constraintNode: aNode.
bar := aNode holder listElement.
bar nodeScrolling ifTrue: [ ^ self ].
bar nodeAutoDistribution ifTrue: [
aNode item constraintsDo: [ :c |
c horizontal matchParent.
c vertical matchParent ] ]
]

{ #category : #initialization }
ToItemNodeManager >> defaultFakeDataItem [

Expand Down
1 change: 0 additions & 1 deletion src/Toplo-Widget-List/ToListElementEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ ToListElementEventHandler >> boundsHasChangedDuringScrollingEvent: anEvent [
{ #category : #'event handling' }
ToListElementEventHandler >> clickEvent: anEvent [

anEvent isConsumed ifTrue: [ ^ self ].
anEvent ifPrimary: [ self primaryClickEvent: anEvent ]
secondary: [ self secondaryClickEvent: anEvent ]
middle: [ self middleClickEvent: anEvent ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ ToListNodeSelectionEventHandler >> clickEvent: anEvent [
listElement isEnabled ifFalse: [ ^ self ].
mode := listElement primarySelectionMode.
mode selectOnPressed ifTrue: [ ^ self ].
self notifyClickOnNodeFromEvent: anEvent.
"anEvent consume"
self notifyClickOnNodeFromEvent: anEvent
]

{ #category : #'mouse handlers' }
Expand Down
1 change: 1 addition & 0 deletions src/Toplo-Widget-Menu/ToMenuBar.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ ToMenuBar >> itemContaining: anElement [
self = anElement ifTrue: [ ^ self ].
^ (self itemList itemContaining: anElement) ifNotNil: [ :found |
| item |
found = anElement ifTrue: [ ^ self ].
item := found item.
item isMenuBar
ifTrue: [ item itemContaining: anElement ]
Expand Down
11 changes: 3 additions & 8 deletions src/Toplo-Widget-Menu/ToMenuItemElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,9 @@ ToMenuItemElement >> constraintMenuNode: aNode [
" Sent to let any menu item to adapt its resizer/layout constraints before the node is added in the menu list. Notice that I am sent before the node adding + the selections shift is actually finished. Thus, this place is not adequate for changing one of the list selections (use #addedInMenu for that) "

aNode holder listElement isHorizontal
ifTrue: [
self constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ] ]
ifFalse: [
self constraintsDo: [ :c |
c horizontal matchParent.
c vertical fitContent ] ]
ifTrue: [ self hFitContent ]
ifFalse: [ self hMatchParent ].
self vFitContent
]

{ #category : #initialization }
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Widget-Segmented/ToSegmentedNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ToSegmentedNode >> checkableElement: aCheckable [
{ #category : #'t - list node' }
ToSegmentedNode >> clickEventHandlerClasses [

^ { }
^ { ToSegmentedNodeSelectionEventHandler }
]

{ #category : #skin }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Class {
#name : #ToSegmentedNodeSelectionEventHandler,
#superclass : #BlCustomEventHandler,
#category : #'Toplo-Widget-Segmented-Node'
}

{ #category : #'event handling' }
ToSegmentedNodeSelectionEventHandler >> clickEvent: anEvent [

anEvent
ifPrimary: [ self primaryClickEvent: anEvent ]
secondary: [ ]
middle: [ ]
other: [ ]
]

{ #category : #'api - accessing' }
ToSegmentedNodeSelectionEventHandler >> eventsToHandle [
^ { BlPrimaryClickEvent }
]

{ #category : #'event handling' }
ToSegmentedNodeSelectionEventHandler >> primaryClickEvent: anEvent [

anEvent currentTarget item dispatchEvent: anEvent.
]
16 changes: 16 additions & 0 deletions src/Toplo-Widget-Segmented/ToSegmentedNodeSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Class {
#category : #'Toplo-Widget-Segmented-Node'
}

{ #category : #'event handling' }
ToSegmentedNodeSkin >> hoveredSkinEvent: anEvent [

super hoveredSkinEvent: anEvent.
anEvent elementDo: [ :e |
e mouseCursor: Cursor webLink ]
]

{ #category : #'event handling' }
ToSegmentedNodeSkin >> installSkinEvent: anEvent [

Expand All @@ -15,3 +23,11 @@ ToSegmentedNodeSkin >> installSkinEvent: anEvent [
vertical: (e valueOfTokenNamed: #'segmented-node-padding-V')).
e border: (BlBorder empty) ]
]

{ #category : #'event handling' }
ToSegmentedNodeSkin >> leavedSkinEvent: anEvent [

super leavedSkinEvent: anEvent.
anEvent elementDo: [ :e |
e mouseCursor: Cursor normal ]
]

0 comments on commit 4bbc3af

Please sign in to comment.