Skip to content

Commit

Permalink
Merge pull request #216 from pharo-graphics/ToCommandApplierEnh
Browse files Browse the repository at this point in the history
To command applier enh
  • Loading branch information
plantec authored Oct 22, 2024
2 parents 641e04f + 32ee2c0 commit 7ef3274
Show file tree
Hide file tree
Showing 27 changed files with 100 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ToListSelectionHistoryExampleEventHandler >> listSelectionCommandAppliedEvent: a

currentTarget := aCommandAppliedEvent currentTarget.
" check that the command is applied on the primary selection model "
aCommandAppliedEvent selectionModel = currentTarget selectionModel
aCommandAppliedEvent selectionModel == currentTarget selectionModel
ifFalse: [ ^ self ].
aCommandAppliedEvent command applyWithOperator: self.
currentTarget := nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ToListSelectionTraceExampleEventHandler >> listSelectionCommandAppliedEvent: aCo
currentTarget := aCommandAppliedEvent currentTarget.

" check that the command is applied on the primary selection model "
aCommandAppliedEvent selectionModel = currentTarget selectionModel
aCommandAppliedEvent selectionModel == currentTarget selectionModel
ifFalse: [ ^ self ].

traceSelectionModel := currentTarget userData at: #traceSelectionModel.
Expand Down
24 changes: 10 additions & 14 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,6 @@ ToSandBox class >> example_ListWithEditableAndContextMenu [

| l |
l := self listWithEditableAndContextMenu.
l inspect.
l openInInnerWindow
]

