diff --git a/src/Pyramid-Bloc/PyramidAbstractChangeDrawOrderCommand.class.st b/src/Pyramid-Bloc/PyramidAbstractChangeDrawOrderCommand.class.st new file mode 100644 index 00000000..38ee07cb --- /dev/null +++ b/src/Pyramid-Bloc/PyramidAbstractChangeDrawOrderCommand.class.st @@ -0,0 +1,24 @@ +Class { + #name : #PyramidAbstractChangeDrawOrderCommand, + #superclass : #PyramidAbstractBlocCommand, + #category : #'Pyramid-Bloc-plugin-bloc-order' +} + +{ #category : #testing } +PyramidAbstractChangeDrawOrderCommand class >> isAbstract [ + + ^ self == PyramidAbstractChangeDrawOrderCommand +] + +{ #category : #testing } +PyramidAbstractChangeDrawOrderCommand >> canBeUsedFor: anObject [ + + ^ (super canBeUsedFor: anObject) and: [ anObject hasParent] +] + +{ #category : #'as yet unclassified' } +PyramidAbstractChangeDrawOrderCommand >> getValueFor: aBlElement [ + "return current index for testing." + + ^ aBlElement parent childIndexOf: aBlElement +] diff --git a/src/Pyramid-Bloc/PyramidAbstractChangePositionWithSiblingsCommand.class.st b/src/Pyramid-Bloc/PyramidAbstractChangePositionWithSiblingsCommand.class.st deleted file mode 100644 index 87a70a0a..00000000 --- a/src/Pyramid-Bloc/PyramidAbstractChangePositionWithSiblingsCommand.class.st +++ /dev/null @@ -1,41 +0,0 @@ -Class { - #name : #PyramidAbstractChangePositionWithSiblingsCommand, - #superclass : #PyramidAbstractBlocCommand, - #category : #'Pyramid-Bloc-plugin-bloc-siblings' -} - -{ #category : #testing } -PyramidAbstractChangePositionWithSiblingsCommand class >> isAbstract [ - - ^ self == PyramidAbstractChangePositionWithSiblingsCommand -] - -{ #category : #testing } -PyramidAbstractChangePositionWithSiblingsCommand >> canBeUsedFor: anObject [ - - ^ (super canBeUsedFor: anObject) and: [ anObject hasParent ] -] - -{ #category : #'as yet unclassified' } -PyramidAbstractChangePositionWithSiblingsCommand >> commandInverse [ - - ^ PyramidSendAtIndexCommand new -] - -{ #category : #'as yet unclassified' } -PyramidAbstractChangePositionWithSiblingsCommand >> getValueFor: aBlElement [ - - ^ PyramidChangePositionWithSiblingsModel new - zIndex: aBlElement elevation elevation; - childIndex: (aBlElement parent childIndexOf: aBlElement); - yourself -] - -{ #category : #'as yet unclassified' } -PyramidAbstractChangePositionWithSiblingsCommand >> saveStatesOf: aCollection with: arguments [ - - ^ self - saveStatesOf: aCollection - withCommand: self commandInverse - withArguments: arguments -] diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index 5f1cd964..a6f8b8a9 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -402,33 +402,37 @@ PyramidBlocPlugin >> menuChangeOrderOn: aBuilder [ group addItem: [ :item | item - icon: (self iconNamed: #top); - name: 'Put in front'; + icon: PyramidDrawOrderIcons formOnForeground; + name: 'On foreground'; enabled: true; - action: [ self send: PyramidSendTopCommand new on: { single } ]; + action: [ + self send: PyramidOnForegroundOrderCommand new on: { single } ]; yourself ]; addItem: [ :item | item - icon: (self iconNamed: #up); - name: 'Send up'; + icon: PyramidDrawOrderIcons formOnBackground; + name: 'On background'; enabled: true; - action: [ self send: PyramidSendUpCommand new on: { single } ]; + action: [ + self send: PyramidOnBackgroundOrderCommand new on: { single } ]; yourself ]; addItem: [ :item | item - icon: (self iconNamed: #down); - name: 'Send down'; + icon: PyramidDrawOrderIcons formMoveForward; + name: 'Move forward'; enabled: true; - action: [ self send: PyramidSendDownCommand new on: { single } ]; + action: [ + self send: PyramidMoveForwardOrderCommand new on: { single } ]; yourself ]; addItem: [ :item | item - icon: (self iconNamed: #bottom); - name: 'Put in back'; + icon: PyramidDrawOrderIcons formMoveBackward; + name: 'Move backward'; enabled: true; action: [ - self send: PyramidSendBottomCommand new on: { single } ]; - yourself ] ] + self send: PyramidMoveBackwardOrderCommand new on: { single } ]; + yourself ]; + yourself ] order: 20 ] diff --git a/src/Pyramid-Bloc/PyramidChangeOrderWithIndexCommand.class.st b/src/Pyramid-Bloc/PyramidChangeOrderWithIndexCommand.class.st new file mode 100644 index 00000000..f314fb83 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidChangeOrderWithIndexCommand.class.st @@ -0,0 +1,17 @@ +Class { + #name : #PyramidChangeOrderWithIndexCommand, + #superclass : #PyramidAbstractChangeDrawOrderCommand, + #category : #'Pyramid-Bloc-plugin-bloc-order' +} + +{ #category : #'as yet unclassified' } +PyramidChangeOrderWithIndexCommand >> setValueFor: aBlElement with: anArgument [ + + | currentIndex parent | + currentIndex := self getValueFor: aBlElement. + parent := aBlElement parent. + (anArgument between: 1 and: parent childrenCount) ifFalse: [ ^ self ]. + + parent removeChild: aBlElement. + parent addChild: aBlElement at: anArgument +] diff --git a/src/Pyramid-Bloc/PyramidChangePositionWithSiblingsModel.class.st b/src/Pyramid-Bloc/PyramidChangePositionWithSiblingsModel.class.st deleted file mode 100644 index 5666d795..00000000 --- a/src/Pyramid-Bloc/PyramidChangePositionWithSiblingsModel.class.st +++ /dev/null @@ -1,41 +0,0 @@ -Class { - #name : #PyramidChangePositionWithSiblingsModel, - #superclass : #Object, - #instVars : [ - 'zIndex', - 'childIndex' - ], - #category : #'Pyramid-Bloc-plugin-bloc-siblings' -} - -{ #category : #comparing } -PyramidChangePositionWithSiblingsModel >> = anObject [ - - anObject == self ifTrue: [ ^true ]. - anObject class = self class ifTrue: [ ^ true ]. - ^ (self childIndex = anObject childIndex) and: [ self zIndex = anObject zIndex ] -] - -{ #category : #accessing } -PyramidChangePositionWithSiblingsModel >> childIndex [ - - ^ childIndex -] - -{ #category : #accessing } -PyramidChangePositionWithSiblingsModel >> childIndex: anObject [ - - childIndex := anObject -] - -{ #category : #accessing } -PyramidChangePositionWithSiblingsModel >> zIndex [ - - ^ zIndex -] - -{ #category : #accessing } -PyramidChangePositionWithSiblingsModel >> zIndex: anObject [ - - zIndex := anObject -] diff --git a/src/Pyramid-Bloc/PyramidDrawOrderIcons.class.st b/src/Pyramid-Bloc/PyramidDrawOrderIcons.class.st new file mode 100644 index 00000000..399418ae --- /dev/null +++ b/src/Pyramid-Bloc/PyramidDrawOrderIcons.class.st @@ -0,0 +1,715 @@ +Class { + #name : #PyramidDrawOrderIcons, + #superclass : #Object, + #category : #'Pyramid-Bloc-plugin-bloc-order' +} + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> blocMoveBackward [ + "This class has been generated using Pyramid. + + By: YannLEGOFF + 2023-12-15 09:23:43" + + + ^ '[ + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #position : Point [ 4, 4 ], + #margin : BlInsets { + #top : 0.0, + #left : 0.0, + #bottom : 0.0, + #right : 0.0 + }, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : Float [ #infinity ], + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color [ #black ] + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : BlStrokeLineButtCap { }, + #lineJoin : BlStrokeLineMiterJoin { }, + #miterLimit : 4.0, + #dashArray : [ ], + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.6862170087976539, + #green : 0.8357771260997068, + #blue : 0.9804496578690127, + #alpha : 1.0 + } + } + }, + #elevation : BlRelativeElevation { + #elevation : 1 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #B + } + }, + #layout : BlBasicLayout { } + }, + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #position : Point [ 0.0, 0.0 ], + #margin : @10, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : @11, + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color { + #red : 0.592375366568915, + #green : 0.592375366568915, + #blue : 0.592375366568915, + #alpha : 1.0 + } + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : @17, + #lineJoin : @18, + #miterLimit : 4.0, + #dashArray : @19, + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.9022482893450635, + #green : 0.9022482893450635, + #blue : 0.9022482893450635, + #alpha : 1.0 + } + } + }, + #elevation : BlRelativeElevation { + #elevation : 2 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #A + } + }, + #layout : @26 + } +]' +] + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> blocMoveForward [ + "This class has been generated using Pyramid. + + By: YannLEGOFF + 2023-12-15 09:24:01" + + + ^ '[ + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #position : Point [ 0.0, 0.0 ], + #margin : BlInsets { + #top : 0.0, + #left : 0.0, + #bottom : 0.0, + #right : 0.0 + }, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : Float [ #infinity ], + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color { + #red : 0.592375366568915, + #green : 0.592375366568915, + #blue : 0.592375366568915, + #alpha : 1.0 + } + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : BlStrokeLineButtCap { }, + #lineJoin : BlStrokeLineMiterJoin { }, + #miterLimit : 4.0, + #dashArray : [ ], + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.9022482893450635, + #green : 0.9022482893450635, + #blue : 0.9022482893450635, + #alpha : 1.0 + } + } + }, + #elevation : BlRelativeElevation { + #elevation : 0 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #A + } + }, + #layout : BlBasicLayout { } + }, + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 12.0 + } + }, + #position : Point [ 4, 4 ], + #margin : @10, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : @11, + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color [ #black ] + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : @17, + #lineJoin : @18, + #miterLimit : 4.0, + #dashArray : @19, + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.6862170087976539, + #green : 0.8357771260997068, + #blue : 0.9804496578690127, + #alpha : 1.0 + } + } + }, + #elevation : BlRelativeElevation { + #elevation : 1 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #B + } + }, + #layout : @26 + } +]' +] + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> blocOnBackground [ + "This class has been generated using Pyramid. + + By: YannLEGOFF + 2023-12-15 09:22:07" + + + ^ '[ + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #position : Point [ 4, 4 ], + #margin : BlInsets { + #top : 0.0, + #left : 0.0, + #bottom : 0.0, + #right : 0.0 + }, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : Float [ #infinity ], + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color [ #black ] + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : BlStrokeLineButtCap { }, + #lineJoin : BlStrokeLineMiterJoin { }, + #miterLimit : 4.0, + #dashArray : [ ], + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.6862170087976539, + #green : 0.8357771260997068, + #blue : 0.9804496578690127, + #alpha : 1.0 + } + } + }, + #elevation : BlRelativeElevation { + #elevation : 1 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #B + } + }, + #layout : BlBasicLayout { } + }, + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #position : Point [ 0.0, 0.0 ], + #margin : @10, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : @11, + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color { + #red : 0.592375366568915, + #green : 0.592375366568915, + #blue : 0.592375366568915, + #alpha : 1.0 + } + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : @17, + #lineJoin : @18, + #miterLimit : 4.0, + #dashArray : @19, + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.9022482893450635, + #green : 0.9022482893450635, + #blue : 0.9022482893450635, + #alpha : 1.0 + } + } + }, + #elevation : BlRelativeElevation { + #elevation : 2 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #A + } + }, + #layout : @26 + }, + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #position : Point [ 8.0, 8.0 ], + #margin : @10, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : @11, + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color { + #red : 0.592375366568915, + #green : 0.592375366568915, + #blue : 0.592375366568915, + #alpha : 1.0 + } + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : @17, + #lineJoin : @18, + #miterLimit : 4.0, + #dashArray : @19, + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : @40, + #elevation : BlRelativeElevation { + #elevation : 2 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #C + } + }, + #layout : @26 + } +]' +] + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> blocOnForeground [ + "This class has been generated using Pyramid. + + By: YannLEGOFF + 2023-12-15 09:21:40" + + + ^ '[ + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #position : Point [ 0.0, 0.0 ], + #margin : BlInsets { + #top : 0.0, + #left : 0.0, + #bottom : 0.0, + #right : 0.0 + }, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : Float [ #infinity ], + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color { + #red : 0.592375366568915, + #green : 0.592375366568915, + #blue : 0.592375366568915, + #alpha : 1.0 + } + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : BlStrokeLineButtCap { }, + #lineJoin : BlStrokeLineMiterJoin { }, + #miterLimit : 4.0, + #dashArray : [ ], + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.9022482893450635, + #green : 0.9022482893450635, + #blue : 0.9022482893450635, + #alpha : 1.0 + } + } + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #A + } + }, + #layout : BlBasicLayout { } + }, + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #position : Point [ 8.0, 8.0 ], + #margin : @10, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : @11, + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color { + #red : 0.592375366568915, + #green : 0.592375366568915, + #blue : 0.592375366568915, + #alpha : 1.0 + } + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : @17, + #lineJoin : @18, + #miterLimit : 4.0, + #dashArray : @19, + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : @20 + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #C + } + }, + #layout : @25 + }, + BlElement { + #children : BlChildrenArray [ ], + #constraints : BlLayoutCommonConstraints { + #vertical : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #horizontal : BlLayoutCommonConstraintsAxis { + #resizer : BlLayoutExactResizer { + #size : 8.0 + } + }, + #position : Point [ 4, 4 ], + #margin : @10, + #padding : @10, + #minHeight : 0.0, + #minWidth : 0.0, + #maxHeight : @11, + #maxWidth : @11, + #ignoredByLayout : false, + #accountTransformation : false + }, + #visuals : BlCustomVisuals { + #border : BlBorder { + #paint : BlColorPaint { + #color : Color [ #black ] + }, + #width : 1, + #style : BlStrokeStyle { + #lineCap : @17, + #lineJoin : @18, + #miterLimit : 4.0, + #dashArray : @19, + #dashOffset : 0.0 + }, + #opacity : 1.0 + }, + #background : BlPaintBackground { + #paint : BlColorPaint { + #color : Color { + #red : 0.6862170087976539, + #green : 0.8357771260997068, + #blue : 0.9804496578690127, + #alpha : 1.0 + } + } + }, + #elevation : BlRelativeElevation { + #elevation : 1 + } + }, + #userData : IdentityDictionary { + #shouldHandleMousePickOutsideEvent : false, + #elementId : BlElementNamedId { + #identifier : #B + } + }, + #layout : @25 + } +]' +] + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> formMoveBackward [ + + ^ (BlElement new + size: 16 @ 16; + addChildren: self blocMoveBackward materializeAsBlElement) + exportAsForm +] + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> formMoveForward [ + + ^ (BlElement new + size: 16 @ 16; + addChildren: self blocMoveForward materializeAsBlElement) + exportAsForm +] + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> formOnBackground [ + + ^ (BlElement new + size: 16 @ 16; + addChildren: self blocOnBackground materializeAsBlElement) + exportAsForm +] + +{ #category : #'pyramid-serialized-bloc' } +PyramidDrawOrderIcons class >> formOnForeground [ + + ^ (BlElement new + size: 16 @ 16; + addChildren: self blocOnForeground materializeAsBlElement) + exportAsForm +] diff --git a/src/Pyramid-Bloc/PyramidMoveBackwardOrderCommand.class.st b/src/Pyramid-Bloc/PyramidMoveBackwardOrderCommand.class.st new file mode 100644 index 00000000..4fc68ba7 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidMoveBackwardOrderCommand.class.st @@ -0,0 +1,20 @@ +Class { + #name : #PyramidMoveBackwardOrderCommand, + #superclass : #PyramidAbstractChangeDrawOrderCommand, + #category : #'Pyramid-Bloc-plugin-bloc-order' +} + +{ #category : #'as yet unclassified' } +PyramidMoveBackwardOrderCommand >> commandInverse [ + + ^ PyramidMoveForwardOrderCommand new +] + +{ #category : #'as yet unclassified' } +PyramidMoveBackwardOrderCommand >> setValueFor: aBlElement with: anArgument [ + + | currentIndex | + currentIndex := self getValueFor: aBlElement. + currentIndex = 1 ifTrue: [ ^ self ]. + aBlElement parent swapChildAt: currentIndex with: currentIndex - 1 +] diff --git a/src/Pyramid-Bloc/PyramidMoveForwardOrderCommand.class.st b/src/Pyramid-Bloc/PyramidMoveForwardOrderCommand.class.st new file mode 100644 index 00000000..35008ed9 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidMoveForwardOrderCommand.class.st @@ -0,0 +1,21 @@ +Class { + #name : #PyramidMoveForwardOrderCommand, + #superclass : #PyramidAbstractChangeDrawOrderCommand, + #category : #'Pyramid-Bloc-plugin-bloc-order' +} + +{ #category : #'as yet unclassified' } +PyramidMoveForwardOrderCommand >> commandInverse [ + + ^ PyramidMoveBackwardOrderCommand new +] + +{ #category : #'as yet unclassified' } +PyramidMoveForwardOrderCommand >> setValueFor: aBlElement with: anArgument [ + + | currentIndex | + currentIndex := self getValueFor: aBlElement. + currentIndex = aBlElement parent childrenCount ifTrue: [ ^ self ]. + + aBlElement parent swapChildAt: currentIndex with: currentIndex + 1 +] diff --git a/src/Pyramid-Bloc/PyramidOnBackgroundOrderCommand.class.st b/src/Pyramid-Bloc/PyramidOnBackgroundOrderCommand.class.st new file mode 100644 index 00000000..257fd1b4 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidOnBackgroundOrderCommand.class.st @@ -0,0 +1,22 @@ +Class { + #name : #PyramidOnBackgroundOrderCommand, + #superclass : #PyramidAbstractChangeDrawOrderCommand, + #category : #'Pyramid-Bloc-plugin-bloc-order' +} + +{ #category : #'as yet unclassified' } +PyramidOnBackgroundOrderCommand >> commandInverse [ + + ^ PyramidChangeOrderWithIndexCommand new +] + +{ #category : #'as yet unclassified' } +PyramidOnBackgroundOrderCommand >> setValueFor: aBlElement with: anArgument [ + + | currentIndex parent | + currentIndex := self getValueFor: aBlElement. + parent := aBlElement parent. + parent childrenCount <= 1 ifTrue: [ ^ self ]. + parent removeChild: aBlElement. + parent addChild: aBlElement at: 1 +] diff --git a/src/Pyramid-Bloc/PyramidOnForegroundOrderCommand.class.st b/src/Pyramid-Bloc/PyramidOnForegroundOrderCommand.class.st new file mode 100644 index 00000000..dda01bb0 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidOnForegroundOrderCommand.class.st @@ -0,0 +1,22 @@ +Class { + #name : #PyramidOnForegroundOrderCommand, + #superclass : #PyramidAbstractChangeDrawOrderCommand, + #category : #'Pyramid-Bloc-plugin-bloc-order' +} + +{ #category : #'as yet unclassified' } +PyramidOnForegroundOrderCommand >> commandInverse [ + + ^ PyramidChangeOrderWithIndexCommand new +] + +{ #category : #'as yet unclassified' } +PyramidOnForegroundOrderCommand >> setValueFor: aBlElement with: anArgument [ + + | currentIndex parent | + currentIndex := self getValueFor: aBlElement. + parent := aBlElement parent. + parent childrenCount <= 1 ifTrue: [ ^ self ]. + parent removeChild: aBlElement. + parent addChild: aBlElement at: parent childrenCount + 1 +] diff --git a/src/Pyramid-Bloc/PyramidSendAtIndexCommand.class.st b/src/Pyramid-Bloc/PyramidSendAtIndexCommand.class.st deleted file mode 100644 index 2ed7fd14..00000000 --- a/src/Pyramid-Bloc/PyramidSendAtIndexCommand.class.st +++ /dev/null @@ -1,15 +0,0 @@ -Class { - #name : #PyramidSendAtIndexCommand, - #superclass : #PyramidAbstractChangePositionWithSiblingsCommand, - #category : #'Pyramid-Bloc-plugin-bloc-siblings' -} - -{ #category : #'as yet unclassified' } -PyramidSendAtIndexCommand >> setValueFor: anObject with: anArgument [ - - | currentIndex | - anObject zIndex: anArgument zIndex. - - currentIndex := anObject parent childIndexOf: anObject. - anObject parent swapChildAt: currentIndex with: anArgument childIndex. -] diff --git a/src/Pyramid-Bloc/PyramidSendBottomCommand.class.st b/src/Pyramid-Bloc/PyramidSendBottomCommand.class.st deleted file mode 100644 index 908008b9..00000000 --- a/src/Pyramid-Bloc/PyramidSendBottomCommand.class.st +++ /dev/null @@ -1,23 +0,0 @@ -Class { - #name : #PyramidSendBottomCommand, - #superclass : #PyramidAbstractChangePositionWithSiblingsCommand, - #category : #'Pyramid-Bloc-plugin-bloc-siblings' -} - -{ #category : #'as yet unclassified' } -PyramidSendBottomCommand >> setValueFor: anObject with: anArgument [ - - | elevationMin rightChild parent | - parent := anObject parent. - elevationMin := anObject parent children - inject: Float infinity - into: [ :acc :each | - acc min: each elevation elevation ]. - rightChild := parent childAt: - (anObject parent children asOrderedCollection - findFirst: [ :each | - each elevation elevation = elevationMin ]). - rightChild = anObject ifTrue: [ ^ self ]. - parent removeChild: anObject. - parent addChild: anObject before: rightChild -] diff --git a/src/Pyramid-Bloc/PyramidSendDownCommand.class.st b/src/Pyramid-Bloc/PyramidSendDownCommand.class.st deleted file mode 100644 index 1785674f..00000000 --- a/src/Pyramid-Bloc/PyramidSendDownCommand.class.st +++ /dev/null @@ -1,41 +0,0 @@ -Class { - #name : #PyramidSendDownCommand, - #superclass : #PyramidAbstractChangePositionWithSiblingsCommand, - #category : #'Pyramid-Bloc-plugin-bloc-siblings' -} - -{ #category : #'as yet unclassified' } -PyramidSendDownCommand >> setValueFor: anObject with: anArgument [ - "Check in all elements before anObject if one as the same elevation, -if true then put anObject before. -if false then find the next smallest elevation on the end and put anObject before. -" - - | elementsToSeek rightChildIndex rightChild nextElevation parent | - parent := anObject parent. - - "Check in all elements before anObject if one as the same elevation" - elementsToSeek := parent children asOrderedCollection allButLast: - parent children size - - (parent childIndexOf: anObject) + 1. - rightChildIndex := elementsToSeek findLast: [ :each | - each elevation elevation - = anObject elevation elevation ]. - rightChildIndex = 0 ifFalse: [ - rightChild := parent childAt: rightChildIndex. - parent removeChild: anObject. - parent addChild: anObject before: rightChild. - ^ self ]. - - "if false then find the next smallest elevation on the end" - nextElevation := anObject elevation elevation. - parent children reverseDo: [ :each | - each elevation elevation < nextElevation ifTrue: [ - nextElevation := each elevation elevation. - rightChild := each ] ]. - - rightChild ifNil: [ ^ self ]. - anObject zIndex: nextElevation. - parent removeChild: anObject. - parent addChild: anObject before: rightChild -] diff --git a/src/Pyramid-Bloc/PyramidSendTopCommand.class.st b/src/Pyramid-Bloc/PyramidSendTopCommand.class.st deleted file mode 100644 index 6ce9ce9f..00000000 --- a/src/Pyramid-Bloc/PyramidSendTopCommand.class.st +++ /dev/null @@ -1,24 +0,0 @@ -Class { - #name : #PyramidSendTopCommand, - #superclass : #PyramidAbstractChangePositionWithSiblingsCommand, - #category : #'Pyramid-Bloc-plugin-bloc-siblings' -} - -{ #category : #'as yet unclassified' } -PyramidSendTopCommand >> setValueFor: anObject with: anArgument [ - - | elevationMax leftChild parent | - parent := anObject parent. - elevationMax := anObject parent children - inject: Float negativeInfinity - into: [ :acc :each | - acc max: each elevation elevation ]. - leftChild := parent childAt: - (anObject parent children asOrderedCollection - findLast: [ :each | - each elevation elevation = elevationMax ]). - leftChild = anObject ifTrue: [ ^ self ]. - anObject zIndex: elevationMax. - parent removeChild: anObject. - parent addChild: anObject after: leftChild -] diff --git a/src/Pyramid-Bloc/PyramidSendUpCommand.class.st b/src/Pyramid-Bloc/PyramidSendUpCommand.class.st deleted file mode 100644 index d4f9fbbb..00000000 --- a/src/Pyramid-Bloc/PyramidSendUpCommand.class.st +++ /dev/null @@ -1,40 +0,0 @@ -Class { - #name : #PyramidSendUpCommand, - #superclass : #PyramidAbstractChangePositionWithSiblingsCommand, - #category : #'Pyramid-Bloc-plugin-bloc-siblings' -} - -{ #category : #'as yet unclassified' } -PyramidSendUpCommand >> setValueFor: anObject with: anArgument [ - "Check in all elements after anObject if one as the same elevation, -if true then put anObject after. -if false then find the next highest elevation on the start and put anObject after. -" - - | elementsToSeek leftChildIndex leftChild nextElevation parent | - parent := anObject parent. - - "Check in all elements after anObject if one as the same elevation" - elementsToSeek := parent children asOrderedCollection allButFirst: - (parent childIndexOf: anObject). - leftChildIndex := elementsToSeek findFirst: [ :each | - each elevation elevation - = anObject elevation elevation ]. - leftChildIndex = 0 ifFalse: [ - leftChild := parent childAt: leftChildIndex + (parent childIndexOf: anObject). - parent removeChild: anObject. - parent addChild: anObject after: leftChild. - ^ self ]. - - "if false then find the next highest elevation on the start" - nextElevation := anObject elevation elevation. - parent children do: [ :each | - each elevation elevation > nextElevation ifTrue: [ - nextElevation := each elevation elevation. - leftChild := each ] ]. - - leftChild ifNil: [ ^ self ]. - anObject zIndex: nextElevation. - parent removeChild: anObject. - parent addChild: anObject after: leftChild -] diff --git a/src/Pyramid-Bloc/PyramidTreePlugin.class.st b/src/Pyramid-Bloc/PyramidTreePlugin.class.st index 259d75e3..1375c546 100644 --- a/src/Pyramid-Bloc/PyramidTreePlugin.class.st +++ b/src/Pyramid-Bloc/PyramidTreePlugin.class.st @@ -78,7 +78,9 @@ PyramidTreePlugin class >> columnZIndex: aPyramidTreePlugin [ ^ SpStringTableColumn new title: 'z'; evaluated: [ :aBlElement | - aBlElement elevation elevation printString ]; + aBlElement elevation elevation = 0 + ifTrue: [ '' ] + ifFalse: [ aBlElement elevation elevation printString ] ]; width: 16; yourself ] diff --git a/src/Pyramid-Bloc/PyramidTreePresenter.class.st b/src/Pyramid-Bloc/PyramidTreePresenter.class.st index b8a1a883..696dce0b 100644 --- a/src/Pyramid-Bloc/PyramidTreePresenter.class.st +++ b/src/Pyramid-Bloc/PyramidTreePresenter.class.st @@ -178,8 +178,21 @@ PyramidTreePresenter >> tree [ { #category : #'as yet unclassified' } PyramidTreePresenter >> updateRoots [ + | roots parent shouldOrder | self shouldUpdateSelection: false. - [ self tree roots: self projectModel firstLevelElements asArray ] ensure: [ + + roots := self projectModel roots asArray. + parent := nil. + + "If roots all have the same parent then it should be ordered by the parent children order." + shouldOrder := (roots allSatisfy: [ :each | + parent ifNil: [ parent := each parent ]. + each parent = parent ]) and: [ + parent notNil and: [ + parent childrenCount = roots size ] ]. + shouldOrder ifTrue: [ roots := parent children asArray ]. + + [ self tree roots: roots ] ensure: [ self shouldUpdateSelection: true ] ] diff --git a/src/Pyramid-Tests/PyramidChangeOrderWithIndexCommandTest.class.st b/src/Pyramid-Tests/PyramidChangeOrderWithIndexCommandTest.class.st new file mode 100644 index 00000000..3f304800 --- /dev/null +++ b/src/Pyramid-Tests/PyramidChangeOrderWithIndexCommandTest.class.st @@ -0,0 +1,96 @@ +Class { + #name : #PyramidChangeOrderWithIndexCommandTest, + #superclass : #TestCase, + #traits : 'TPyramidCommandTest', + #classTraits : 'TPyramidCommandTest classTrait', + #category : #'Pyramid-Tests-cases-plugin-bloc-order' +} + +{ #category : #accessing } +PyramidChangeOrderWithIndexCommandTest >> command [ + + ^ PyramidChangeOrderWithIndexCommand new +] + +{ #category : #'as yet unclassified' } +PyramidChangeOrderWithIndexCommandTest >> makeElementWithChildren [ + + | parent c1 c2 c3 | + parent := BlElement new + id: #parent; + yourself. + c1 := BlElement new + id: #c1; + yourself. + c2 := BlElement new + id: #c2; + yourself. + c3 := BlElement new + id: #c3; + yourself. + parent addChildren: { + c1. + c2. + c3 }. + ^ parent +] + +{ #category : #'as yet unclassified' } +PyramidChangeOrderWithIndexCommandTest >> targetContainers [ + + | test1 test2 test3 test4 test5 test6 | + test1 := self makeElementWithChildren. + test2 := self makeElementWithChildren. + test3 := self makeElementWithChildren. + test4 := self makeElementWithChildren. + test5 := self makeElementWithChildren. + test6 := self makeElementWithChildren. + + ^ { + (PyramidCommandTestContainer + no: (test1 childAt: 1) + with: 1 + prop: 1). + (PyramidCommandTestContainer + no: (test2 childAt: 1) + with: 1 + prop: 2). + (PyramidCommandTestContainer + no: (test3 childAt: 1) + with: 1 + prop: 3). + (PyramidCommandTestContainer + no: (test4 childAt: 3) + with: 3 + prop: 3). + (PyramidCommandTestContainer + no: (test5 childAt: 3) + with: 3 + prop: 2). + (PyramidCommandTestContainer + no: (test4 childAt: 3) + with: 3 + prop: 1) } +] + +{ #category : #'as yet unclassified' } +PyramidChangeOrderWithIndexCommandTest >> targetsCanBeUsedFor [ + + ^ self targetContainers flatCollect: [ :each | + { + each targetNoProp } ] +] + +{ #category : #accessing } +PyramidChangeOrderWithIndexCommandTest >> targetsWithValuesAndValues [ + + ^ self targetContainers collect: [ :each | + each targetNoProp -> each targetWithProp ] +] + +{ #category : #tests } +PyramidChangeOrderWithIndexCommandTest >> testGetValueFor [ + + self targetsWithValuesAndValues do: [ :each | + self assert: (self command getValueFor: each key) equals: each value ] +] diff --git a/src/Pyramid-Tests/PyramidMoveBackwardOrderCommandTest.class.st b/src/Pyramid-Tests/PyramidMoveBackwardOrderCommandTest.class.st new file mode 100644 index 00000000..beae1f5e --- /dev/null +++ b/src/Pyramid-Tests/PyramidMoveBackwardOrderCommandTest.class.st @@ -0,0 +1,129 @@ +Class { + #name : #PyramidMoveBackwardOrderCommandTest, + #superclass : #TestCase, + #traits : 'TPyramidCommandTest', + #classTraits : 'TPyramidCommandTest classTrait', + #category : #'Pyramid-Tests-cases-plugin-bloc-order' +} + +{ #category : #'as yet unclassified' } +PyramidMoveBackwardOrderCommandTest >> argumentsForHistory [ + + ^ { 3. 2. 1 } +] + +{ #category : #accessing } +PyramidMoveBackwardOrderCommandTest >> command [ + + ^ PyramidMoveBackwardOrderCommand new +] + +{ #category : #'as yet unclassified' } +PyramidMoveBackwardOrderCommandTest >> makeElementWithChildren [ + + | parent c1 c2 c3 | + parent := BlElement new id: #parent; yourself. + c1 := BlElement new id: #c1; yourself. + c2 := BlElement new id: #c2; yourself. + c3 := BlElement new id: #c3; yourself. + parent addChildren: { c1. c2 . c3 }. + ^ parent +] + +{ #category : #'as yet unclassified' } +PyramidMoveBackwardOrderCommandTest >> targetContainers [ + + | test1 test2 test3 | + test1 := self makeElementWithChildren. + test2 := self makeElementWithChildren. + test3 := self makeElementWithChildren. + + ^ { + (PyramidCommandTestContainer + no: (test1 childAt: 1) + with: 1 + prop: 1). + (PyramidCommandTestContainer + no: (test2 childAt: 2) + with: 1 + prop: 2). + (PyramidCommandTestContainer + no: (test3 childAt: 3) + with: 2 + prop: 3) } +] + +{ #category : #'as yet unclassified' } +PyramidMoveBackwardOrderCommandTest >> targetsCanBeUsedFor [ + + ^ self targetContainers flatCollect: [ :each | + { + each targetNoProp } ] +] + +{ #category : #'as yet unclassified' } +PyramidMoveBackwardOrderCommandTest >> targetsCannotBeUsedFor [ + "override if needed" + + ^ { nil. false. 0. $a . BlElement new } +] + +{ #category : #accessing } +PyramidMoveBackwardOrderCommandTest >> targetsWithValuesAndValues [ + + ^ self targetContainers collect: [ :each | + each targetNoProp -> each prop ] +] + +{ #category : #accessing } +PyramidMoveBackwardOrderCommandTest >> targetsWithoutValuesAndValues [ + + ^ self targetContainers collect: [ :each | + each targetNoProp -> each targetWithProp ] +] + +{ #category : #tests } +PyramidMoveBackwardOrderCommandTest >> testHistory [ + "Do once. + undo + redo + undo + redo" + + | history commandExecutor targets parent | + parent := self makeElementWithChildren. + targets := { (parent childAt: 3) }. + history := PyramidHistory new. + commandExecutor := PyramidHistoryCommandExecutor new + history: history; + wrappee: PyramidMainCommandExecutor new; + yourself. + + "Do once" + self argumentsForHistory do: [ :each | + commandExecutor use: self command on: targets with: each ]. + + "Undo all" + self argumentsForHistory reverseDo: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canUndo ifTrue: [ history undo ] ]. + + "Redo all" + self argumentsForHistory do: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canRedo ifTrue: [ history redo ] ]. + + "Undo all" + self argumentsForHistory reverseDo: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canUndo ifTrue: [ history undo ] ]. + + "Redo all" + self argumentsForHistory do: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canRedo ifTrue: [ history redo ] ] +] diff --git a/src/Pyramid-Tests/PyramidMoveForwardOrderCommandTest.class.st b/src/Pyramid-Tests/PyramidMoveForwardOrderCommandTest.class.st new file mode 100644 index 00000000..876ebefa --- /dev/null +++ b/src/Pyramid-Tests/PyramidMoveForwardOrderCommandTest.class.st @@ -0,0 +1,129 @@ +Class { + #name : #PyramidMoveForwardOrderCommandTest, + #superclass : #TestCase, + #traits : 'TPyramidCommandTest', + #classTraits : 'TPyramidCommandTest classTrait', + #category : #'Pyramid-Tests-cases-plugin-bloc-order' +} + +{ #category : #'as yet unclassified' } +PyramidMoveForwardOrderCommandTest >> argumentsForHistory [ + + ^ { 1 . 2 . 3 } +] + +{ #category : #accessing } +PyramidMoveForwardOrderCommandTest >> command [ + + ^ PyramidMoveForwardOrderCommand new +] + +{ #category : #'as yet unclassified' } +PyramidMoveForwardOrderCommandTest >> makeElementWithChildren [ + + | parent c1 c2 c3 | + parent := BlElement new id: #parent; yourself. + c1 := BlElement new id: #c1; yourself. + c2 := BlElement new id: #c2; yourself. + c3 := BlElement new id: #c3; yourself. + parent addChildren: { c1. c2 . c3 }. + ^ parent +] + +{ #category : #'as yet unclassified' } +PyramidMoveForwardOrderCommandTest >> targetContainers [ + + | test1 test2 test3 | + test1 := self makeElementWithChildren. + test2 := self makeElementWithChildren. + test3 := self makeElementWithChildren. + + ^ { + (PyramidCommandTestContainer + no: (test1 childAt: 1) + with: 2 + prop: 1). + (PyramidCommandTestContainer + no: (test2 childAt: 2) + with: 3 + prop: 2). + (PyramidCommandTestContainer + no: (test3 childAt: 3) + with: 3 + prop: 3) } +] + +{ #category : #'as yet unclassified' } +PyramidMoveForwardOrderCommandTest >> targetsCanBeUsedFor [ + + ^ self targetContainers flatCollect: [ :each | + { + each targetNoProp } ] +] + +{ #category : #'as yet unclassified' } +PyramidMoveForwardOrderCommandTest >> targetsCannotBeUsedFor [ + "override if needed" + + ^ { nil. false. 0. $a . BlElement new } +] + +{ #category : #accessing } +PyramidMoveForwardOrderCommandTest >> targetsWithValuesAndValues [ + + ^ self targetContainers collect: [ :each | + each targetNoProp -> each prop ] +] + +{ #category : #accessing } +PyramidMoveForwardOrderCommandTest >> targetsWithoutValuesAndValues [ + + ^ self targetContainers collect: [ :each | + each targetNoProp -> each targetWithProp ] +] + +{ #category : #tests } +PyramidMoveForwardOrderCommandTest >> testHistory [ + "Do once. + undo + redo + undo + redo" + + | history commandExecutor targets parent | + parent := self makeElementWithChildren. + targets := { (parent childAt: 1) }. + history := PyramidHistory new. + commandExecutor := PyramidHistoryCommandExecutor new + history: history; + wrappee: PyramidMainCommandExecutor new; + yourself. + + "Do once" + self argumentsForHistory do: [ :each | + commandExecutor use: self command on: targets with: each ]. + + "Undo all" + self argumentsForHistory reverseDo: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canUndo ifTrue: [ history undo ] ]. + + "Redo all" + self argumentsForHistory do: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canRedo ifTrue: [ history redo ].]. + + "Undo all" + self argumentsForHistory reverseDo: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canUndo ifTrue: [ history undo ] ]. + + "Redo all" + self argumentsForHistory do: [ :argument | + targets do: [ :target | + self assert: (self command getValueFor: target) equals: argument ]. + history canRedo ifTrue: [ history redo ]. ] +] diff --git a/src/Pyramid-Tests/PyramidOnBackgroundOrderCommandTest.class.st b/src/Pyramid-Tests/PyramidOnBackgroundOrderCommandTest.class.st new file mode 100644 index 00000000..0e57fc9e --- /dev/null +++ b/src/Pyramid-Tests/PyramidOnBackgroundOrderCommandTest.class.st @@ -0,0 +1,74 @@ +Class { + #name : #PyramidOnBackgroundOrderCommandTest, + #superclass : #TestCase, + #traits : 'TPyramidCommandTest', + #classTraits : 'TPyramidCommandTest classTrait', + #category : #'Pyramid-Tests-cases-plugin-bloc-order' +} + +{ #category : #accessing } +PyramidOnBackgroundOrderCommandTest >> command [ + + ^ PyramidOnBackgroundOrderCommand new +] + +{ #category : #'as yet unclassified' } +PyramidOnBackgroundOrderCommandTest >> makeElementWithChildren [ + + | parent c1 c2 c3 | + parent := BlElement new + id: #parent; + yourself. + c1 := BlElement new + id: #c1; + yourself. + c2 := BlElement new + id: #c2; + yourself. + c3 := BlElement new + id: #c3; + yourself. + parent addChildren: { + c1. + c2. + c3 }. + ^ parent +] + +{ #category : #'as yet unclassified' } +PyramidOnBackgroundOrderCommandTest >> targetContainers [ + + | test1 test2 test3 | + test1 := self makeElementWithChildren. + test2 := self makeElementWithChildren. + test3 := self makeElementWithChildren. + + ^ { + (PyramidCommandTestContainer + no: (test1 childAt: 1) + with: 1 + prop: 1). + (PyramidCommandTestContainer + no: (test2 childAt: 2) + with: 2 + prop: 1). + (PyramidCommandTestContainer + no: (test3 childAt: 3) + with: 3 + prop: 1) } +] + +{ #category : #'as yet unclassified' } +PyramidOnBackgroundOrderCommandTest >> targetsCanBeUsedFor [ + + ^ self targetContainers flatCollect: [ :each | + { + each targetNoProp } ] +] + +{ #category : #accessing } +PyramidOnBackgroundOrderCommandTest >> targetsWithValuesAndValues [ + + ^ self targetContainers collect: [ :each | + each targetNoProp -> each targetWithProp ] +] diff --git a/src/Pyramid-Tests/PyramidOnForegroundOrderCommandTest.class.st b/src/Pyramid-Tests/PyramidOnForegroundOrderCommandTest.class.st new file mode 100644 index 00000000..dfd10ec8 --- /dev/null +++ b/src/Pyramid-Tests/PyramidOnForegroundOrderCommandTest.class.st @@ -0,0 +1,74 @@ +Class { + #name : #PyramidOnForegroundOrderCommandTest, + #superclass : #TestCase, + #traits : 'TPyramidCommandTest', + #classTraits : 'TPyramidCommandTest classTrait', + #category : #'Pyramid-Tests-cases-plugin-bloc-order' +} + +{ #category : #accessing } +PyramidOnForegroundOrderCommandTest >> command [ + + ^ PyramidOnForegroundOrderCommand new +] + +{ #category : #'as yet unclassified' } +PyramidOnForegroundOrderCommandTest >> makeElementWithChildren [ + + | parent c1 c2 c3 | + parent := BlElement new + id: #parent; + yourself. + c1 := BlElement new + id: #c1; + yourself. + c2 := BlElement new + id: #c2; + yourself. + c3 := BlElement new + id: #c3; + yourself. + parent addChildren: { + c1. + c2. + c3 }. + ^ parent +] + +{ #category : #'as yet unclassified' } +PyramidOnForegroundOrderCommandTest >> targetContainers [ + + | test1 test2 test3 | + test1 := self makeElementWithChildren. + test2 := self makeElementWithChildren. + test3 := self makeElementWithChildren. + + ^ { + (PyramidCommandTestContainer + no: (test1 childAt: 1) + with: 1 + prop: 3). + (PyramidCommandTestContainer + no: (test2 childAt: 2) + with: 2 + prop: 3). + (PyramidCommandTestContainer + no: (test3 childAt: 3) + with: 3 + prop: 3) } +] + +{ #category : #'as yet unclassified' } +PyramidOnForegroundOrderCommandTest >> targetsCanBeUsedFor [ + + ^ self targetContainers flatCollect: [ :each | + { + each targetNoProp } ] +] + +{ #category : #accessing } +PyramidOnForegroundOrderCommandTest >> targetsWithValuesAndValues [ + + ^ self targetContainers collect: [ :each | + each targetNoProp -> each targetWithProp ] +] diff --git a/src/Pyramid-Tests/PyramidSendAtIndexCommandTest.class.st b/src/Pyramid-Tests/PyramidSendAtIndexCommandTest.class.st deleted file mode 100644 index f8e6efc7..00000000 --- a/src/Pyramid-Tests/PyramidSendAtIndexCommandTest.class.st +++ /dev/null @@ -1,106 +0,0 @@ -Class { - #name : #PyramidSendAtIndexCommandTest, - #superclass : #TestCase, - #traits : 'TPyramidCommandTest', - #classTraits : 'TPyramidCommandTest classTrait', - #category : #'Pyramid-Tests-cases-plugin-bloc-siblings' -} - -{ #category : #accessing } -PyramidSendAtIndexCommandTest >> command [ - - ^ PyramidSendAtIndexCommand new -] - -{ #category : #'as yet unclassified' } -PyramidSendAtIndexCommandTest >> targetContainers [ - - | parent1 a1 a2 a3 a4 b1 b2 b3 b4 parent2 | - parent1 := BlElement new - id: #parent1; - yourself. - a1 := BlElement new - id: #a1; - zIndex: 0; - yourself. - a2 := BlElement new - id: #a2; - zIndex: 2; - yourself. - a3 := BlElement new - id: #a3; - zIndex: 3; - yourself. - a4 := BlElement new - id: #a4; - zIndex: 4; - yourself. - parent1 addChildren: { - a1. - a2. - a3. - a4 }. - - parent2 := BlElement new - id: #parent2; - yourself. - b1 := BlElement new - id: #b1; - zIndex: 40; - yourself. - b2 := BlElement new - id: #b2; - zIndex: 42; - yourself. - b3 := BlElement new - id: #b3; - zIndex: 43; - yourself. - b4 := BlElement new - id: #b4; - zIndex: 44; - yourself. - parent2 addChildren: { - b1. - b3. - b2. - b4 }. - - ^ { - (PyramidCommandTestContainer - no: b1 - with: a1 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 1; - zIndex: 0)). - (PyramidCommandTestContainer - no: b2 - with: a2 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 2; - zIndex: 2)). - (PyramidCommandTestContainer - no: b3 - with: a3 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 3; - zIndex: 3)). - (PyramidCommandTestContainer - no: b4 - with: a4 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 4; - zIndex: 4)) } -] - -{ #category : #'as yet unclassified' } -PyramidSendAtIndexCommandTest >> targetsCannotBeUsedFor [ - "override if needed" - - ^ { - nil. - false. - 0. - $a. - BlElement new } -] diff --git a/src/Pyramid-Tests/PyramidSendBottomCommandTest.class.st b/src/Pyramid-Tests/PyramidSendBottomCommandTest.class.st deleted file mode 100644 index a8558066..00000000 --- a/src/Pyramid-Tests/PyramidSendBottomCommandTest.class.st +++ /dev/null @@ -1,87 +0,0 @@ -Class { - #name : #PyramidSendBottomCommandTest, - #superclass : #TestCase, - #traits : 'TPyramidCommandTest', - #classTraits : 'TPyramidCommandTest classTrait', - #category : #'Pyramid-Tests-cases-plugin-bloc-siblings' -} - -{ #category : #accessing } -PyramidSendBottomCommandTest >> command [ - - ^ PyramidSendBottomCommand new -] - -{ #category : #'as yet unclassified' } -PyramidSendBottomCommandTest >> targetContainers [ - - | parent1 a1 a2 a3 a4 b1 b2 b3 b4 parent2 | - parent1 := BlElement new - id: #parent1; - yourself. - a1 := BlElement new - id: #a1; - zIndex: 0; - yourself. - a2 := BlElement new - id: #a2; - zIndex: 0; - yourself. - a3 := BlElement new - id: #a3; - zIndex: 2; - yourself. - a4 := BlElement new - id: #a4; - zIndex: 2; - yourself. - parent1 addChildren: { - a1. - a2. - a3. - a4 }. - - parent2 := BlElement new - id: #parent2; - yourself. - b1 := BlElement new - id: #b1; - zIndex: 0; - yourself. - b2 := BlElement new - id: #b2; - zIndex: 0; - yourself. - b3 := BlElement new - id: #b3; - zIndex: 2; - yourself. - b4 := BlElement new - id: #b4; - zIndex: 2; - yourself. - parent2 addChildren: { - b1. - b2. - b3. - b4 }. - - ^ { (PyramidCommandTestContainer - no: b4 - with: a4 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 1; - zIndex: 0)) } -] - -{ #category : #'as yet unclassified' } -PyramidSendBottomCommandTest >> targetsCannotBeUsedFor [ - "override if needed" - - ^ { - nil. - false. - 0. - $a. - BlElement new } -] diff --git a/src/Pyramid-Tests/PyramidSendDownCommandTest.class.st b/src/Pyramid-Tests/PyramidSendDownCommandTest.class.st deleted file mode 100644 index ad96fab4..00000000 --- a/src/Pyramid-Tests/PyramidSendDownCommandTest.class.st +++ /dev/null @@ -1,87 +0,0 @@ -Class { - #name : #PyramidSendDownCommandTest, - #superclass : #TestCase, - #traits : 'TPyramidCommandTest', - #classTraits : 'TPyramidCommandTest classTrait', - #category : #'Pyramid-Tests-cases-plugin-bloc-siblings' -} - -{ #category : #accessing } -PyramidSendDownCommandTest >> command [ - - ^ PyramidSendDownCommand new -] - -{ #category : #'as yet unclassified' } -PyramidSendDownCommandTest >> targetContainers [ - - | parent1 a1 a2 a3 a4 b1 b2 b3 b4 parent2 | - parent1 := BlElement new - id: #parent1; - yourself. - a1 := BlElement new - id: #a1; - zIndex: 0; - yourself. - a2 := BlElement new - id: #a2; - zIndex: 0; - yourself. - a3 := BlElement new - id: #a3; - zIndex: 2; - yourself. - a4 := BlElement new - id: #a4; - zIndex: 2; - yourself. - parent1 addChildren: { - a1. - a2. - a3. - a4 }. - - parent2 := BlElement new - id: #parent2; - yourself. - b1 := BlElement new - id: #b1; - zIndex: 0; - yourself. - b2 := BlElement new - id: #b2; - zIndex: 0; - yourself. - b3 := BlElement new - id: #b3; - zIndex: 2; - yourself. - b4 := BlElement new - id: #b4; - zIndex: 2; - yourself. - parent2 addChildren: { - b1. - b2. - b3. - b4 }. - - ^ { (PyramidCommandTestContainer - no: b3 - with: a3 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 0; - zIndex: 2)) } -] - -{ #category : #'as yet unclassified' } -PyramidSendDownCommandTest >> targetsCannotBeUsedFor [ - "override if needed" - - ^ { - nil. - false. - 0. - $a. - BlElement new } -] diff --git a/src/Pyramid-Tests/PyramidSendTopCommandTest.class.st b/src/Pyramid-Tests/PyramidSendTopCommandTest.class.st deleted file mode 100644 index fa09918e..00000000 --- a/src/Pyramid-Tests/PyramidSendTopCommandTest.class.st +++ /dev/null @@ -1,87 +0,0 @@ -Class { - #name : #PyramidSendTopCommandTest, - #superclass : #TestCase, - #traits : 'TPyramidCommandTest', - #classTraits : 'TPyramidCommandTest classTrait', - #category : #'Pyramid-Tests-cases-plugin-bloc-siblings' -} - -{ #category : #accessing } -PyramidSendTopCommandTest >> command [ - - ^ PyramidSendTopCommand new -] - -{ #category : #'as yet unclassified' } -PyramidSendTopCommandTest >> targetContainers [ - - | parent1 a1 a2 a3 a4 b1 b2 b3 b4 parent2 | - parent1 := BlElement new - id: #parent1; - yourself. - a1 := BlElement new - id: #a1; - zIndex: 0; - yourself. - a2 := BlElement new - id: #a2; - zIndex: 0; - yourself. - a3 := BlElement new - id: #a3; - zIndex: 2; - yourself. - a4 := BlElement new - id: #a4; - zIndex: 2; - yourself. - parent1 addChildren: { - a1. - a2. - a3. - a4 }. - - parent2 := BlElement new - id: #parent2; - yourself. - b1 := BlElement new - id: #b1; - zIndex: 0; - yourself. - b2 := BlElement new - id: #b2; - zIndex: 0; - yourself. - b3 := BlElement new - id: #b3; - zIndex: 2; - yourself. - b4 := BlElement new - id: #b4; - zIndex: 2; - yourself. - parent2 addChildren: { - b1. - b2. - b3. - b4 }. - - ^ { (PyramidCommandTestContainer - no: b1 - with: a1 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 4; - zIndex: 2)) } -] - -{ #category : #'as yet unclassified' } -PyramidSendTopCommandTest >> targetsCannotBeUsedFor [ - "override if needed" - - ^ { - nil. - false. - 0. - $a. - BlElement new } -] diff --git a/src/Pyramid-Tests/PyramidSendUpCommandTest.class.st b/src/Pyramid-Tests/PyramidSendUpCommandTest.class.st deleted file mode 100644 index 0f1ff713..00000000 --- a/src/Pyramid-Tests/PyramidSendUpCommandTest.class.st +++ /dev/null @@ -1,87 +0,0 @@ -Class { - #name : #PyramidSendUpCommandTest, - #superclass : #TestCase, - #traits : 'TPyramidCommandTest', - #classTraits : 'TPyramidCommandTest classTrait', - #category : #'Pyramid-Tests-cases-plugin-bloc-siblings' -} - -{ #category : #accessing } -PyramidSendUpCommandTest >> command [ - - ^ PyramidSendUpCommand new -] - -{ #category : #'as yet unclassified' } -PyramidSendUpCommandTest >> targetContainers [ - - | parent1 a1 a2 a3 a4 b1 b2 b3 b4 parent2 | - parent1 := BlElement new - id: #parent1; - yourself. - a1 := BlElement new - id: #a1; - zIndex: 0; - yourself. - a2 := BlElement new - id: #a2; - zIndex: 0; - yourself. - a3 := BlElement new - id: #a3; - zIndex: 2; - yourself. - a4 := BlElement new - id: #a4; - zIndex: 2; - yourself. - parent1 addChildren: { - a1. - a2. - a3. - a4 }. - - parent2 := BlElement new - id: #parent2; - yourself. - b1 := BlElement new - id: #b1; - zIndex: 0; - yourself. - b2 := BlElement new - id: #b2; - zIndex: 0; - yourself. - b3 := BlElement new - id: #b3; - zIndex: 2; - yourself. - b4 := BlElement new - id: #b4; - zIndex: 2; - yourself. - parent2 addChildren: { - b1. - b2. - b3. - b4 }. - - ^ { (PyramidCommandTestContainer - no: b2 - with: a1 - prop: (PyramidChangePositionWithSiblingsModel new - childIndex: 3; - zIndex: 2)) } -] - -{ #category : #'as yet unclassified' } -PyramidSendUpCommandTest >> targetsCannotBeUsedFor [ - "override if needed" - - ^ { - nil. - false. - 0. - $a. - BlElement new } -] diff --git a/src/Pyramid/PyramidCommand.class.st b/src/Pyramid/PyramidCommand.class.st index bdbd74bd..e502872e 100644 --- a/src/Pyramid/PyramidCommand.class.st +++ b/src/Pyramid/PyramidCommand.class.st @@ -52,7 +52,10 @@ PyramidCommand >> getValueFor: anObject [ { #category : #'as yet unclassified' } PyramidCommand >> saveStatesOf: aCollection with: arguments [ - ^ self saveStatesOf: aCollection withCommand: self withArguments: arguments + ^ self + saveStatesOf: aCollection + withCommand: self + withArguments: arguments ] { #category : #'as yet unclassified' }