Skip to content

Commit

Permalink
Spawn a new tab on the selection using primary + double click [feenkc…
Browse files Browse the repository at this point in the history
  • Loading branch information
chisandrei committed Nov 5, 2024
1 parent 4ca6e72 commit 8df69bb
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 46 deletions.
22 changes: 11 additions & 11 deletions src/GToolkit-Phlow/GtPhlowGroupedListToSelectHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ GtPhlowGroupedListToSelectHandler >> selectionChangedEvent: anEvent [

{ #category : #accessing }
GtPhlowGroupedListToSelectHandler >> selectionDoubleClickedEvent: anEvent [

anEvent selection ifNotEmpty: [ :anInterval |
| aWidgetElement aSelectedObject |

aWidgetElement := anEvent currentTarget.

aSelectedObject := aWidgetElement viewModel entityAt: anInterval first.
self transformation
spawn: aSelectedObject
indices: anInterval
from: aWidgetElement ]
anEvent selection
ifNotEmpty: [ :anInterval |
| aWidgetElement aSelectedObject |
aWidgetElement := anEvent currentTarget.

aSelectedObject := aWidgetElement viewModel entityAt: anInterval first.
self transformation
spawn: aSelectedObject
indices: anInterval
from: aWidgetElement
shouldShowSpace: false ]
]
6 changes: 6 additions & 0 deletions src/GToolkit-Phlow/GtPhlowListHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ GtPhlowListHandler >> initialize [
transformation := self defaultTransformation
]

{ #category : #testing }
GtPhlowListHandler >> shouldShowSelectionInNewSpaceFor: anEvent [
^ anEvent sourceEvent notNil and: [
anEvent sourceEvent modifiers isPrimaryModifier ]
]

{ #category : #accessing }
GtPhlowListHandler >> transformation [
<return: #GtPhlowSendTransformation>
Expand Down
30 changes: 13 additions & 17 deletions src/GToolkit-Phlow/GtPhlowListToSelectHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,31 @@ GtPhlowListToSelectHandler >> selectionChangedEvent: anEvent [
| currentWidgetElement selectedObject |
aSelection isNotEmpty
ifTrue: [
| shouldShowSpace |
currentWidgetElement := anEvent currentTarget.
selectedObject := currentWidgetElement selectionCallback
value: aSelection indices.
shouldShowSpace := anEvent sourceEvent notNil and: [
anEvent sourceEvent modifiers isPrimaryModifier and: [
anEvent sourceEvent modifiers isShift ] ].

self transformation
select: selectedObject
indices: aSelection indices
from: currentWidgetElement
shouldShowSpace: shouldShowSpace ] ]
shouldShowSpace: false ] ]
]

{ #category : #'api - event managing' }
GtPhlowListToSelectHandler >> selectionDoubleClickedEvent: anEvent [

anEvent selection ifNotEmpty: [ :anInterval |
| currentWidgetElement selectedObject |

currentWidgetElement := anEvent currentTarget.
selectedObject := currentWidgetElement selectionCallback
value: anInterval.

self transformation
spawn: selectedObject
indices: anInterval
from: currentWidgetElement ]
anEvent selection
ifNotEmpty: [ :anInterval |
| currentWidgetElement selectedObject shouldShowSpace |
currentWidgetElement := anEvent currentTarget.
selectedObject := currentWidgetElement selectionCallback value: anInterval.
shouldShowSpace := self shouldShowSelectionInNewSpaceFor: anEvent.

self transformation
spawn: selectedObject
indices: anInterval
from: currentWidgetElement
shouldShowSpace: shouldShowSpace ]
]

{ #category : #'api - event managing' }
Expand Down
24 changes: 14 additions & 10 deletions src/GToolkit-Phlow/GtPhlowListToSpawnHandler.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Class {
#name : #GtPhlowListToSpawnHandler,
#superclass : #GtPhlowListHandler,
#category : 'GToolkit-Phlow-Events'
#category : #'GToolkit-Phlow-Events'
}

{ #category : #'private - accessing' }
Expand All @@ -20,16 +20,20 @@ GtPhlowListToSpawnHandler >> eventsToHandle [
{ #category : #'api - event managing' }
GtPhlowListToSpawnHandler >> handleEvent: anEvent [
| aWidgetElement |

aWidgetElement := anEvent currentTarget.

anEvent selectedDo: [ :anInterval |
| selectedObject |
selectedObject := aWidgetElement viewModel itemAt: anInterval first.
self transformation
spawn: selectedObject
indices: anInterval
from: aWidgetElement. ]

anEvent
selectedDo: [ :anInterval |
| selectedObject shouldShowSpace |
GtJustContextStackSignal emit.
selectedObject := aWidgetElement viewModel itemAt: anInterval first.
shouldShowSpace := self shouldShowSelectionInNewSpaceFor: anEvent.

self transformation
spawn: selectedObject
indices: anInterval
from: aWidgetElement
shouldShowSpace: shouldShowSpace ]
]

{ #category : #'api - event managing' }
Expand Down
7 changes: 5 additions & 2 deletions src/GToolkit-Phlow/GtPhlowSendObjectTransformation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ GtPhlowSendObjectTransformation >> select: aSelectedObject indices: aSelectionIn
]

{ #category : #'api - events' }
GtPhlowSendObjectTransformation >> spawn: aSelectedObject indices: aSelectionIndices from: anElement [
GtPhlowSendObjectTransformation >> spawn: aSelectedObject indices: aSelectionIndices from: anElement shouldShowSpace: shouldShowSpace [
| aTransformedValue |
aTransformedValue := self transformedValueFrom: aSelectedObject selection: aSelectionIndices.
anElement phlow spawnObject: aTransformedValue

shouldShowSpace
ifTrue: [ self spawnInSpaceObject: aTransformedValue from: anElement ]
ifFalse: [ anElement phlow spawnObject: aTransformedValue ]
]

{ #category : #utils }
Expand Down
7 changes: 5 additions & 2 deletions src/GToolkit-Phlow/GtPhlowSendToolTransformation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ GtPhlowSendToolTransformation >> select: aSelectedObject indices: aSelectionIndi
]

{ #category : #'api - events' }
GtPhlowSendToolTransformation >> spawn: aSelectedObject indices: aSelectionIndices from: anElement [
GtPhlowSendToolTransformation >> spawn: aSelectedObject indices: aSelectionIndices from: anElement shouldShowSpace: shouldShowSpace [
| aTransformedTool |
aTransformedTool := self transformedValueFrom: aSelectedObject selection: aSelectionIndices.
anElement phlow spawnTool: aTransformedTool

shouldShowSpace
ifTrue: [ self spawnInSpaceTool: aTransformedTool from: anElement ]
ifFalse: [ anElement phlow spawnTool: aTransformedTool ]
]

{ #category : #utils }
Expand Down
2 changes: 1 addition & 1 deletion src/GToolkit-Phlow/GtPhlowSendTransformation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GtPhlowSendTransformation >> select: aSelectedObject indices: aSelectionIndices
]

{ #category : #'api - events' }
GtPhlowSendTransformation >> spawn: aSelectedObject indices: aSelectionIndices from: anElement [
GtPhlowSendTransformation >> spawn: aSelectedObject indices: aSelectionIndices from: anElement shouldShowSpace: shouldShowSpace [
"Properly instantiate and fire ${class:GtPhlowObjectToSpawn}$ event
The ${class:GtPhlowObjectToSpawn}$ event must be instantiated with a ${class:GtPhlowTool}$ instance
that displayes the selected object (aSelectedObject)."
Expand Down
7 changes: 4 additions & 3 deletions src/GToolkit-Phlow/GtPhlowSendTreeNodeTransformation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ GtPhlowSendTreeNodeTransformation >> select: aSelectedNode indices: aSelectionIn
]

{ #category : #'api - events' }
GtPhlowSendTreeNodeTransformation >> spawn: aSelectedNode indices: aSelectionIndices from: anElement [
self transformation
GtPhlowSendTreeNodeTransformation >> spawn: aSelectedNode indices: aSelectionIndices from: anElement shouldShowSpace: shouldShowSpace [
self transformation
spawn: aSelectedNode value
indices: aSelectionIndices
indices: aSelectionIndices
from: anElement
shouldShowSpace: shouldShowSpace
]

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

0 comments on commit 8df69bb

Please sign in to comment.