Skip to content

Commit

Permalink
make embedded selection work
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Jan 26, 2025
1 parent 48f9dd7 commit abbba45
Show file tree
Hide file tree
Showing 23 changed files with 234 additions and 69 deletions.
19 changes: 19 additions & 0 deletions src/Toplo-Examples/ToListEmbeddedNodeExampleSkin.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class {
#name : #ToListEmbeddedNodeExampleSkin,
#superclass : #ToListNodeSkin,
#category : #'Toplo-Examples-Parts'
}

{ #category : #'event handling' }
ToListEmbeddedNodeExampleSkin >> deselectedSkinEvent: anEvent [

super deselectedSkinEvent: anEvent.
anEvent elementDo: [ :e | e background: Color transparent ]
]

{ #category : #'event handling' }
ToListEmbeddedNodeExampleSkin >> selectedSkinEvent: anEvent [

super selectedSkinEvent: anEvent.
anEvent elementDo: [ :e | e background: Color lightGreen ]
]
18 changes: 16 additions & 2 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,20 @@ ToSandBox class >> example_ListWithAllClassesNone [
l openInSpace
]

{ #category : #list }
ToSandBox class >> example_ListWithAllClassesWithEmbeddedSelection [

| l |
l := ToListElement new.
l nodeBuilder: [ :node :dataItem :holder |
node defaultRawSkin: ToListEmbeddedNodeExampleSkin new.
node addChild: (ToLabel text: dataItem) withNullSkin ].
l selectionOption withEmbeddedRepresentation.
l dataAccessor addAll:
(Smalltalk globals allClasses collect: [ :cls | cls name ]).
l openInSpace
]

{ #category : #list }
ToSandBox class >> example_ListWithAllMethods [

Expand Down Expand Up @@ -6952,7 +6966,7 @@ ToSandBox class >> listWithEditableAndContextMenu [
whenClickedDo: [ :event |
target hiddenSelecter deselectAll ];
yourself).
target primarySelectionMode selectionOption isMasked
target selectionOption isMasked
ifTrue: [
menu addItem: (ToMenuItem new
labelText: 'stop primary selection masking';
Expand All @@ -6965,7 +6979,7 @@ ToSandBox class >> listWithEditableAndContextMenu [
whenClickedDo: [ :event |
target selectionOption masked: true ];
yourself) ].
target primarySelectionMode selectionOption
target selectionOption
isAnimated
ifTrue: [
menu addItem: (ToMenuItem new
Expand Down
2 changes: 2 additions & 0 deletions src/Toplo-Widget-Album/ToLabelSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Class {
ToLabelSkin >> deselectedSkinEvent: anEvent [

super deselectedSkinEvent: anEvent.
anEvent selectionMode isPrimary ifFalse: [ ^ self ].
anEvent enabledElementDo: [ :e |
| to |
to := e valueOfTokenNamed: #'color-text'.
Expand Down Expand Up @@ -48,6 +49,7 @@ ToLabelSkin >> installSkinEvent: anEvent [
ToLabelSkin >> selectedSkinEvent: anEvent [

super selectedSkinEvent: anEvent.
anEvent selectionMode isPrimary ifFalse: [ ^ self ].
anEvent enabledElementDo: [ :e |
| tokname to |
tokname := anEvent focused
Expand Down
40 changes: 36 additions & 4 deletions src/Toplo-Widget-List/ToAbstractListSelectionMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ToAbstractListSelectionMode >> changeSelectionOptionWith: aSelectionOption [
selectionOption onUninstalledIn: listElement ].
selectionOption := aSelectionOption.
selectionOption ifNil: [ ^ self ].
selectionOption selectionMode: self.
selectionOption onInstalledIn: listElement
]

Expand Down Expand Up @@ -67,10 +68,16 @@ ToAbstractListSelectionMode >> initialize [
enabled := true
]

{ #category : #testing }
ToAbstractListSelectionMode >> isContextMenu [

^ false
]

{ #category : #testing }
ToAbstractListSelectionMode >> isDisabled [

^ self enabled not
^ false
]

{ #category : #testing }
Expand All @@ -79,12 +86,36 @@ ToAbstractListSelectionMode >> isEnabled [
^ self enabled
]

{ #category : #testing }
ToAbstractListSelectionMode >> isHidden [

^ false
]

{ #category : #testing }
ToAbstractListSelectionMode >> isMultipleSelection [

^ true
]

{ #category : #testing }
ToAbstractListSelectionMode >> isPrimary [

^ false
]

{ #category : #testing }
ToAbstractListSelectionMode >> isSecondary [

^ false
]

{ #category : #testing }
ToAbstractListSelectionMode >> isUnselectable [

^ false
]

{ #category : #accessing }
ToAbstractListSelectionMode >> itemCount [

Expand Down Expand Up @@ -145,18 +176,19 @@ ToAbstractListSelectionMode >> onInstalledIn: aListElement [
selecter onInstalledIn: aListElement.
selectionOption := self defaultSelectionOption.
selectionOption ifNil: [ ^ self ].
selectionOption selectionMode: self.
selectionOption onInstalledIn: aListElement
]

{ #category : #'api - hooks' }
ToAbstractListSelectionMode >> onUninstalledIn: aListElement [

selectionOption ifNotNil: [ selectionOption onUninstalledIn: aListElement ].
selectionOption ifNotNil: [
selectionOption onUninstalledIn: aListElement ].
selecter onUninstalledIn: aListElement.
aListElement removeSelectionMode: self.
selectionOption := nil.
selecter := nil.

selecter := nil
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Widget-List/ToBarNodeSkin.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToBarNodeSkin,
#superclass : #ToRawSkin,
#superclass : #ToBasicNodeSkin,
#category : #'Toplo-Widget-List-Node'
}

Expand Down
19 changes: 19 additions & 0 deletions src/Toplo-Widget-List/ToBasicNodeSkin.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Class {
#name : #ToBasicNodeSkin,
#superclass : #ToRawSkin,
#category : #'Toplo-Widget-List-Node'
}

{ #category : #'event handling' }
ToBasicNodeSkin >> deselectedSkinEvent: anEvent [

super deselectedSkinEvent: anEvent.
anEvent elementDo: [ :e | ]
]

{ #category : #'event handling' }
ToBasicNodeSkin >> selectedSkinEvent: anEvent [

super selectedSkinEvent: anEvent.
anEvent elementDo: [ :e | ]
]
6 changes: 6 additions & 0 deletions src/Toplo-Widget-List/ToListContextMenuSelectionMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ ToListContextMenuSelectionMode >> defaultSelectionOption [
elementFactory: [ ToListContextMenuSelectionElement new ]
]

{ #category : #testing }
ToListContextMenuSelectionMode >> isContextMenu [

^ true
]

{ #category : #'instance creation' }
ToListContextMenuSelectionMode >> newSelecter [

Expand Down
6 changes: 6 additions & 0 deletions src/Toplo-Widget-List/ToListDisabledSelectionMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Class {
#category : #'Toplo-Widget-List-Selection-Mode'
}

{ #category : #testing }
ToListDisabledSelectionMode >> isDisabled [

^ true
]

{ #category : #'instance creation' }
ToListDisabledSelectionMode >> newSelectionChangedEventHandler [

Expand Down
6 changes: 6 additions & 0 deletions src/Toplo-Widget-List/ToListHiddenSelectionMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Class {
#category : #'Toplo-Widget-List-Selection-Mode'
}

{ #category : #testing }
ToListHiddenSelectionMode >> isHidden [

^ true
]

{ #category : #'instance creation' }
ToListHiddenSelectionMode >> selectionChangedEventClass [

Expand Down
3 changes: 1 addition & 2 deletions src/Toplo-Widget-List/ToListNodeSkin.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToListNodeSkin,
#superclass : #ToRawSkin,
#superclass : #ToBasicNodeSkin,
#category : #'Toplo-Widget-List-Node'
}

Expand All @@ -9,7 +9,6 @@ ToListNodeSkin >> installSkinEvent: anEvent [

super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
e outskirts: BlOutskirts inside.
e padding: (BlInsets
horizontal: (e valueOfTokenNamed: #'list-node-padding-H')
vertical: (e valueOfTokenNamed: #'list-node-padding-V')) ]
Expand Down
6 changes: 6 additions & 0 deletions src/Toplo-Widget-List/ToListPrimarySelectionMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ ToListPrimarySelectionMode >> isMultipleSelection [
^ multiple
]

{ #category : #testing }
ToListPrimarySelectionMode >> isPrimary [

^ true
]

{ #category : #testing }
ToListPrimarySelectionMode >> maxSelectedIndexesForSelectionPreserving [

Expand Down
6 changes: 6 additions & 0 deletions src/Toplo-Widget-List/ToListSecondarySelectionMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ ToListSecondarySelectionMode >> isMultipleSelection [
^ multiple
]

{ #category : #testing }
ToListSecondarySelectionMode >> isSecondary [

^ true
]

{ #category : #accessing }
ToListSecondarySelectionMode >> multiple: aBoolean [

Expand Down
23 changes: 21 additions & 2 deletions src/Toplo-Widget-List/ToListSelectionOption.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Class {
#name : #ToListSelectionOption,
#superclass : #Object,
#instVars : [
'selectionMode',
'masked',
'triggerSelectionState',
'representationOption',
Expand Down Expand Up @@ -32,9 +33,9 @@ ToListSelectionOption >> beneath: aBoolean [
]

{ #category : #'private - selection updating' }
ToListSelectionOption >> currentSelectionGroupsFrom: aListElement withSelectionModel: aSelectionModel [
ToListSelectionOption >> currentSelectionRepresentationsFrom: aListElement withSelectionModel: aSelectionModel [

^ representationOption currentSelectionGroupsFrom: aListElement withSelectionModel: aSelectionModel
^ representationOption currentSelectionRepresentationsFrom: aListElement withSelectionModel: aSelectionModel
]

{ #category : #accessing }
Expand Down Expand Up @@ -157,6 +158,18 @@ ToListSelectionOption >> selectionElements [
^ representationOption selectionElements
]

{ #category : #accessing }
ToListSelectionOption >> selectionMode [

^ selectionMode
]

{ #category : #accessing }
ToListSelectionOption >> selectionMode: aListSelectionMode [

selectionMode := aListSelectionMode
]

{ #category : #accessing }
ToListSelectionOption >> triggerSelectionState [

Expand All @@ -174,3 +187,9 @@ ToListSelectionOption >> updateSelectionIn: aListElement withSelectionModel: aSe

representationOption updateSelectionIn: aListElement withSelectionModel: aSelectionModel
]

{ #category : #accessing }
ToListSelectionOption >> withEmbeddedRepresentation [

self representation: ToListSelectionRepresentationOption embedded
]
Loading

0 comments on commit abbba45

Please sign in to comment.