Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : #PyramidRemoveSelectionCommand,
#name : #PyramidRemoveSelectedElementsCommand,
#superclass : #PyramidAbstractBlocCommand,
#instVars : [
'mementoInverse'
Expand All @@ -8,13 +8,13 @@ Class {
}

{ #category : #'as yet unclassified' }
PyramidRemoveSelectionCommand >> getValueFor: anElementOfSelection [
PyramidRemoveSelectedElementsCommand >> getValueFor: anElementOfSelection [

^ nil
]

{ #category : #'as yet unclassified' }
PyramidRemoveSelectionCommand >> mementoFor: anElement withArguments: anArgument [
PyramidRemoveSelectedElementsCommand >> mementoFor: anElement withArguments: anArgument [

(anArgument includes: anElement) ifTrue: [
^ PyramidCommandMemento new
Expand All @@ -30,26 +30,26 @@ PyramidRemoveSelectionCommand >> mementoFor: anElement withArguments: anArgument
]

{ #category : #accessing }
PyramidRemoveSelectionCommand >> mementoInverse [
PyramidRemoveSelectedElementsCommand >> mementoInverse [

^ mementoInverse
]

{ #category : #accessing }
PyramidRemoveSelectionCommand >> mementoInverse: anObject [
PyramidRemoveSelectedElementsCommand >> mementoInverse: anObject [

mementoInverse := anObject
]

{ #category : #'as yet unclassified' }
PyramidRemoveSelectionCommand >> saveStatesOf: aCollection with: aRoots [
PyramidRemoveSelectedElementsCommand >> saveStatesOf: aCollection with: aRoots [
"We ignore the state recovery for the redo, we will force the inverse of the undo state."

^ self mementoInverse accept: PyramidMementoInverser new.
]

{ #category : #'as yet unclassified' }
PyramidRemoveSelectionCommand >> saveStatesWithCommandInverseOf: aCollection with: aRoots [
PyramidRemoveSelectedElementsCommand >> saveStatesWithCommandInverseOf: aCollection with: aRoots [

| mementos finalMemento |
mementos := aCollection asArray collect: [ :anElement |
Expand All @@ -65,10 +65,16 @@ PyramidRemoveSelectionCommand >> saveStatesWithCommandInverseOf: aCollection wit
]

{ #category : #'as yet unclassified' }
PyramidRemoveSelectionCommand >> setValueFor: anElementOfSelection with: aRoot [
PyramidRemoveSelectedElementsCommand >> setValueFor: aBlElementToRemove with: aRoot [
"Remove the element from its parent"

(aRoot includes: anElementOfSelection) ifTrue: [
aRoot remove: anElementOfSelection.
^ self ].
anElementOfSelection parent removeChild: anElementOfSelection
"When the parent is the root"
(aRoot includes: aBlElementToRemove) ifTrue: [
aRoot remove: aBlElementToRemove.
^ self
].

"When the parent is not the root"
aBlElementToRemove hasParent ifFalse:[ ^ self ].
aBlElementToRemove parent removeChild: aBlElementToRemove
]
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidSelectionMakerExtension.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PyramidSelectionMakerExtension >> computeExclusifSelection: aCollection [
PyramidSelectionMakerExtension >> computeNormalSelection: aCollection [

self projectModel ifNil: [ ^ self ].
self projectModel selection replaceAll: aCollection
self projectModel setSelection: aCollection
]

{ #category : #'as yet unclassified' }
Expand Down
24 changes: 13 additions & 11 deletions src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PyramidSelectionWidgetExtension >> centerDragEnd: anEvent [
self widgetElement transformDo: [ :t | t translateBy: 0 @ 0 ].
self widgetElement childrenDo: [ :child |
child
childNamed: #drag_ghost
childWithId: #drag_ghost
ifFound: [ :ghost | ghost visibility: BlVisibility hidden ] ]
]

Expand All @@ -50,7 +50,10 @@ PyramidSelectionWidgetExtension >> centerDragStart: anEvent [
self isDragging: true.
self dragOrigin: anEvent position.
anEvent consumed: true.
self widgetElement childrenDo: [ :child | child childNamed: #drag_ghost ifFound: [ :ghost | ghost visibility: BlVisibility visible ] ]
self widgetElement childrenDo: [ :child |
child
childWithId: #drag_ghost
ifFound: [ :ghost | ghost visibility: BlVisibility visible ] ]
]

{ #category : #accessing }
Expand Down Expand Up @@ -189,18 +192,10 @@ PyramidSelectionWidgetExtension >> projectModel: aProjectModel [
self makeNewSelection.
]

{ #category : #events }
PyramidSelectionWidgetExtension >> pyramidElementsChanged [

self removeSelection.
self makeNewSelection
]

{ #category : #events }
PyramidSelectionWidgetExtension >> pyramidSelectionChanged [

self removeSelection.
self makeNewSelection
self updateSelection
]

{ #category : #'selection element' }
Expand All @@ -225,6 +220,13 @@ PyramidSelectionWidgetExtension >> removeSelection [
self widgetElement removeChildren.
]

{ #category : #selection }
PyramidSelectionWidgetExtension >> updateSelection [

self removeSelection.
self makeNewSelection
]

{ #category : #'as yet unclassified' }
PyramidSelectionWidgetExtension >> usePositionOffsetCommand: aPosition [

Expand Down
23 changes: 13 additions & 10 deletions src/Pyramid-Bloc/PyramidTreePlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ PyramidTreePlugin >> menuAddAndDeleteOn: aBuilder [
addGroupEmptySelection: [ :group :empty |
group addItem: [ :anItem |
anItem
name: 'Add new element';
name: 'Add element...';
help: 'Add a new element on the roots of the design.';
icon: (self iconNamed: #add);
action: [
Expand All @@ -215,7 +215,7 @@ PyramidTreePlugin >> menuAddAndDeleteOn: aBuilder [
addGroupSingleSelection: [ :group :single |
group addItem: [ :anItem |
anItem
name: 'Add new element';
name: 'Add child element...';
help: 'Add a new element as a child of the selected element.';
icon: (self iconNamed: #add);
action: [
Expand All @@ -225,11 +225,11 @@ PyramidTreePlugin >> menuAddAndDeleteOn: aBuilder [
position: SpPopoverPosition right) popup ] ].
group addItem: [ :anItem |
anItem
name: 'Remove selection';
name: 'Remove element';
help:
'Delete the selected element and its children from the design.';
'Delete the selected element and its content';
icon: (self iconNamed: #delete);
action: [ self removeSelection ] ] ]
action: [ self removeSelectedElements ] ] ]
order: 10.

aBuilder
Expand All @@ -238,19 +238,22 @@ PyramidTreePlugin >> menuAddAndDeleteOn: aBuilder [
anItem
name: 'Remove selection';
help:
'Delete all selected elements and their children from the design.';
'Delete all selected elements and their contents';
icon: (self iconNamed: #delete);
action: [ self removeSelection ] ] ]
action: [ self removeSelectedElements ] ] ]
order: 10
]

{ #category : #removing }
PyramidTreePlugin >> removeSelection [
PyramidTreePlugin >> removeSelectedElements [

self editor propertiesManager commandExecutor
use: PyramidRemoveSelectionCommand new
use: PyramidRemoveSelectedElementsCommand new
on: self editor projectModel selection
with: self editor projectModel roots
with: self editor projectModel roots.

"Update the selection after remove"
self editor projectModel updateSelection.
]

{ #category : #accessing }
Expand Down
7 changes: 2 additions & 5 deletions src/Pyramid-Bloc/PyramidTreePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ PyramidTreePresenter >> actionSelectionChanged: aCollection [
self projectModel ifNil: [ ^ self ].
self shouldUpdateSelection ifFalse: [ ^ self ].
self shouldUpdateSelection: false.
[
self projectModel selection replaceAll:
aCollection selectedItems ] ensure: [
self shouldUpdateSelection: true ]
[self projectModel setSelection: aCollection selectedItems ] ensure: [ self shouldUpdateSelection: true ]
]

{ #category : #accessing }
Expand Down Expand Up @@ -194,7 +191,7 @@ PyramidTreePresenter >> updateSelection [
[
self tree unselectAll.
self projectModel selection
ifNotEmpty: [ self tree selectItems: self projectModel selection ] ]
ifNotEmpty: [ :e | self tree selectItems: e ] ]
ensure: [ self shouldUpdateSelection: true ]
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ PyramidRemoveSelectionCommandTest >> arraysToTest [
{ #category : #accessing }
PyramidRemoveSelectionCommandTest >> command [

^ PyramidRemoveSelectionCommand new
^ PyramidRemoveSelectedElementsCommand new
]

{ #category : #'as yet unclassified' }
Expand Down
35 changes: 22 additions & 13 deletions src/Pyramid/PyramidProjectModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,37 @@ PyramidProjectModel >> initialize [
selection := PyramidCollectionWithCallbacks new.
roots := PyramidSortedCollectionWithCallbacks new sortFunction: PyramidElevationSortFunction new; yourself.

selection
subscribe: self
withCallback: [ self informSelectionChanged ].
selection subscribe: self withCallback: [ self informSelectionChanged ].
roots subscribe: self withCallback: [ self informRootsChanged ]
]

{ #category : #removing }
PyramidProjectModel >> removeSelection [

(self selection asArray difference: self roots asArray) do: [ :each |
each parent ifNotNil: [ :p | p removeChild: each ] ].
self roots removeAllFoundIn: self selection asArray.
self selection removeAll
]

{ #category : #accessing }
PyramidProjectModel >> roots [
^ roots
]

{ #category : #accessing }
{ #category : #selection }
PyramidProjectModel >> selection [

^ selection
]

{ #category : #selection }
PyramidProjectModel >> setSelection: aBlElementCollection [
"Replace current selection by another one"

self selection replaceAll: aBlElementCollection
]

{ #category : #selection }
PyramidProjectModel >> updateSelection [
"Update the selection list regarding existing elements"

| toBeRemovedFromSelectionElements |
"Select not attached to scene or without parents elements (this is the status after a deletion)"
toBeRemovedFromSelectionElements := self selection collection select:[ :e | e hasParent not or:[ e isAttachedToSceneGraph ] ].

self selection removeAll: toBeRemovedFromSelectionElements.


]
13 changes: 8 additions & 5 deletions src/Pyramid/PyramidSelectionView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ PyramidSelectionView >> pyramidSelectionChanged [
{ #category : #'as yet unclassified' }
PyramidSelectionView >> updateSelection [

self list items: self currentSelection.
self currentSelection ifEmpty: [
| currentSelection |
currentSelection := self currentSelection.

self list items: currentSelection.
currentSelection ifEmpty: [
self connectPlaygroundTo: nil.
^ self ].
self currentSelection size = 1 ifTrue: [
self connectPlaygroundTo: self currentSelection first.
currentSelection size = 1 ifTrue: [
self connectPlaygroundTo: currentSelection first.
^ self ].
self connectPlaygroundTo: self currentSelection
self connectPlaygroundTo: currentSelection
]