Expand Down Expand Up @@ -3867,6 +3866,16 @@ ToSandBox class >> example_selectWithEditingMultiSelectionWithAllClassNames [
| select innerWindow space |
select := self selectWithEditingMultiSelection.
select filtrable: true.
select placeholderText: ('Choose a class' asRopedText
foreground: Color lightGray;
yourself).
select popupListElement placeholderBuilder: [ :placeholder :e |
placeholder layout alignCenter.
placeholder addChild:
(ToAttributedLabel text: ('No Data' asRopedText
fontSize: 24;
foreground: Color lightGray;
yourself)) ].

innerWindow := ToInnerWindow new.
select popupWindowManager anchorRoot: innerWindow root.
Expand Down Expand Up @@ -5432,19 +5441,6 @@ ToSandBox class >> listWithEditableAndContextMenu [
disabledMode changeSelectionOptionWith: option.

unselectableMode := l unselectableSelectionMode.
l
addEventHandlerOn: unselectableMode selectionChangedEventClass
do: [ :event |
| target |
target := event currentTarget.
event selectionOption
updateSelectionIn: target
withSelectionModel: target selecter selectionModel.
target selecter deselectIndexes: event touchedIndexes.
target secondarySelecter deselectAll.
event touchedIntervals do: [ :int |
target dataSource notifyItemsChanged: int ] ].

option := ToListSelectionOption new.
option grouped: false.
option beneath: false.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ ToSelecterEventTargetStub >> itemCount [
^ 100
]

{ #category : #'event firing' }
ToSelecterEventTargetStub >> notifyPrimarySelectionDirty [
]

{ #category : #accessing }
ToSelecterEventTargetStub >> scrollIndex [

Expand Down Expand Up @@ -51,3 +47,7 @@ ToSelecterEventTargetStub >> selectionModel: aSelectionModel [
on: self;
yourself
]

{ #category : #'event firing' }
ToSelecterEventTargetStub >> updateAllSelections [
]
4 changes: 2 additions & 2 deletions src/Toplo-Widget-List/TToListElementWithDecoration.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ TToListElementWithDecoration >> withDecoration: aDecorationClass [
]

{ #category : #'t - infinite accessing' }
TToListElementWithDecoration >> withRowNumbers [
TToListElementWithDecoration >> withRowNumbers [

self next withRowNumbers.
self notifyPrimarySelectionDirty.
self updateAllSelections.
self requestLayout
]
35 changes: 20 additions & 15 deletions src/Toplo-Widget-List/ToAbstractListElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -344,39 +344,34 @@ ToAbstractListElement >> nodeUnbuilder: aValuable [
nodeManager nodeUnbuilder: aValuable
]

{ #category : #'event firing' }
{ #category : #notifications }
ToAbstractListElement >> notifyDataSourceChanged [


self dataSource notifyChanged
]

{ #category : #'event firing' }
{ #category : #notifications }
ToAbstractListElement >> notifyDataSourceItemChanged: aDataSourceEvent [

| request |
request := ToListDataSourceItemChangeRequestEvent new
dataSourceEvent: aDataSourceEvent;
requestedAction: [ self dispatchEvent: aDataSourceEvent ];
yourself.
self dispatchAuthorisationRequest: request
self dispatchEvent: aDataSourceEvent
]

{ #category : #'event firing' }
{ #category : #notifications }
ToAbstractListElement >> notifyDataSourceItemsFiltered: aDataSourceEvent [


self dispatchEvent: aDataSourceEvent
]

{ #category : #'event firing' }
{ #category : #notifications }
ToAbstractListElement >> notifyPrimarySelectionDirty [

self dispatchEvent: (ToListPrimarySelectionDirtyEvent new
selectionOption: self selectionOption;
selectionModel: self selectionModel;
itemCount: self itemCount;
yourself)
self
deprecated: 'use #updateAllSelections instead'
transformWith:
'`@rcvr notifyPrimarySelectionDirty' -> '`@rcvr updateAllSelections'.
self updateAllSelections
]

{ #category : #'private - commands' }
Expand Down Expand Up @@ -540,6 +535,16 @@ ToAbstractListElement >> unselectableSelectionModel [
^ self selectionModel unselectableSelectionModel
]

{ #category : #'selection updating' }
ToAbstractListElement >> updateAllSelections [

self selectionModes do: [ :mode |
mode selectionOption ifNotNil: [ :option |
option
updateSelectionIn: self
withSelectionModel: mode selectionModel ] ]
]

{ #category : #accessing }
ToAbstractListElement >> withoutNodeBuilder [

Expand Down

This file was deleted.

12 changes: 8 additions & 4 deletions src/Toplo-Widget-List/ToCommandApplier.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToCommandApplier,
#superclass : #BlCustomEventHandler,
#superclass : #Object,
#instVars : [
'element'
],
Expand All @@ -19,8 +19,12 @@ ToCommandApplier >> element: anElement [
element := anElement
]

{ #category : #'api - accessing' }
ToCommandApplier >> eventsToHandle [
{ #category : #'api - hooks' }
ToCommandApplier >> onInstalledIn: aSelecter [

]

{ #category : #'api - hooks' }
ToCommandApplier >> onUninstalledIn: aSelecter [

^ { }
]

This file was deleted.

2 changes: 1 addition & 1 deletion src/Toplo-Widget-List/ToListElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ToListElement >> defaultNodeManagerClass [
{ #category : #'private - invalidation' }
ToListElement >> invalidateItemDecorations [

self notifyPrimarySelectionDirty
self updateAllSelections
]

{ #category : #skin }
Expand Down
8 changes: 4 additions & 4 deletions src/Toplo-Widget-List/ToListElementEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,25 @@ ToListElementEventHandler >> listDataSourceItemsRemovedEvent: anEvent [

| target |
target := anEvent currentTarget.
" update the secondary selection because it can be on the removed nodes "
" update the secondary selection because it can be on the removed nodes "
target secondarySelecter
deselectIndex: anEvent position
to: anEvent position + anEvent itemCount - 1.
"Have to update directly the selection model here (not from the selecter).
If done by the selecter, the model update is postponed, the consequence
can be that the skin can be updated whereas the selection model
is not up-to-date leading to a baddly SelectedSkinEvent sent"

target selectionModel withAllSubModelsDo: [ :sm |
sm
deselectIndex: anEvent position
to: anEvent position + anEvent itemCount - 1 ].
" since the delection model as been updated, one have to force the renewal
of selection elements "
target notifyPrimarySelectionDirty.
target selecter
shiftSelection: anEvent itemCount negated
from: anEvent position
from: anEvent position.

target updateAllSelections
]

{ #category : #'infinite event handling' }
Expand Down
8 changes: 4 additions & 4 deletions src/Toplo-Widget-List/ToListElementSieve.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ ToListElementSieve >> isInstalled [
^ originalData notNil
]

{ #category : #'event firing' }
ToListElementSieve >> notifyPrimarySelectionDirty [
]

{ #category : #'api - hooks' }
ToListElementSieve >> onInstalledIn: aListElement [
" install the sieve on the listElement "
Expand Down Expand Up @@ -161,6 +157,10 @@ ToListElementSieve >> selectionModel [
^ selectionModel
]

{ #category : #'selection updating' }
ToListElementSieve >> updateAllSelections [
]

{ #category : #private }
ToListElementSieve >> updateCurrentData [

Expand Down
8 changes: 8 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,14 @@ Class {
#category : #'Toplo-Widget-List-Selection-Mode'
}

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

^ ToListBasicAdditionalSelectionElementEventHandler new
selectionChangedEventClass: self selectionChangedEventClass;
yourself
]

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ ToListInnerContainerEventHandler >> boundsHasChangedDuringScrollingEvent: anEven
]

{ #category : #'infinite event handling' }
ToListInnerContainerEventHandler >> elementAddedToSceneGraphEvent: anEvent [
ToListInnerContainerEventHandler >> elementAddedToSceneGraphEvent: anEvent [

"anEvent currentTarget listElement notifyPrimarySelectionDirty"
"anEvent currentTarget listElement updateAllSelections"
]

{ #category : #'infinite event handling' }
ToListInnerContainerEventHandler >> elementPositionChangedEvent: anEvent [

anEvent currentTarget listElement notifyPrimarySelectionDirty
anEvent currentTarget listElement updateAllSelections
]

{ #category : #'infinite event handling' }
Expand Down
52 changes: 0 additions & 52 deletions src/Toplo-Widget-List/ToListPrimarySelectionDirtyEvent.class.st

This file was deleted.

Loading

0 comments on commit 7ef3274

Please sign in to comment.