Skip to content

Commit

Permalink
working on ToListElement
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Mar 21, 2024
1 parent 711f0bc commit c5e32bc
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 240 deletions.
2 changes: 1 addition & 1 deletion src/Toplo-Examples/ToListElementStresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ ToListElementStresser >> initialize [
self tabsPanel enqueueTask:
(BlTaskAction new action: [
(self tabsPanel tabs at: idx) check ]).
self resizeSpace.
"self resizeSpace."
1 seconds wait ] ] newProcess.


Expand Down
11 changes: 0 additions & 11 deletions src/Toplo-Widget-List-Tests/ToSelectionModelHolderForTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,6 @@ ToSelectionModelHolderForTest >> notifyUnselectableSelectionChanged: anEvent [
self dispatchEvent: anEvent
]

{ #category : #'selection command application' }
ToSelectionModelHolderForTest >> onPrimarySelectionCommandApplied: aCommand [

aCommand selectionChanged ifFalse: [ ^ self ].

self notifyPrimarySelectionChanged:
(ToListPrimarySelectionChangedEvent new
selectionModel: self selectionModel copy;
yourself)
]

{ #category : #accessing }
ToSelectionModelHolderForTest >> operator [

Expand Down
26 changes: 0 additions & 26 deletions src/Toplo-Widget-List/ToAbstractListElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -280,20 +280,6 @@ ToAbstractListElement >> nodeReleaser [
^ self subclassResponsibility
]

{ #category : #'event firing' }
ToAbstractListElement >> notifyClickOnNodeEvent: aClickEvent [

| preNotification node |
node := aClickEvent sourceEvent currentTarget.
preNotification := ToListClickOnNodePreNotificationEvent new
node: node;
sourceEvent: aClickEvent;
yourself.
self dispatchEvent: preNotification.
preNotification sourceEvent ifNil: [ ^ self ].
node dispatchEvent: preNotification sourceEvent
]

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

Expand All @@ -306,18 +292,6 @@ ToAbstractListElement >> notifyDataSourceItemsChanged: aDataSourceEvent [
self dispatchEvent: preNotification sourceEvent
]

{ #category : #'event firing' }
ToAbstractListElement >> notifyPrimarySelectionChanged: aSelectionChangedEvent [

| preNotification |
preNotification := ToListPrimarySelectionChangePreNotificationEvent new
sourceEvent: aSelectionChangedEvent;
yourself.
self dispatchEvent: preNotification.
preNotification sourceEvent ifNil: [ ^ self ].
self dispatchEvent: preNotification sourceEvent
]

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

Expand Down
36 changes: 36 additions & 0 deletions src/Toplo-Widget-List/ToAdditionalSelectionModelOperator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Class {
#name : #ToAdditionalSelectionModelOperator,
#superclass : #ToSelectionModelOperator,
#instVars : [
'eventClass'
],
#category : #'Toplo-Widget-List-Command-Selection'
}

{ #category : #accessing }
ToAdditionalSelectionModelOperator class >> eventClass: anEventClass [

^ self new eventClass: anEventClass
]

{ #category : #accessing }
ToAdditionalSelectionModelOperator >> eventClass [

^ eventClass
]

{ #category : #accessing }
ToAdditionalSelectionModelOperator >> eventClass: anEventClass [

eventClass := anEventClass
]

{ #category : #'private command application' }
ToAdditionalSelectionModelOperator >> notifySelectionChangedAfter: aCommand in: aTarget [

aCommand selectionChanged ifFalse: [ ^ self ].

aTarget dispatchEvent: (self eventClass new
selectionModel: self selectionModel copy;
yourself)
]
15 changes: 0 additions & 15 deletions src/Toplo-Widget-List/ToBasicListElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,3 @@ ToBasicListElement >> nodeReleaser: aValuable [

nodeReleaser := aValuable
]

{ #category : #'selection command application' }
ToBasicListElement >> onPrimarySelectionCommandApplied: aCommand [

aCommand selectionChanged ifFalse: [ ^ self ].

self dispatchEvent: (ToPrimarySelectionCommandAppliedEvent new
command: aCommand;
yourself).

self notifyPrimarySelectionChanged:
(ToListPrimarySelectionChangedEvent new
selectionModel: self selectionModel copy;
yourself)
]
1 change: 0 additions & 1 deletion src/Toplo-Widget-List/ToCommandOperator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ ToCommandOperator >> initialize [
{ #category : #'command operations' }
ToCommandOperator >> listScrollCommand: aCommand in: aTarget [

aTarget scrollToIndex: aCommand index
]

{ #category : #'api - hooks' }
Expand Down
18 changes: 0 additions & 18 deletions src/Toplo-Widget-List/ToDisabledSelectionModelOperator.class.st

This file was deleted.

18 changes: 0 additions & 18 deletions src/Toplo-Widget-List/ToHiddenSelectionModelOperator.class.st

This file was deleted.

98 changes: 13 additions & 85 deletions src/Toplo-Widget-List/ToListElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ ToListElement >> infiniteSharedEvents [
{ #category : #initialization }
ToListElement >> initializeSelectionModel [

unselectableSelecter := self installSelecterForOperator:
ToUnselectableSelectionModelOperator new.
disabledSelecter := self installSelecterForOperator:
ToDisabledSelectionModelOperator new.
hiddenSelecter := self installSelecterForOperator:
ToHiddenSelectionModelOperator new.
unselectableSelecter := self installSelecterForEventClass:
ToListUnselectableSelectionChangedEvent.
disabledSelecter := self installSelecterForEventClass:
ToListDisabledSelectionChangedEvent.
hiddenSelecter := self installSelecterForEventClass:
ToListHiddenSelectionChangedEvent.

self secondarySelectionModel: self newSecondarySelectionModel.
self secondarySelectionMode: self defaultSecondarySelectionMode.
Expand All @@ -96,15 +96,17 @@ ToListElement >> initializeSelectionModel [
]

{ #category : #initialization }
ToListElement >> installSelecterForOperator: aSelectionOperator [
ToListElement >> installSelecterForEventClass: anEventClass [

| newSelectionModel newSelecter |
| newSelectionModel newSelecter operator |
operator := ToAdditionalSelectionModelOperator eventClass:
anEventClass.
newSelectionModel := self newSelectionModel.
newSelectionModel onInstalledIn: self.
newSelecter := ToMultiSelectionModelSelecter new.
aSelectionOperator selectionModel: newSelectionModel.
aSelectionOperator onInstalledIn: self.
newSelecter operator: aSelectionOperator.
operator selectionModel: newSelectionModel.
operator onInstalledIn: self.
newSelecter operator: operator.
newSelecter onInstalledIn: self.

^ newSelecter
Expand All @@ -128,80 +130,6 @@ ToListElement >> newSecondarySelectionModel [
^ ToListSelectionModel new
]

{ #category : #'event firing' }
ToListElement >> notifyDisabledSelectionChanged: aSelectionChangedEvent [

self dispatchEvent: aSelectionChangedEvent
]

{ #category : #'event firing' }
ToListElement >> notifyHiddenSelectionChanged: aSelectionChangedEvent [

self dispatchEvent: aSelectionChangedEvent
]

{ #category : #'event firing' }
ToListElement >> notifySecondarySelectionChanged: aSelectionChangedEvent [

| preNotification |
preNotification := ToListSecondarySelectionChangePreNotificationEvent new
sourceEvent: aSelectionChangedEvent;
yourself.
self dispatchEvent: preNotification.
preNotification sourceEvent ifNil: [ ^ self ].
self dispatchEvent: preNotification sourceEvent
]

{ #category : #'event firing' }
ToListElement >> notifyUnselectableSelectionChanged: aSelectionChangedEvent [

self dispatchEvent: aSelectionChangedEvent
]

{ #category : #'selection command application' }
ToListElement >> onDisabledSelectionCommandApplied: aCommand [

aCommand selectionChanged ifFalse: [ ^ self ].

self notifyDisabledSelectionChanged:
(ToListDisabledSelectionChangedEvent new
selectionModel: self disabledSelectionModel copy;
yourself)
]

{ #category : #'selection command application' }
ToListElement >> onHiddenSelectionCommandApplied: aCommand [

aCommand selectionChanged ifFalse: [ ^ self ].

self notifyHiddenSelectionChanged:
(ToListHiddenSelectionChangedEvent new
selectionModel: self hiddenSelectionModel copy;
yourself)
]

{ #category : #'selection command application' }
ToListElement >> onSecondarySelectionCommandApplied: aCommand [

aCommand selectionChanged ifFalse: [ ^ self ].

self notifySecondarySelectionChanged:
(ToListSecondarySelectionChangedEvent new
selectionModel: self secondarySelectionModel copy;
yourself)
]

{ #category : #'selection command application' }
ToListElement >> onUnselectableSelectionCommandApplied: aCommand [

aCommand selectionChanged ifFalse: [ ^ self ].

self notifyUnselectableSelectionChanged:
(ToListUnselectableSelectionChangedEvent new
selectionModel: self unselectableSelectionModel copy;
yourself)
]

{ #category : #accessing }
ToListElement >> secondarySelecter [

Expand Down
43 changes: 21 additions & 22 deletions src/Toplo-Widget-List/ToListElementEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ ToListElementEventHandler >> listClickOnNodePreNotificationEvent: anEvent [
{ #category : #'list element handling' }
ToListElementEventHandler >> listDisabledSelectionChangedEvent: anEvent [

| target nodesArray |
target := anEvent currentTarget.
target isAttachedToSceneGraph ifFalse: [ ^ self ].
| listElement |
listElement := anEvent currentTarget.
listElement isAttachedToSceneGraph ifFalse: [ ^ self ].

nodesArray := target infinite children asArray.
anEvent selectionModel ifEmpty: [
target dataSource notifyChanged.
listElement dataSource notifyChanged.
^ self ].
anEvent selectionModel selectedIndexesIntervalsDo: [ :interval |
target dataSource notifyItemsChanged: (interval first to: interval last) ]
listElement dataSource notifyItemsChanged:
(interval first to: interval last) ]
]

{ #category : #'list element handling' }
ToListElementEventHandler >> listHiddenSelectionChangedEvent: anEvent [

| listElement nodesArray |
| listElement |
listElement := anEvent currentTarget.
listElement isAttachedToSceneGraph ifFalse: [ ^ self ].
nodesArray := listElement infinite children asArray.

anEvent selectionModel ifEmpty: [
listElement dataSource notifyChanged.
^ self ].
Expand All @@ -56,21 +56,20 @@ ToListElementEventHandler >> listHiddenSelectionChangedEvent: anEvent [
{ #category : #'list element handling' }
ToListElementEventHandler >> listUnselectableSelectionChangedEvent: anEvent [

| target firstPos lastPos |
target := anEvent currentTarget.
target isAttachedToSceneGraph ifFalse: [ ^ self ].
target infinite hasChildren ifFalse: [ ^ self ].
| listElement firstPos lastPos |
listElement := anEvent currentTarget.
listElement isAttachedToSceneGraph ifFalse: [ ^ self ].
listElement infinite hasChildren ifFalse: [ ^ self ].
anEvent selectionModel ifEmpty: [
target dataSource notifyChanged.
listElement dataSource notifyChanged.
^ self ].
firstPos := target infinite firstChild holder position.
lastPos := target infinite lastChild holder position.
(target selectionModel hasUnselectableInInterval:
(firstPos to: lastPos)) ifFalse: [ ^ self ].
firstPos := listElement infinite firstChild holder position.
lastPos := listElement infinite lastChild holder position.
firstPos to: lastPos do: [ :idx |
((target selectionModel containsIndex: idx) and: [
target unselectableSelectionModel containsIndex: idx ]) ifTrue: [
target selecter deselectIndex: idx ] ].
target dataSource notifyItemsChanged: (firstPos to: lastPos).
target requestLayout
((listElement selectionModel containsIndex: idx) and: [
listElement unselectableSelectionModel containsIndex: idx ]) ifTrue: [
listElement selecter deselectIndex: idx ] ].
anEvent selectionModel selectedIndexesIntervalsDo: [ :interval |
listElement dataSource notifyItemsChanged:
(interval first to: interval last) ]
]
15 changes: 11 additions & 4 deletions src/Toplo-Widget-List/ToListNodeSelectionEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ ToListNodeSelectionEventHandler >> mouseDownEvent: anEvent [
{ #category : #'mouse handlers' }
ToListNodeSelectionEventHandler >> notifyClickOnNodeFromEvent: anEvent [

| node listElement |
| node listElement preNotification eventToNotify |
node := anEvent currentTarget.
listElement := node holder listElement.
listElement notifyClickOnNodeEvent: (ToListClickOnNodeEvent new
sourceEvent: anEvent;
yourself)
eventToNotify := ToListClickOnNodeEvent new
sourceEvent: anEvent;
yourself.
preNotification := ToListClickOnNodePreNotificationEvent new
node: node;
sourceEvent: eventToNotify;
yourself.
listElement dispatchEvent: preNotification.
preNotification sourceEvent ifNil: [ ^ self ].
node dispatchEvent: eventToNotify
]

{ #category : #'mouse handlers' }
Expand Down
Loading

0 comments on commit c5e32bc

Please sign in to comment.