From 9cf2f07a9c792e12a9abdbb7b57d90b02a2e075d Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 16:43:23 +0100 Subject: [PATCH 01/10] Add frame constraints --- .../BlBottomAlignment.extension.st | 9 + .../BlHorizontalCenterAlignment.extension.st | 9 + ...izontalCoordinateEndAlignment.extension.st | 9 + ...zontalCoordinateLeftAlignment.extension.st | 11 + ...ontalCoordinateRightAlignment.extension.st | 9 + ...ontalCoordinateStartAlignment.extension.st | 9 + .../BlHorizontalEndAlignment.extension.st | 9 + .../BlHorizontalStartAlignment.extension.st | 9 + .../BlNullHorizontalAlignment.extension.st | 9 + .../BlNullVerticalAlignment.extension.st | 9 + src/Pyramid-Bloc/BlTopAlignment.extension.st | 9 + .../BlVerticalCenterAlignment.extension.st | 9 + ...icalCoordinateBottomAlignment.extension.st | 9 + ...erticalCoordinateTopAlignment.extension.st | 9 + ...actFrameConstraintsInputPresenter.class.st | 266 ++++++++++++++++++ src/Pyramid-Bloc/PyramidBlocPlugin.class.st | 39 ++- .../PyramidFrameConstraintsCommand.class.st | 13 + ...FrameHorizontalConstraintsCommand.class.st | 18 ++ ...idFrameVerticalConstraintsCommand.class.st | 18 ++ ...talFrameConstraintsInputPresenter.class.st | 77 +++++ ...calFrameConstraintsInputPresenter.class.st | 78 +++++ 21 files changed, 633 insertions(+), 4 deletions(-) create mode 100644 src/Pyramid-Bloc/BlBottomAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlHorizontalCenterAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlHorizontalCoordinateEndAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlHorizontalCoordinateLeftAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlHorizontalCoordinateRightAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlHorizontalCoordinateStartAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlHorizontalEndAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlHorizontalStartAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlNullHorizontalAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlNullVerticalAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlTopAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlVerticalCenterAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlVerticalCoordinateBottomAlignment.extension.st create mode 100644 src/Pyramid-Bloc/BlVerticalCoordinateTopAlignment.extension.st create mode 100644 src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st create mode 100644 src/Pyramid-Bloc/PyramidFrameConstraintsCommand.class.st create mode 100644 src/Pyramid-Bloc/PyramidFrameHorizontalConstraintsCommand.class.st create mode 100644 src/Pyramid-Bloc/PyramidFrameVerticalConstraintsCommand.class.st create mode 100644 src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st create mode 100644 src/Pyramid-Bloc/PyramidVerticalFrameConstraintsInputPresenter.class.st diff --git a/src/Pyramid-Bloc/BlBottomAlignment.extension.st b/src/Pyramid-Bloc/BlBottomAlignment.extension.st new file mode 100644 index 00000000..2683598c --- /dev/null +++ b/src/Pyramid-Bloc/BlBottomAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlBottomAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlBottomAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectEnd. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlHorizontalCenterAlignment.extension.st b/src/Pyramid-Bloc/BlHorizontalCenterAlignment.extension.st new file mode 100644 index 00000000..0c592c15 --- /dev/null +++ b/src/Pyramid-Bloc/BlHorizontalCenterAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlHorizontalCenterAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlHorizontalCenterAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectCenter. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlHorizontalCoordinateEndAlignment.extension.st b/src/Pyramid-Bloc/BlHorizontalCoordinateEndAlignment.extension.st new file mode 100644 index 00000000..e5ba3cff --- /dev/null +++ b/src/Pyramid-Bloc/BlHorizontalCoordinateEndAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlHorizontalCoordinateEndAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlHorizontalCoordinateEndAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectCenter. + aFrameConstraintsPresenter inputHasRelative state: true. + aFrameConstraintsPresenter inputRelative value: self coordinate negated +] diff --git a/src/Pyramid-Bloc/BlHorizontalCoordinateLeftAlignment.extension.st b/src/Pyramid-Bloc/BlHorizontalCoordinateLeftAlignment.extension.st new file mode 100644 index 00000000..a1e09b0a --- /dev/null +++ b/src/Pyramid-Bloc/BlHorizontalCoordinateLeftAlignment.extension.st @@ -0,0 +1,11 @@ +Extension { #name : #BlHorizontalCoordinateLeftAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlHorizontalCoordinateLeftAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectStart. + aFrameConstraintsPresenter inputHasRelative + state: true. + aFrameConstraintsPresenter inputRelative + value: self coordinate +] diff --git a/src/Pyramid-Bloc/BlHorizontalCoordinateRightAlignment.extension.st b/src/Pyramid-Bloc/BlHorizontalCoordinateRightAlignment.extension.st new file mode 100644 index 00000000..e9f5b757 --- /dev/null +++ b/src/Pyramid-Bloc/BlHorizontalCoordinateRightAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlHorizontalCoordinateRightAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlHorizontalCoordinateRightAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectEnd. + aFrameConstraintsPresenter inputHasRelative state: true. + aFrameConstraintsPresenter inputRelative value: self coordinate +] diff --git a/src/Pyramid-Bloc/BlHorizontalCoordinateStartAlignment.extension.st b/src/Pyramid-Bloc/BlHorizontalCoordinateStartAlignment.extension.st new file mode 100644 index 00000000..b571a509 --- /dev/null +++ b/src/Pyramid-Bloc/BlHorizontalCoordinateStartAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlHorizontalCoordinateStartAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlHorizontalCoordinateStartAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectCenter. + aFrameConstraintsPresenter inputHasRelative state: true. + aFrameConstraintsPresenter inputRelative value: self coordinate +] diff --git a/src/Pyramid-Bloc/BlHorizontalEndAlignment.extension.st b/src/Pyramid-Bloc/BlHorizontalEndAlignment.extension.st new file mode 100644 index 00000000..39362c5e --- /dev/null +++ b/src/Pyramid-Bloc/BlHorizontalEndAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlHorizontalEndAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlHorizontalEndAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectEnd. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlHorizontalStartAlignment.extension.st b/src/Pyramid-Bloc/BlHorizontalStartAlignment.extension.st new file mode 100644 index 00000000..0b37baf7 --- /dev/null +++ b/src/Pyramid-Bloc/BlHorizontalStartAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlHorizontalStartAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlHorizontalStartAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectStart. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlNullHorizontalAlignment.extension.st b/src/Pyramid-Bloc/BlNullHorizontalAlignment.extension.st new file mode 100644 index 00000000..c23a7bf5 --- /dev/null +++ b/src/Pyramid-Bloc/BlNullHorizontalAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlNullHorizontalAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlNullHorizontalAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectNull. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlNullVerticalAlignment.extension.st b/src/Pyramid-Bloc/BlNullVerticalAlignment.extension.st new file mode 100644 index 00000000..73f64c9b --- /dev/null +++ b/src/Pyramid-Bloc/BlNullVerticalAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlNullVerticalAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlNullVerticalAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectNull. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlTopAlignment.extension.st b/src/Pyramid-Bloc/BlTopAlignment.extension.st new file mode 100644 index 00000000..4a7ea7ef --- /dev/null +++ b/src/Pyramid-Bloc/BlTopAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlTopAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlTopAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectStart. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlVerticalCenterAlignment.extension.st b/src/Pyramid-Bloc/BlVerticalCenterAlignment.extension.st new file mode 100644 index 00000000..9892aa8d --- /dev/null +++ b/src/Pyramid-Bloc/BlVerticalCenterAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlVerticalCenterAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlVerticalCenterAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectCenter. + aFrameConstraintsPresenter inputHasRelative state: false. + aFrameConstraintsPresenter inputRelative value: 0 +] diff --git a/src/Pyramid-Bloc/BlVerticalCoordinateBottomAlignment.extension.st b/src/Pyramid-Bloc/BlVerticalCoordinateBottomAlignment.extension.st new file mode 100644 index 00000000..fcb941ef --- /dev/null +++ b/src/Pyramid-Bloc/BlVerticalCoordinateBottomAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlVerticalCoordinateBottomAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlVerticalCoordinateBottomAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectEnd. + aFrameConstraintsPresenter inputHasRelative state: true. + aFrameConstraintsPresenter inputRelative value: self coordinate +] diff --git a/src/Pyramid-Bloc/BlVerticalCoordinateTopAlignment.extension.st b/src/Pyramid-Bloc/BlVerticalCoordinateTopAlignment.extension.st new file mode 100644 index 00000000..9efda788 --- /dev/null +++ b/src/Pyramid-Bloc/BlVerticalCoordinateTopAlignment.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #BlVerticalCoordinateTopAlignment } + +{ #category : #'*Pyramid-Bloc' } +BlVerticalCoordinateTopAlignment >> pyramidSelectOn: aFrameConstraintsPresenter [ + + aFrameConstraintsPresenter selectStart. + aFrameConstraintsPresenter inputHasRelative state: true. + aFrameConstraintsPresenter inputRelative value: self coordinate +] diff --git a/src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st b/src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st new file mode 100644 index 00000000..940c89b7 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st @@ -0,0 +1,266 @@ +Class { + #name : #PyramidAbstractFrameConstraintsInputPresenter, + #superclass : #PyramidInputPresenter, + #instVars : [ + 'buttonNull', + 'buttonStart', + 'buttonCenter', + 'buttonEnd', + 'inputHasRelative', + 'inputRelative', + 'whenValueChangedDo', + 'shouldTrigger' + ], + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #testing } +PyramidAbstractFrameConstraintsInputPresenter class >> isAbstract [ + + ^ self == PyramidAbstractFrameConstraintsInputPresenter +] + +{ #category : #layout } +PyramidAbstractFrameConstraintsInputPresenter >> buttonCenter [ + + ^ buttonCenter +] + +{ #category : #layout } +PyramidAbstractFrameConstraintsInputPresenter >> buttonEnd [ + + ^ buttonEnd +] + +{ #category : #layout } +PyramidAbstractFrameConstraintsInputPresenter >> buttonNull [ + + ^ buttonNull +] + +{ #category : #layout } +PyramidAbstractFrameConstraintsInputPresenter >> buttonStart [ + ^ buttonStart +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> connectPresenters [ + + self inputHasRelative whenChangedDo: [ :aBoolean | + self inputRelative enabled: aBoolean. + self triggerValueChanged ]. + self inputRelative whenValueChangedDo: [ :aValue | + self whenValueChangedDo value: self value ]. + self buttonNull action: [ + self selectNull. + self triggerValueChanged ]. + self buttonStart action: [ + self selectStart. + self triggerValueChanged ]. + self buttonCenter action: [ + self selectCenter. + self triggerValueChanged ]. + self buttonEnd action: [ + self selectEnd. + self triggerValueChanged. ] +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> currentRelativeValue [ + + ^ self inputRelative value isNumber ifTrue: [ ^ self inputRelative value ] ifFalse: [ ^ 0 ] +] + +{ #category : #layout } +PyramidAbstractFrameConstraintsInputPresenter >> defaultLayout [ + + ^ SpBoxLayout newHorizontal + spacing: 4; + add: self buttonNull withConstraints: [ :c | c width: 32 ]; + add: self buttonStart withConstraints: [ :c | c width: 32 ]; + add: self buttonCenter withConstraints: [ :c | c width: 32 ]; + add: self buttonEnd withConstraints: [ :c | c width: 32 ]; + add: self inputHasRelative withConstraints: [ :c | c width: 64 ]; + add: self inputRelative expand: true; + yourself +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> doNotTriggerWhile: aBlock [ + + self shouldTrigger: false. + aBlock value. + self shouldTrigger: true. +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> helpCenter [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> helpEnd [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> helpNull [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> helpStart [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> iconCenter [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> iconEnd [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> iconNull [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> iconStart [ + + ^ self shouldBeImplemented +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> initialize [ + + super initialize. + whenValueChangedDo := [ :newVal ] +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> initializePresenters [ + + buttonNull := SpButtonPresenter new + icon: self iconNull; + help: self helpNull; + yourself. + buttonStart := SpButtonPresenter new + icon: self iconStart; + help: self helpStart; + yourself. + buttonCenter := SpButtonPresenter new + icon: self iconCenter; + help: self helpCenter; + yourself. + buttonEnd := SpButtonPresenter new + icon: self iconEnd; + help: self helpEnd; + yourself. + inputHasRelative := SpCheckBoxPresenter new + label: 'at:'; + state: true; + yourself. + inputRelative := PyramidNumberInputPresenter new value: 0; yourself +] + +{ #category : #layout } +PyramidAbstractFrameConstraintsInputPresenter >> inputHasRelative [ + + ^ inputHasRelative +] + +{ #category : #layout } +PyramidAbstractFrameConstraintsInputPresenter >> inputRelative [ + + ^ inputRelative +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> selectCenter [ + self buttonNull state: false. + self buttonStart state: false. + self buttonCenter state: true. + self buttonEnd state: false. + +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> selectEnd [ + self buttonNull state: false. + self buttonStart state: false. + self buttonCenter state: false. + self buttonEnd state: true. + +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> selectNull [. + self buttonNull state: true. + self buttonStart state: false. + self buttonCenter state: false. + self buttonEnd state: false. + +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> selectStart [. + self buttonNull state: false. + self buttonStart state: true. + self buttonCenter state: false. + self buttonEnd state: false. + +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> shouldTrigger [ + + ^ shouldTrigger +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> shouldTrigger: aBoolean [ +shouldTrigger:=aBoolean +] + +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> triggerValueChanged [ + + self shouldTrigger ifFalse: [ ^ self ]. + self whenValueChangedDo value: self value +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> value [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> value: aValue [ + + self doNotTriggerWhile: [ aValue pyramidSelectOn: self ] + +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> whenValueChangedDo [ + + ^ whenValueChangedDo +] + +{ #category : #'as yet unclassified' } +PyramidAbstractFrameConstraintsInputPresenter >> whenValueChangedDo: aBlock [ + + whenValueChangedDo := aBlock. +] diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index a6f8b8a9..ec046112 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -101,12 +101,38 @@ PyramidBlocPlugin class >> constraintsBasicVExact [ ^ property ] +{ #category : #accessing } +PyramidBlocPlugin class >> constraintsFrameH [ + + | property | + property := PyramidProperty new + name: 'Constraints - Frame - horizontal'; + command: PyramidFrameHorizontalConstraintsCommand new; + pyramidInputPresenterClass: + PyramidHorizontalFrameConstraintsInputPresenter; + yourself. + ^ property +] + +{ #category : #accessing } +PyramidBlocPlugin class >> constraintsFrameV [ + + | property | + property := PyramidProperty new + name: 'Constraints - Frame - vertical'; + command: PyramidFrameVerticalConstraintsCommand new; + pyramidInputPresenterClass: + PyramidVerticalFrameConstraintsInputPresenter; + yourself. + ^ property +] + { #category : #accessing } PyramidBlocPlugin class >> constraintsPropH [ | property | property := PyramidProperty new - name: 'Constraints - horizontal'; + name: 'Constraints - Proportionnal - horizontal'; command: PyramidProportionnalHorizontalConstraintsCommand new; pyramidInputPresenterClass: PyramidPointInputPresenter; @@ -123,7 +149,7 @@ PyramidBlocPlugin class >> constraintsPropV [ | property | property := PyramidProperty new - name: 'Constraints - vertical'; + name: 'Constraints - Proportionnal - vertical'; command: PyramidProportionnalVerticalConstraintsCommand new; pyramidInputPresenterClass: PyramidPointInputPresenter; @@ -306,11 +332,14 @@ PyramidBlocPlugin >> connectOn: aPyramidEditor [ aPyramidEditor propertiesManager addProperty: self class geometry. aPyramidEditor propertiesManager addProperty: self class cornerRadii. aPyramidEditor propertiesManager addProperty: self class position. - + aPyramidEditor propertiesManager addProperty: self class layout. - aPyramidEditor propertiesManager addProperty: self class flowLayoutOrientation. + aPyramidEditor propertiesManager addProperty: + self class flowLayoutOrientation. "Constraints - horizontal" + aPyramidEditor propertiesManager addProperty: + self class constraintsFrameH. aPyramidEditor propertiesManager addProperty: self class constraintsPropH. aPyramidEditor propertiesManager addProperty: @@ -319,6 +348,8 @@ PyramidBlocPlugin >> connectOn: aPyramidEditor [ self class constraintsBasicHExact. "Constraints - vertical" + aPyramidEditor propertiesManager addProperty: + self class constraintsFrameV. aPyramidEditor propertiesManager addProperty: self class constraintsPropV. aPyramidEditor propertiesManager addProperty: diff --git a/src/Pyramid-Bloc/PyramidFrameConstraintsCommand.class.st b/src/Pyramid-Bloc/PyramidFrameConstraintsCommand.class.st new file mode 100644 index 00000000..97c01b99 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidFrameConstraintsCommand.class.st @@ -0,0 +1,13 @@ +Class { + #name : #PyramidFrameConstraintsCommand, + #superclass : #PyramidAbstractBlocCommand, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #testing } +PyramidFrameConstraintsCommand >> canBeUsedFor: anObject [ + + ^ (super canBeUsedFor: anObject) and: [ + anObject hasParent and: [ + BlFrameLayout = anObject parent layout class ] ] +] diff --git a/src/Pyramid-Bloc/PyramidFrameHorizontalConstraintsCommand.class.st b/src/Pyramid-Bloc/PyramidFrameHorizontalConstraintsCommand.class.st new file mode 100644 index 00000000..271f6c0e --- /dev/null +++ b/src/Pyramid-Bloc/PyramidFrameHorizontalConstraintsCommand.class.st @@ -0,0 +1,18 @@ +Class { + #name : #PyramidFrameHorizontalConstraintsCommand, + #superclass : #PyramidFrameConstraintsCommand, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #'as yet unclassified' } +PyramidFrameHorizontalConstraintsCommand >> getValueFor: anObject [ + + ^ anObject constraints frame horizontal alignment +] + +{ #category : #'as yet unclassified' } +PyramidFrameHorizontalConstraintsCommand >> setValueFor: anObject with: anArgument [ + + anObject constraintsDo: [ :c | + c frame horizontal alignment: anArgument. ] +] diff --git a/src/Pyramid-Bloc/PyramidFrameVerticalConstraintsCommand.class.st b/src/Pyramid-Bloc/PyramidFrameVerticalConstraintsCommand.class.st new file mode 100644 index 00000000..99b53c7a --- /dev/null +++ b/src/Pyramid-Bloc/PyramidFrameVerticalConstraintsCommand.class.st @@ -0,0 +1,18 @@ +Class { + #name : #PyramidFrameVerticalConstraintsCommand, + #superclass : #PyramidFrameConstraintsCommand, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #'as yet unclassified' } +PyramidFrameVerticalConstraintsCommand >> getValueFor: anObject [ + + ^ anObject constraints frame vertical alignment +] + +{ #category : #'as yet unclassified' } +PyramidFrameVerticalConstraintsCommand >> setValueFor: anObject with: anArgument [ + + anObject constraintsDo: [ :c | + c frame vertical alignment: anArgument ] +] diff --git a/src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st b/src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st new file mode 100644 index 00000000..7b102f45 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st @@ -0,0 +1,77 @@ +Class { + #name : #PyramidHorizontalFrameConstraintsInputPresenter, + #superclass : #PyramidAbstractFrameConstraintsInputPresenter, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> helpCenter [ + + ^ 'Align the horizontal axis on the center of the shape.' +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> helpEnd [ + + ^ 'Align on the Right border.' +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> helpNull [ + + ^ 'Do not align horizontaly.' +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> helpStart [ + + ^ 'Align on the Left border.' +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> iconCenter [ + + ^ (self iconNamed: #windowMinimize) rotateBy: #left centerAt: 8 @ 8 +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> iconEnd [ + + ^( self iconNamed: #windowMenu) rotateBy: -90 +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> iconNull [ + + ^ self iconNamed: #windowMaximize +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> iconStart [ + + ^ (self iconNamed: #windowMenu) rotateBy: 90 +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenter >> value [ + + self buttonNull state ifTrue: [ ^ BlHorizontalAlignment null ]. + self inputHasRelative state + ifTrue: [ + self buttonStart state ifTrue: [ + ^ (BlFrameLayoutConstraintsHorizontal new alignLeftAt: + self currentRelativeValue) alignment ]. + self buttonCenter state ifTrue: [ + ^ (BlFrameLayoutConstraintsHorizontal new alignCenterAt: + self currentRelativeValue) alignment ]. + self buttonEnd state ifTrue: [ + ^ (BlFrameLayoutConstraintsHorizontal new alignRightAt: + self currentRelativeValue) alignment ] ] + ifFalse: [ + self buttonStart state ifTrue: [ + ^ BlFrameLayoutConstraintsHorizontal new alignLeft alignment ]. + self buttonCenter state ifTrue: [ + ^ BlFrameLayoutConstraintsHorizontal new alignCenter alignment ]. + self buttonEnd state ifTrue: [ + ^ BlFrameLayoutConstraintsHorizontal new alignRight alignment ] ] +] diff --git a/src/Pyramid-Bloc/PyramidVerticalFrameConstraintsInputPresenter.class.st b/src/Pyramid-Bloc/PyramidVerticalFrameConstraintsInputPresenter.class.st new file mode 100644 index 00000000..e4a36d60 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidVerticalFrameConstraintsInputPresenter.class.st @@ -0,0 +1,78 @@ +Class { + #name : #PyramidVerticalFrameConstraintsInputPresenter, + #superclass : #PyramidAbstractFrameConstraintsInputPresenter, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> helpCenter [ + + ^ 'Align the vertical axis on the center of the shape.' +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> helpEnd [ + + ^ 'Align on the Bottom border.' +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> helpNull [ + + ^ 'Do not align vertically.' +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> helpStart [ + + ^ 'Align on the Top border.' +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> iconCenter [ + + ^ self iconNamed: #windowMinimize +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> iconEnd [ + + ^ (self iconNamed: #windowMenu) +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> iconNull [ + + ^ self iconNamed: #windowMaximize +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> iconStart [ + + ^ (self iconNamed: #windowMenu) rotateBy: 180 +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenter >> value [ + + self buttonNull state ifTrue: [ ^ BlVerticalAlignment null ]. + self inputHasRelative state + ifTrue: [ + self buttonStart state ifTrue: [ + ^ (BlFrameLayoutConstraintsVertical new alignTopAt: + self currentRelativeValue) alignment ]. + self buttonCenter state ifTrue: [ + ^ (BlFrameLayoutConstraintsVertical new alignCenterAt: + self currentRelativeValue) alignment ]. + self buttonEnd state ifTrue: [ + ^ (BlFrameLayoutConstraintsVertical new alignBottomAt: + self currentRelativeValue) alignment ] ] + ifFalse: [ + self buttonStart state ifTrue: [ + ^ BlFrameLayoutConstraintsVertical new alignTop alignment ]. + self buttonCenter state ifTrue: [ + ^ BlFrameLayoutConstraintsVertical new alignCenter alignment ]. + self buttonEnd state ifTrue: [ + ^ BlFrameLayoutConstraintsVertical new alignBottom alignment ] ]. + ^ PyramidUnknowState new +] From 7f17371c69694fe630602e1f8354f3ebbddce33c Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 17:13:05 +0100 Subject: [PATCH 02/10] Add icon for Layouts --- src/Pyramid-Bloc/BlBasicLayout.extension.st | 6 ++++++ src/Pyramid-Bloc/BlElement.extension.st | 2 +- src/Pyramid-Bloc/BlFlowLayout.extension.st | 6 ++++++ src/Pyramid-Bloc/BlFrameLayout.extension.st | 7 +++++++ src/Pyramid-Bloc/BlLayout.extension.st | 6 ++++++ src/Pyramid-Bloc/BlLinearLayout.extension.st | 7 +++++++ .../BlProportionalLayout.extension.st | 6 ++++++ src/Pyramid-Bloc/BlTextElement.extension.st | 2 +- .../PyramidBasicConstraintsCommand.class.st | 16 ---------------- 9 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 src/Pyramid-Bloc/BlFrameLayout.extension.st create mode 100644 src/Pyramid-Bloc/BlLinearLayout.extension.st diff --git a/src/Pyramid-Bloc/BlBasicLayout.extension.st b/src/Pyramid-Bloc/BlBasicLayout.extension.st index 04c7965c..8dff8389 100644 --- a/src/Pyramid-Bloc/BlBasicLayout.extension.st +++ b/src/Pyramid-Bloc/BlBasicLayout.extension.st @@ -1,5 +1,11 @@ Extension { #name : #BlBasicLayout } +{ #category : #'*Pyramid-Bloc' } +BlBasicLayout >> asIcon [ + + ^ self iconNamed: #checkBoxOff +] + { #category : #'*Pyramid-Bloc' } BlBasicLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ diff --git a/src/Pyramid-Bloc/BlElement.extension.st b/src/Pyramid-Bloc/BlElement.extension.st index eed6d21b..fa3b7f48 100644 --- a/src/Pyramid-Bloc/BlElement.extension.st +++ b/src/Pyramid-Bloc/BlElement.extension.st @@ -3,5 +3,5 @@ Extension { #name : #BlElement } { #category : #'*Pyramid-Bloc' } BlElement >> asIcon [ - ^ self iconNamed: #class + ^ self layout asIcon ] diff --git a/src/Pyramid-Bloc/BlFlowLayout.extension.st b/src/Pyramid-Bloc/BlFlowLayout.extension.st index 5813f904..22b4c8bc 100644 --- a/src/Pyramid-Bloc/BlFlowLayout.extension.st +++ b/src/Pyramid-Bloc/BlFlowLayout.extension.st @@ -11,6 +11,12 @@ BlFlowLayout >> = anObject [ ^ true ] +{ #category : #'*Pyramid-Bloc' } +BlFlowLayout >> asIcon [ + + ^ self iconNamed: #smallJustified +] + { #category : #'*Pyramid-Bloc' } BlFlowLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ diff --git a/src/Pyramid-Bloc/BlFrameLayout.extension.st b/src/Pyramid-Bloc/BlFrameLayout.extension.st new file mode 100644 index 00000000..fd888ddb --- /dev/null +++ b/src/Pyramid-Bloc/BlFrameLayout.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #BlFrameLayout } + +{ #category : #'*Pyramid-Bloc' } +BlFrameLayout >> asIcon [ + + ^ self iconNamed: #windowMaximize +] diff --git a/src/Pyramid-Bloc/BlLayout.extension.st b/src/Pyramid-Bloc/BlLayout.extension.st index 8a9cdf18..ad16196d 100644 --- a/src/Pyramid-Bloc/BlLayout.extension.st +++ b/src/Pyramid-Bloc/BlLayout.extension.st @@ -7,6 +7,12 @@ BlLayout >> = anObject [ ^ self class = anObject class ] +{ #category : #'*Pyramid-Bloc' } +BlLayout >> asIcon [ + + ^ self iconNamed: #smallQuestion +] + { #category : #'*Pyramid-Bloc' } BlLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ diff --git a/src/Pyramid-Bloc/BlLinearLayout.extension.st b/src/Pyramid-Bloc/BlLinearLayout.extension.st new file mode 100644 index 00000000..db887d29 --- /dev/null +++ b/src/Pyramid-Bloc/BlLinearLayout.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #BlLinearLayout } + +{ #category : #'*Pyramid-Bloc' } +BlLinearLayout >> asIcon [ + + ^ self iconNamed: #smallLeftFlush +] diff --git a/src/Pyramid-Bloc/BlProportionalLayout.extension.st b/src/Pyramid-Bloc/BlProportionalLayout.extension.st index 10f1204c..97403c42 100644 --- a/src/Pyramid-Bloc/BlProportionalLayout.extension.st +++ b/src/Pyramid-Bloc/BlProportionalLayout.extension.st @@ -1,5 +1,11 @@ Extension { #name : #BlProportionalLayout } +{ #category : #'*Pyramid-Bloc' } +BlProportionalLayout >> asIcon [ + + ^ self iconNamed: #haloScale +] + { #category : #'*Pyramid-Bloc' } BlProportionalLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ diff --git a/src/Pyramid-Bloc/BlTextElement.extension.st b/src/Pyramid-Bloc/BlTextElement.extension.st index 131c8409..3e98b88a 100644 --- a/src/Pyramid-Bloc/BlTextElement.extension.st +++ b/src/Pyramid-Bloc/BlTextElement.extension.st @@ -3,5 +3,5 @@ Extension { #name : #BlTextElement } { #category : #'*Pyramid-Bloc' } BlTextElement >> asIcon [ - ^ self iconNamed: #haloFontStyle + ^ self iconNamed: #smallFonts ] diff --git a/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st b/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st index 47df5075..1e983380 100644 --- a/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st +++ b/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st @@ -3,19 +3,3 @@ Class { #superclass : #PyramidAbstractBlocCommand, #category : #'Pyramid-Bloc-plugin-bloc-layout' } - -{ #category : #testing } -PyramidBasicConstraintsCommand >> canBeUsedFor: anObject [ - - ^ (super canBeUsedFor: anObject) and: [ - anObject hasParent and: [ - self targetsLayoutClass includes: anObject parent layout class ] ] -] - -{ #category : #'as yet unclassified' } -PyramidBasicConstraintsCommand >> targetsLayoutClass [ - - ^ { - BlBasicLayout. - BlFlowLayout } -] From 7f7be5ab81265336727f34bf65828273d2fdc518 Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 17:36:18 +0100 Subject: [PATCH 03/10] Set authorized layout for basic constraints --- .../PyramidBasicConstraintsCommand.class.st | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st b/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st index 1e983380..37fb42eb 100644 --- a/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st +++ b/src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st @@ -3,3 +3,18 @@ Class { #superclass : #PyramidAbstractBlocCommand, #category : #'Pyramid-Bloc-plugin-bloc-layout' } + +{ #category : #'as yet unclassified' } +PyramidBasicConstraintsCommand >> authorizedLayouts [ + + + ^ { BlBasicLayout . BlFlowLayout . BlLinearLayout . BlFrameLayout } +] + +{ #category : #testing } +PyramidBasicConstraintsCommand >> canBeUsedFor: anObject [ + + ^ (super canBeUsedFor: anObject) and: [ + anObject hasParent and: [ + self authorizedLayouts includes: anObject parent layout class ] ] +] From dc65f7719254501494f079e372da0f4f87cc66db Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 21:39:59 +0100 Subject: [PATCH 04/10] Add TU --- ...actFrameConstraintsInputPresenter.class.st | 9 + src/Pyramid-Bloc/PyramidBlocPlugin.class.st | 6 +- ...talFrameConstraintsInputPresenter.class.st | 3 +- .../PyramidLayoutInputPresenter.class.st | 186 ++++++++---------- ...rameConstraintsInputPresenterTest.class.st | 45 +++++ .../PyramidLayoutInputPresenterTest.class.st | 24 ++- ...rameConstraintsInputPresenterTest.class.st | 59 ++++++ src/Pyramid/PyramidUnknowState.class.st | 6 + 8 files changed, 224 insertions(+), 114 deletions(-) create mode 100644 src/Pyramid-Tests/PyramidHorizontalFrameConstraintsInputPresenterTest.class.st create mode 100644 src/Pyramid-Tests/PyramidVerticalFrameConstraintsInputPresenterTest.class.st diff --git a/src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st b/src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st index 940c89b7..f1993d4a 100644 --- a/src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st +++ b/src/Pyramid-Bloc/PyramidAbstractFrameConstraintsInputPresenter.class.st @@ -240,6 +240,15 @@ PyramidAbstractFrameConstraintsInputPresenter >> triggerValueChanged [ self whenValueChangedDo value: self value ] +{ #category : #initialization } +PyramidAbstractFrameConstraintsInputPresenter >> unselectAll [ + + self buttonNull state: false. + self buttonStart state: false. + self buttonCenter state: false. + self buttonEnd state: false +] + { #category : #'as yet unclassified' } PyramidAbstractFrameConstraintsInputPresenter >> value [ diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index ec046112..aa3deda8 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -229,10 +229,8 @@ PyramidBlocPlugin class >> layout [ | property | property := PyramidProperty new name: 'Layout'; - command: - PyramidLayoutBlocCommand new; - pyramidInputPresenterClass: - PyramidLayoutInputPresenter; + command: PyramidLayoutBlocCommand new; + pyramidInputPresenterClass: PyramidLayoutInputPresenter; yourself. ^ property ] diff --git a/src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st b/src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st index 7b102f45..62966d86 100644 --- a/src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st +++ b/src/Pyramid-Bloc/PyramidHorizontalFrameConstraintsInputPresenter.class.st @@ -73,5 +73,6 @@ PyramidHorizontalFrameConstraintsInputPresenter >> value [ self buttonCenter state ifTrue: [ ^ BlFrameLayoutConstraintsHorizontal new alignCenter alignment ]. self buttonEnd state ifTrue: [ - ^ BlFrameLayoutConstraintsHorizontal new alignRight alignment ] ] + ^ BlFrameLayoutConstraintsHorizontal new alignRight alignment ] ]. + ^ PyramidUnknowState new. ] diff --git a/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st b/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st index cb1a9123..e192eb49 100644 --- a/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st +++ b/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st @@ -2,154 +2,132 @@ Class { #name : #PyramidLayoutInputPresenter, #superclass : #PyramidInputPresenter, #instVars : [ - 'buttonBasic', - 'buttonFlow', - 'buttonProportionnal', - 'whenValueChangedDo', - 'value' + 'buttonsDictionary', + 'buttons', + 'whenValueChangedDo' ], #category : #'Pyramid-Bloc-plugin-bloc-layout' } -{ #category : #accessing } -PyramidLayoutInputPresenter >> buttonBasic [ +{ #category : #'as yet unclassified' } +PyramidLayoutInputPresenter >> allAssociationsLayoutClass [ + + ^ { + (BlBasicLayout -> #basic). + (BlLinearLayout -> #linear). + (BlFlowLayout -> #flow). + (BlFrameLayout -> #frame). + (BlProportionalLayout -> #proportionnal) } +] - ^ buttonBasic +{ #category : #'as yet unclassified' } +PyramidLayoutInputPresenter >> associatedClassOf: aLabel [ + + | allClasses | + allClasses := self allAssociationsLayoutClass select: [ :each | each value = aLabel ] thenCollect: [ :each | each key ]. + allClasses ifEmpty: [ ^ PyramidUnknowState new ]. + allClasses size = 1 ifTrue: [ ^ allClasses first new ]. + ^ PyramidUnknowState new ] { #category : #accessing } -PyramidLayoutInputPresenter >> buttonFlow [ +PyramidLayoutInputPresenter >> buttons [ - ^ buttonFlow + ^ buttons ] { #category : #accessing } -PyramidLayoutInputPresenter >> buttonProportionnal [ +PyramidLayoutInputPresenter >> buttonsDictionary [ - ^ buttonProportionnal + ^ buttonsDictionary ] { #category : #layout } PyramidLayoutInputPresenter >> defaultLayout [ - ^ SpBoxLayout newHorizontal - spacing: 4; - add: self buttonBasic; - add: self buttonFlow; - add: self buttonProportionnal; - yourself + | defaultLayout currentLine counter | + defaultLayout := SpBoxLayout newVertical + spacing: 4; + yourself. + currentLine := SpBoxLayout newHorizontal spacing: 4. + counter := 1. + self buttons do: [ :each | + currentLine add: each. + counter := counter + 1. + counter = 4 ifTrue: [ + defaultLayout add: currentLine. + currentLine := SpBoxLayout newHorizontal spacing: 4. + counter := 1 ] ]. + defaultLayout add: currentLine. + ^ defaultLayout ] { #category : #initialization } PyramidLayoutInputPresenter >> initializePresenters [ - whenValueChangedDo := [ :visibility | ]. - buttonBasic := SpButtonPresenter new - label: 'No layout'; - help: - 'Remove the layout. The children will be place according to their position.'; - action: [ - self value: BlBasicLayout new. - self whenValueChangedDo value: self value ]; - enabled: false; - yourself. - buttonFlow := SpButtonPresenter new - label: 'Flow'; - help: - 'Set the layout as Flow. The children will be place according to their order. The flow layout will display all children in line and will wrap arround if it does not have enought place.'; - action: [ - self value: BlFlowLayout horizontal. - self whenValueChangedDo value: self value ]; - enabled: false; - yourself. - buttonProportionnal := SpButtonPresenter new - label: 'ST layout'; - help: - 'Set the layout as Proportional. The children will be place according to their relative top/bottom and left/right proportion.'; - action: [ - self value: BlProportionalLayout new. - self whenValueChangedDo value: self value ]; - enabled: false; - yourself + whenValueChangedDo := [ :newVal | ]. + buttonsDictionary := Dictionary new. + buttons := OrderedCollection new. + self allAssociationsLayoutClass do: [ :association | + | button | + button := self makeButtonFor: association. + buttons add: button. + buttonsDictionary at: association key put: button ] ] -{ #category : #initialization } -PyramidLayoutInputPresenter >> setBasic [ - - self buttonBasic - enabled: true; - icon: (self iconNamed: #checkboxSelected). - self buttonFlow - enabled: true; - icon: (self iconNamed: #checkboxUnselected). - self buttonProportionnal - enabled: true; - icon: (self iconNamed: #checkboxUnselected) -] +{ #category : #'as yet unclassified' } +PyramidLayoutInputPresenter >> makeButtonFor: anAssociation [ -{ #category : #initialization } -PyramidLayoutInputPresenter >> setFlow [ - - self buttonBasic - enabled: true; - icon: (self iconNamed: #checkboxUnselected). - self buttonFlow - enabled: true; - icon: (self iconNamed: #checkboxSelected). - self buttonProportionnal - enabled: true; - icon: (self iconNamed: #checkboxUnselected) -] + | class label | + class := anAssociation key. + label := anAssociation value. -{ #category : #initialization } -PyramidLayoutInputPresenter >> setProportionnal [ - - self buttonBasic - enabled: true; - icon: (self iconNamed: #checkboxUnselected). - self buttonFlow - enabled: true; - icon: (self iconNamed: #checkboxUnselected). - self buttonProportionnal - enabled: true; - icon: (self iconNamed: #checkboxSelected) + ^ SpButtonPresenter new + icon: class new asIcon; + label: label; + action: [ self triggerFor: class ]; + yourself ] -{ #category : #initialization } -PyramidLayoutInputPresenter >> setUnknowValue [ - - self buttonBasic - enabled: false; - icon: (self iconNamed: #checkboxUnselected). - self buttonFlow - enabled: false; - icon: (self iconNamed: #checkboxUnselected). - self buttonProportionnal - enabled: false; - icon: (self iconNamed: #checkboxUnselected) +{ #category : #'as yet unclassified' } +PyramidLayoutInputPresenter >> triggerFor: aLayoutClass [ + + self whenValueChangedDo value: aLayoutClass new. + ] { #category : #'as yet unclassified' } PyramidLayoutInputPresenter >> value [ - ^ value + self buttons do: [ :each | + each state ifTrue: [ ^ self associatedClassOf: each label ] ]. + ^ PyramidUnknowState new. ] { #category : #'as yet unclassified' } -PyramidLayoutInputPresenter >> value: anObject [ +PyramidLayoutInputPresenter >> value: aLayout [ - value := anObject. - anObject setLayoutOn: self + self buttons do: [ :each | each state: false ]. + self buttonsDictionary + at: aLayout class + ifPresent: [ :button | button state: true ] ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } +PyramidLayoutInputPresenter >> valueButtons [ + "used for testing" + + ^ self buttons select: [ :each | each state ] +] + +{ #category : #'as yet unclassified' } PyramidLayoutInputPresenter >> whenValueChangedDo [ ^ whenValueChangedDo ] -{ #category : #accessing } -PyramidLayoutInputPresenter >> whenValueChangedDo: anObject [ +{ #category : #'as yet unclassified' } +PyramidLayoutInputPresenter >> whenValueChangedDo: aBlock [ - whenValueChangedDo := anObject + whenValueChangedDo := aBlock ] diff --git a/src/Pyramid-Tests/PyramidHorizontalFrameConstraintsInputPresenterTest.class.st b/src/Pyramid-Tests/PyramidHorizontalFrameConstraintsInputPresenterTest.class.st new file mode 100644 index 00000000..e50b71f6 --- /dev/null +++ b/src/Pyramid-Tests/PyramidHorizontalFrameConstraintsInputPresenterTest.class.st @@ -0,0 +1,45 @@ +Class { + #name : #PyramidHorizontalFrameConstraintsInputPresenterTest, + #superclass : #TestCase, + #traits : 'TPyramidInputPresenterTest', + #classTraits : 'TPyramidInputPresenterTest classTrait', + #category : #'Pyramid-Tests-cases-specs-custom' +} + +{ #category : #accessing } +PyramidHorizontalFrameConstraintsInputPresenterTest >> dummyValues [ + + ^ { + BlFrameLayoutConstraintsHorizontal new alignNone; alignment. + BlFrameLayoutConstraintsHorizontal new alignLeft; alignment. + BlFrameLayoutConstraintsHorizontal new alignCenter; alignment. + BlFrameLayoutConstraintsHorizontal new alignRight; alignment. + BlFrameLayoutConstraintsHorizontal new alignLeftAt: 0.5; alignment. + BlFrameLayoutConstraintsHorizontal new alignCenterAt: 0.5; alignment. + BlFrameLayoutConstraintsHorizontal new alignRightAt: 0.5; alignment } +] + +{ #category : #accessing } +PyramidHorizontalFrameConstraintsInputPresenterTest >> expectedEmptyValue [ + + ^ PyramidUnknowState new +] + +{ #category : #accessing } +PyramidHorizontalFrameConstraintsInputPresenterTest >> expectedMixedValues [ + + ^ PyramidUnknowState new +] + +{ #category : #tests } +PyramidHorizontalFrameConstraintsInputPresenterTest >> makeNewInput [ + + ^ PyramidHorizontalFrameConstraintsInputPresenter new +] + +{ #category : #'as yet unclassified' } +PyramidHorizontalFrameConstraintsInputPresenterTest >> triggerValueChangedOf: anInput [ + + anInput inputRelative inputNumber contextKeyBindings keymaps do: [ :bind | + bind action value ] +] diff --git a/src/Pyramid-Tests/PyramidLayoutInputPresenterTest.class.st b/src/Pyramid-Tests/PyramidLayoutInputPresenterTest.class.st index ba98dbe2..3a5b2ea9 100644 --- a/src/Pyramid-Tests/PyramidLayoutInputPresenterTest.class.st +++ b/src/Pyramid-Tests/PyramidLayoutInputPresenterTest.class.st @@ -11,10 +11,24 @@ PyramidLayoutInputPresenterTest >> dummyValues [ ^ { BlBasicLayout new. - BlFlowLayout horizontal. - BlFlowLayout vertical. - BlProportionalLayout new - } + BlFlowLayout horizontal. + BlFlowLayout vertical. + BlLinearLayout horizontal. + BlLinearLayout vertical. + BlFrameLayout new. + BlProportionalLayout new } +] + +{ #category : #accessing } +PyramidLayoutInputPresenterTest >> expectedEmptyValue [ + + ^ PyramidUnknowState new +] + +{ #category : #accessing } +PyramidLayoutInputPresenterTest >> expectedMixedValues [ + + ^ PyramidUnknowState new ] { #category : #tests } @@ -26,5 +40,5 @@ PyramidLayoutInputPresenterTest >> makeNewInput [ { #category : #'as yet unclassified' } PyramidLayoutInputPresenterTest >> triggerValueChangedOf: anInput [ - anInput buttonBasic click + anInput valueButtons first click ] diff --git a/src/Pyramid-Tests/PyramidVerticalFrameConstraintsInputPresenterTest.class.st b/src/Pyramid-Tests/PyramidVerticalFrameConstraintsInputPresenterTest.class.st new file mode 100644 index 00000000..54377d79 --- /dev/null +++ b/src/Pyramid-Tests/PyramidVerticalFrameConstraintsInputPresenterTest.class.st @@ -0,0 +1,59 @@ +Class { + #name : #PyramidVerticalFrameConstraintsInputPresenterTest, + #superclass : #TestCase, + #traits : 'TPyramidInputPresenterTest', + #classTraits : 'TPyramidInputPresenterTest classTrait', + #category : #'Pyramid-Tests-cases-specs-custom' +} + +{ #category : #accessing } +PyramidVerticalFrameConstraintsInputPresenterTest >> dummyValues [ + + ^ { + (BlFrameLayoutConstraintsVertical new + alignNone; + alignment). + (BlFrameLayoutConstraintsVertical new + alignTop; + alignment). + (BlFrameLayoutConstraintsVertical new + alignCenter; + alignment). + (BlFrameLayoutConstraintsVertical new + alignBottom; + alignment). + (BlFrameLayoutConstraintsVertical new + alignTopAt: 0.5; + alignment). + (BlFrameLayoutConstraintsVertical new + alignCenterAt: 0.5; + alignment). + (BlFrameLayoutConstraintsVertical new + alignBottomAt: 0.5; + alignment) } +] + +{ #category : #accessing } +PyramidVerticalFrameConstraintsInputPresenterTest >> expectedEmptyValue [ + + ^ PyramidUnknowState new +] + +{ #category : #accessing } +PyramidVerticalFrameConstraintsInputPresenterTest >> expectedMixedValues [ + + ^ PyramidUnknowState new +] + +{ #category : #tests } +PyramidVerticalFrameConstraintsInputPresenterTest >> makeNewInput [ + + ^ PyramidVerticalFrameConstraintsInputPresenter new +] + +{ #category : #'as yet unclassified' } +PyramidVerticalFrameConstraintsInputPresenterTest >> triggerValueChangedOf: anInput [ + + anInput inputRelative inputNumber contextKeyBindings keymaps do: [ :bind | + bind action value ] +] diff --git a/src/Pyramid/PyramidUnknowState.class.st b/src/Pyramid/PyramidUnknowState.class.st index 378d93a9..ebe2f912 100644 --- a/src/Pyramid/PyramidUnknowState.class.st +++ b/src/Pyramid/PyramidUnknowState.class.st @@ -53,6 +53,12 @@ PyramidUnknowState >> asString [ ^ '@ Unknow state' ] +{ #category : #'as yet unclassified' } +PyramidUnknowState >> pyramidSelectOn: anInput [ + + anInput unselectAll +] + { #category : #initialization } PyramidUnknowState >> setConstraintsOn: aPyramidBasicConstraintsInputPresenter [ From 0ad1d86db6f077539bbc42002f2df6d9a20230ac Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 21:53:16 +0100 Subject: [PATCH 05/10] Remove deprecated methods --- src/Pyramid-Bloc/BlBasicLayout.extension.st | 6 ------ src/Pyramid-Bloc/BlFlowLayout.extension.st | 6 ------ src/Pyramid-Bloc/BlLayout.extension.st | 6 ------ src/Pyramid-Bloc/BlProportionalLayout.extension.st | 6 ------ src/Pyramid/PyramidUnknowState.class.st | 6 ------ 5 files changed, 30 deletions(-) diff --git a/src/Pyramid-Bloc/BlBasicLayout.extension.st b/src/Pyramid-Bloc/BlBasicLayout.extension.st index 8dff8389..0625161b 100644 --- a/src/Pyramid-Bloc/BlBasicLayout.extension.st +++ b/src/Pyramid-Bloc/BlBasicLayout.extension.st @@ -5,9 +5,3 @@ BlBasicLayout >> asIcon [ ^ self iconNamed: #checkBoxOff ] - -{ #category : #'*Pyramid-Bloc' } -BlBasicLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ - - aPyramidLayoutInputPresenter setBasic -] diff --git a/src/Pyramid-Bloc/BlFlowLayout.extension.st b/src/Pyramid-Bloc/BlFlowLayout.extension.st index 22b4c8bc..fd33d9ab 100644 --- a/src/Pyramid-Bloc/BlFlowLayout.extension.st +++ b/src/Pyramid-Bloc/BlFlowLayout.extension.st @@ -16,9 +16,3 @@ BlFlowLayout >> asIcon [ ^ self iconNamed: #smallJustified ] - -{ #category : #'*Pyramid-Bloc' } -BlFlowLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ - - aPyramidLayoutInputPresenter setFlow -] diff --git a/src/Pyramid-Bloc/BlLayout.extension.st b/src/Pyramid-Bloc/BlLayout.extension.st index ad16196d..ef45ada7 100644 --- a/src/Pyramid-Bloc/BlLayout.extension.st +++ b/src/Pyramid-Bloc/BlLayout.extension.st @@ -12,9 +12,3 @@ BlLayout >> asIcon [ ^ self iconNamed: #smallQuestion ] - -{ #category : #'*Pyramid-Bloc' } -BlLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ - - aPyramidLayoutInputPresenter setUnknowValue -] diff --git a/src/Pyramid-Bloc/BlProportionalLayout.extension.st b/src/Pyramid-Bloc/BlProportionalLayout.extension.st index 97403c42..25bf27d4 100644 --- a/src/Pyramid-Bloc/BlProportionalLayout.extension.st +++ b/src/Pyramid-Bloc/BlProportionalLayout.extension.st @@ -5,9 +5,3 @@ BlProportionalLayout >> asIcon [ ^ self iconNamed: #haloScale ] - -{ #category : #'*Pyramid-Bloc' } -BlProportionalLayout >> setLayoutOn: aPyramidLayoutInputPresenter [ - - aPyramidLayoutInputPresenter setProportionnal -] diff --git a/src/Pyramid/PyramidUnknowState.class.st b/src/Pyramid/PyramidUnknowState.class.st index ebe2f912..6a6dbdd5 100644 --- a/src/Pyramid/PyramidUnknowState.class.st +++ b/src/Pyramid/PyramidUnknowState.class.st @@ -76,9 +76,3 @@ PyramidUnknowState >> setInsetsOn: aPyramidInsetsInputPresenter [ aPyramidInsetsInputPresenter inputArray value: self ] - -{ #category : #initialization } -PyramidUnknowState >> setLayoutOn: aPyramidLayoutInputPresenter [ - - aPyramidLayoutInputPresenter setUnknowValue -] From ef06788ae7627627977c4736771bdf7cc9c27c5c Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 22:06:27 +0100 Subject: [PATCH 06/10] Update orientation for linear and flow --- src/Pyramid-Bloc/PyramidBlocPlugin.class.st | 2 +- ...lowLayoutChangeOrientationCommand.class.st | 23 ------------------ ...midLayoutChangeOrientationCommand.class.st | 24 +++++++++++++++++++ ...youtChangeOrientationCommandTest.class.st} | 10 ++++---- 4 files changed, 30 insertions(+), 29 deletions(-) delete mode 100644 src/Pyramid-Bloc/PyramidFlowLayoutChangeOrientationCommand.class.st create mode 100644 src/Pyramid-Bloc/PyramidLayoutChangeOrientationCommand.class.st rename src/Pyramid-Tests/{PyramidFlowLayoutChangeOrientationCommandTest.class.st => PyramidLayoutChangeOrientationCommandTest.class.st} (81%) diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index aa3deda8..166fb472 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -198,7 +198,7 @@ PyramidBlocPlugin class >> flowLayoutOrientation [ | property | property := PyramidProperty new name: 'Orientation'; - command: PyramidFlowLayoutChangeOrientationCommand new; + command: PyramidLayoutChangeOrientationCommand new; pyramidInputPresenterClass: PyramidFlowLayoutOrientationPresenter; yourself. diff --git a/src/Pyramid-Bloc/PyramidFlowLayoutChangeOrientationCommand.class.st b/src/Pyramid-Bloc/PyramidFlowLayoutChangeOrientationCommand.class.st deleted file mode 100644 index a6587570..00000000 --- a/src/Pyramid-Bloc/PyramidFlowLayoutChangeOrientationCommand.class.st +++ /dev/null @@ -1,23 +0,0 @@ -Class { - #name : #PyramidFlowLayoutChangeOrientationCommand, - #superclass : #PyramidAbstractBlocCommand, - #category : #'Pyramid-Bloc-plugin-bloc-layout' -} - -{ #category : #testing } -PyramidFlowLayoutChangeOrientationCommand >> canBeUsedFor: anObject [ - - ^ (super canBeUsedFor: anObject) and: [ anObject layout class == BlFlowLayout ] -] - -{ #category : #'as yet unclassified' } -PyramidFlowLayoutChangeOrientationCommand >> getValueFor: anObject [ - - ^ anObject layout orientation -] - -{ #category : #'as yet unclassified' } -PyramidFlowLayoutChangeOrientationCommand >> setValueFor: anObject with: anArgument [ - - anObject layout orientation: anArgument -] diff --git a/src/Pyramid-Bloc/PyramidLayoutChangeOrientationCommand.class.st b/src/Pyramid-Bloc/PyramidLayoutChangeOrientationCommand.class.st new file mode 100644 index 00000000..57cc5aab --- /dev/null +++ b/src/Pyramid-Bloc/PyramidLayoutChangeOrientationCommand.class.st @@ -0,0 +1,24 @@ +Class { + #name : #PyramidLayoutChangeOrientationCommand, + #superclass : #PyramidAbstractBlocCommand, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #testing } +PyramidLayoutChangeOrientationCommand >> canBeUsedFor: anObject [ + + ^ (super canBeUsedFor: anObject) and: [ + { BlFlowLayout . BlLinearLayout } includes: anObject layout class ] +] + +{ #category : #'as yet unclassified' } +PyramidLayoutChangeOrientationCommand >> getValueFor: anObject [ + + ^ anObject layout orientation +] + +{ #category : #'as yet unclassified' } +PyramidLayoutChangeOrientationCommand >> setValueFor: anObject with: anArgument [ + + anObject layout orientation: anArgument +] diff --git a/src/Pyramid-Tests/PyramidFlowLayoutChangeOrientationCommandTest.class.st b/src/Pyramid-Tests/PyramidLayoutChangeOrientationCommandTest.class.st similarity index 81% rename from src/Pyramid-Tests/PyramidFlowLayoutChangeOrientationCommandTest.class.st rename to src/Pyramid-Tests/PyramidLayoutChangeOrientationCommandTest.class.st index 63fe8381..b0e2e9e5 100644 --- a/src/Pyramid-Tests/PyramidFlowLayoutChangeOrientationCommandTest.class.st +++ b/src/Pyramid-Tests/PyramidLayoutChangeOrientationCommandTest.class.st @@ -1,5 +1,5 @@ Class { - #name : #PyramidFlowLayoutChangeOrientationCommandTest, + #name : #PyramidLayoutChangeOrientationCommandTest, #superclass : #TestCase, #traits : 'TPyramidCommandTest', #classTraits : 'TPyramidCommandTest classTrait', @@ -7,13 +7,13 @@ Class { } { #category : #accessing } -PyramidFlowLayoutChangeOrientationCommandTest >> command [ +PyramidLayoutChangeOrientationCommandTest >> command [ - ^ PyramidFlowLayoutChangeOrientationCommand new + ^ PyramidLayoutChangeOrientationCommand new ] { #category : #'as yet unclassified' } -PyramidFlowLayoutChangeOrientationCommandTest >> targetContainers [ +PyramidLayoutChangeOrientationCommandTest >> targetContainers [ ^ { (PyramidCommandTestContainer no: (BlElement new @@ -50,7 +50,7 @@ PyramidFlowLayoutChangeOrientationCommandTest >> targetContainers [ ] { #category : #'as yet unclassified' } -PyramidFlowLayoutChangeOrientationCommandTest >> targetsCannotBeUsedFor [ +PyramidLayoutChangeOrientationCommandTest >> targetsCannotBeUsedFor [ "override if needed" ^ { From d0bfb9cf0c84b34f9b293020fca7c3e1f6e2e015 Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 22:12:12 +0100 Subject: [PATCH 07/10] Add missing endpoint for linear layout --- .../BlLinearLayoutHorizontalOrientation.extension.st | 7 +++++++ .../BlLinearLayoutVerticalOrientation.extension.st | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st create mode 100644 src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st diff --git a/src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st b/src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st new file mode 100644 index 00000000..c06bfba9 --- /dev/null +++ b/src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #BlLinearLayoutHorizontalOrientation } + +{ #category : #'*Pyramid-Bloc' } +BlLinearLayoutHorizontalOrientation >> asBooleanForPyramid [ + + ^ false +] diff --git a/src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st b/src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st new file mode 100644 index 00000000..20492080 --- /dev/null +++ b/src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #BlLinearLayoutVerticalOrientation } + +{ #category : #'*Pyramid-Bloc' } +BlLinearLayoutVerticalOrientation >> asBooleanForPyramid [ + + ^ true +] From 99393842561b79e6dc22d04215595515bc4f2772 Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Wed, 24 Jan 2024 22:22:36 +0100 Subject: [PATCH 08/10] Better icon for no layout --- src/Pyramid-Bloc/BlBasicLayout.extension.st | 2 +- src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pyramid-Bloc/BlBasicLayout.extension.st b/src/Pyramid-Bloc/BlBasicLayout.extension.st index 0625161b..46a35316 100644 --- a/src/Pyramid-Bloc/BlBasicLayout.extension.st +++ b/src/Pyramid-Bloc/BlBasicLayout.extension.st @@ -3,5 +3,5 @@ Extension { #name : #BlBasicLayout } { #category : #'*Pyramid-Bloc' } BlBasicLayout >> asIcon [ - ^ self iconNamed: #checkBoxOff + ^ self iconNamed: #radioButtonUnselected ] diff --git a/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st b/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st index e192eb49..31182138 100644 --- a/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st +++ b/src/Pyramid-Bloc/PyramidLayoutInputPresenter.class.st @@ -17,7 +17,7 @@ PyramidLayoutInputPresenter >> allAssociationsLayoutClass [ (BlLinearLayout -> #linear). (BlFlowLayout -> #flow). (BlFrameLayout -> #frame). - (BlProportionalLayout -> #proportionnal) } + (BlProportionalLayout -> #proportion) } ] { #category : #'as yet unclassified' } @@ -54,7 +54,7 @@ PyramidLayoutInputPresenter >> defaultLayout [ self buttons do: [ :each | currentLine add: each. counter := counter + 1. - counter = 4 ifTrue: [ + counter = 3 ifTrue: [ defaultLayout add: currentLine. currentLine := SpBoxLayout newHorizontal spacing: 4. counter := 1 ] ]. From 898aac2935657670be25d9bcda7992e5b3ed93ef Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Thu, 25 Jan 2024 10:25:23 +0100 Subject: [PATCH 09/10] Fix bug on linear orientation --- ...arLayoutHorizontalOrientation.extension.st | 6 +++++ ...nearLayoutVerticalOrientation.extension.st | 6 +++++ src/Pyramid-Bloc/False.extension.st | 8 +++++- ...bstractLayoutOrientationPresenter.class.st | 27 +++++++++++++++++++ src/Pyramid-Bloc/PyramidBlocPlugin.class.st | 22 ++++++++++++++- ...midFlowLayoutOrientationPresenter.class.st | 20 ++------------ ...utChangeOrientationForFlowCommand.class.st | 13 +++++++++ ...ChangeOrientationForLinearCommand.class.st | 12 +++++++++ ...dLinearLayoutOrientationPresenter.class.st | 11 ++++++++ src/Pyramid-Bloc/True.extension.st | 7 ++++- ...lowLayoutOrientationPresenterTest.class.st | 2 +- src/Pyramid/PyramidUnknowState.class.st | 8 +++++- 12 files changed, 119 insertions(+), 23 deletions(-) create mode 100644 src/Pyramid-Bloc/PyramidAbstractLayoutOrientationPresenter.class.st create mode 100644 src/Pyramid-Bloc/PyramidLayoutChangeOrientationForFlowCommand.class.st create mode 100644 src/Pyramid-Bloc/PyramidLayoutChangeOrientationForLinearCommand.class.st create mode 100644 src/Pyramid-Bloc/PyramidLinearLayoutOrientationPresenter.class.st diff --git a/src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st b/src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st index c06bfba9..a6549508 100644 --- a/src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st +++ b/src/Pyramid-Bloc/BlLinearLayoutHorizontalOrientation.extension.st @@ -5,3 +5,9 @@ BlLinearLayoutHorizontalOrientation >> asBooleanForPyramid [ ^ false ] + +{ #category : #'*Pyramid-Bloc' } +BlLinearLayoutHorizontalOrientation >> switchOrientation [ + + ^ BlLinearLayoutVerticalOrientation new +] diff --git a/src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st b/src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st index 20492080..86c3321b 100644 --- a/src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st +++ b/src/Pyramid-Bloc/BlLinearLayoutVerticalOrientation.extension.st @@ -5,3 +5,9 @@ BlLinearLayoutVerticalOrientation >> asBooleanForPyramid [ ^ true ] + +{ #category : #'*Pyramid-Bloc' } +BlLinearLayoutVerticalOrientation >> switchOrientation [ + + ^ BlLinearLayoutHorizontalOrientation new +] diff --git a/src/Pyramid-Bloc/False.extension.st b/src/Pyramid-Bloc/False.extension.st index 5cf991d7..b5527117 100644 --- a/src/Pyramid-Bloc/False.extension.st +++ b/src/Pyramid-Bloc/False.extension.st @@ -1,7 +1,13 @@ Extension { #name : #False } { #category : #'*Pyramid-Bloc' } -False >> asOrientationForPyramid [ +False >> asOrientationForFlowPyramid [ ^ BlLayoutOrientation horizontal ] + +{ #category : #'*Pyramid-Bloc' } +False >> asOrientationForLinearPyramid [ + + ^ BlLinearLayoutHorizontalOrientation new +] diff --git a/src/Pyramid-Bloc/PyramidAbstractLayoutOrientationPresenter.class.st b/src/Pyramid-Bloc/PyramidAbstractLayoutOrientationPresenter.class.st new file mode 100644 index 00000000..91ef518e --- /dev/null +++ b/src/Pyramid-Bloc/PyramidAbstractLayoutOrientationPresenter.class.st @@ -0,0 +1,27 @@ +Class { + #name : #PyramidAbstractLayoutOrientationPresenter, + #superclass : #PyramidSwitchInputPresenter, + #instVars : [ + 'buttonSwitch' + ], + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #'as yet unclassified' } +PyramidAbstractLayoutOrientationPresenter >> switchState [ + + self value: self value switchOrientation. + self whenValueChangedDo value: self value +] + +{ #category : #'as yet unclassified' } +PyramidAbstractLayoutOrientationPresenter >> value [ + + ^ self shouldBeImplemented +] + +{ #category : #'as yet unclassified' } +PyramidAbstractLayoutOrientationPresenter >> value: anOrientation [ + + super value: anOrientation asBooleanForPyramid +] diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index 166fb472..b39d3ea4 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -198,7 +198,7 @@ PyramidBlocPlugin class >> flowLayoutOrientation [ | property | property := PyramidProperty new name: 'Orientation'; - command: PyramidLayoutChangeOrientationCommand new; + command: PyramidLayoutChangeOrientationForFlowCommand new; pyramidInputPresenterClass: PyramidFlowLayoutOrientationPresenter; yourself. @@ -235,6 +235,24 @@ PyramidBlocPlugin class >> layout [ ^ property ] +{ #category : #accessing } +PyramidBlocPlugin class >> linearLayoutOrientation [ + + | property | + property := PyramidProperty new + name: 'Orientation'; + command: PyramidLayoutChangeOrientationForLinearCommand new; + pyramidInputPresenterClass: + PyramidLinearLayoutOrientationPresenter; + yourself. + property pyramidInputPresenterStrings help: + 'Change the orientation of the flow layout.'. + property pyramidInputPresenterStrings onLabel: 'Vertical'. + property pyramidInputPresenterStrings offLabel: 'Horizontal'. + property pyramidInputPresenterStrings uncertainLabel: 'Uncertain'. + ^ property +] + { #category : #accessing } PyramidBlocPlugin class >> margin [ @@ -334,6 +352,8 @@ PyramidBlocPlugin >> connectOn: aPyramidEditor [ aPyramidEditor propertiesManager addProperty: self class layout. aPyramidEditor propertiesManager addProperty: self class flowLayoutOrientation. + aPyramidEditor propertiesManager addProperty: + self class linearLayoutOrientation. "Constraints - horizontal" aPyramidEditor propertiesManager addProperty: diff --git a/src/Pyramid-Bloc/PyramidFlowLayoutOrientationPresenter.class.st b/src/Pyramid-Bloc/PyramidFlowLayoutOrientationPresenter.class.st index a3403f1a..d2f245bf 100644 --- a/src/Pyramid-Bloc/PyramidFlowLayoutOrientationPresenter.class.st +++ b/src/Pyramid-Bloc/PyramidFlowLayoutOrientationPresenter.class.st @@ -1,27 +1,11 @@ Class { #name : #PyramidFlowLayoutOrientationPresenter, - #superclass : #PyramidSwitchInputPresenter, - #instVars : [ - 'buttonSwitch' - ], + #superclass : #PyramidAbstractLayoutOrientationPresenter, #category : #'Pyramid-Bloc-plugin-bloc-layout' } -{ #category : #'as yet unclassified' } -PyramidFlowLayoutOrientationPresenter >> switchState [ - - self value: self value switchOrientation. - self whenValueChangedDo value: self value -] - { #category : #'as yet unclassified' } PyramidFlowLayoutOrientationPresenter >> value [ - ^ self state asOrientationForPyramid -] - -{ #category : #'as yet unclassified' } -PyramidFlowLayoutOrientationPresenter >> value: anOrientation [ - - super value: anOrientation asBooleanForPyramid + ^ self state asOrientationForFlowPyramid ] diff --git a/src/Pyramid-Bloc/PyramidLayoutChangeOrientationForFlowCommand.class.st b/src/Pyramid-Bloc/PyramidLayoutChangeOrientationForFlowCommand.class.st new file mode 100644 index 00000000..64aafc1b --- /dev/null +++ b/src/Pyramid-Bloc/PyramidLayoutChangeOrientationForFlowCommand.class.st @@ -0,0 +1,13 @@ +Class { + #name : #PyramidLayoutChangeOrientationForFlowCommand, + #superclass : #PyramidLayoutChangeOrientationCommand, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #testing } +PyramidLayoutChangeOrientationForFlowCommand >> canBeUsedFor: anObject [ + + ^ (super canBeUsedFor: anObject) and: [ + + BlFlowLayout = anObject layout class ] +] diff --git a/src/Pyramid-Bloc/PyramidLayoutChangeOrientationForLinearCommand.class.st b/src/Pyramid-Bloc/PyramidLayoutChangeOrientationForLinearCommand.class.st new file mode 100644 index 00000000..f6380468 --- /dev/null +++ b/src/Pyramid-Bloc/PyramidLayoutChangeOrientationForLinearCommand.class.st @@ -0,0 +1,12 @@ +Class { + #name : #PyramidLayoutChangeOrientationForLinearCommand, + #superclass : #PyramidLayoutChangeOrientationCommand, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #testing } +PyramidLayoutChangeOrientationForLinearCommand >> canBeUsedFor: anObject [ + + ^ (super canBeUsedFor: anObject) and: [ + BlLinearLayout = anObject layout class ] +] diff --git a/src/Pyramid-Bloc/PyramidLinearLayoutOrientationPresenter.class.st b/src/Pyramid-Bloc/PyramidLinearLayoutOrientationPresenter.class.st new file mode 100644 index 00000000..0482a18a --- /dev/null +++ b/src/Pyramid-Bloc/PyramidLinearLayoutOrientationPresenter.class.st @@ -0,0 +1,11 @@ +Class { + #name : #PyramidLinearLayoutOrientationPresenter, + #superclass : #PyramidAbstractLayoutOrientationPresenter, + #category : #'Pyramid-Bloc-plugin-bloc-layout' +} + +{ #category : #'as yet unclassified' } +PyramidLinearLayoutOrientationPresenter >> value [ + + ^ self state asOrientationForLinearPyramid +] diff --git a/src/Pyramid-Bloc/True.extension.st b/src/Pyramid-Bloc/True.extension.st index 0e0f3b6f..de1a7a0a 100644 --- a/src/Pyramid-Bloc/True.extension.st +++ b/src/Pyramid-Bloc/True.extension.st @@ -1,7 +1,12 @@ Extension { #name : #True } { #category : #'*Pyramid-Bloc' } -True >> asOrientationForPyramid [ +True >> asOrientationForFlowPyramid [ ^ BlLayoutOrientation vertical ] + +{ #category : #'*Pyramid-Bloc' } +True >> asOrientationForLinearPyramid [ + ^ BlLinearLayoutVerticalOrientation new +] diff --git a/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st b/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st index a112b867..9e5113a7 100644 --- a/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st +++ b/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st @@ -27,7 +27,7 @@ PyramidFlowLayoutOrientationPresenterTest >> expectedMixedValues [ { #category : #tests } PyramidFlowLayoutOrientationPresenterTest >> makeNewInput [ - ^ PyramidFlowLayoutOrientationPresenter new + ^ PyramidAbstractLayoutOrientationPresenter new ] { #category : #'as yet unclassified' } diff --git a/src/Pyramid/PyramidUnknowState.class.st b/src/Pyramid/PyramidUnknowState.class.st index 6a6dbdd5..deec45d9 100644 --- a/src/Pyramid/PyramidUnknowState.class.st +++ b/src/Pyramid/PyramidUnknowState.class.st @@ -36,7 +36,13 @@ PyramidUnknowState >> asIcon [ ] { #category : #converting } -PyramidUnknowState >> asOrientationForPyramid [ +PyramidUnknowState >> asOrientationForFlowPyramid [ + + ^ self +] + +{ #category : #converting } +PyramidUnknowState >> asOrientationForLinearPyramid [ ^ self ] From 40c4554443b918a547a311d8fa004f7b349bcafc Mon Sep 17 00:00:00 2001 From: Nyan11 Date: Thu, 25 Jan 2024 11:17:47 +0100 Subject: [PATCH 10/10] Fix not working tests --- ...lowLayoutOrientationPresenterTest.class.st | 2 +- ...earLayoutOrientationPresenterTest.class.st | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/Pyramid-Tests/PyramidLinearLayoutOrientationPresenterTest.class.st diff --git a/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st b/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st index 9e5113a7..a112b867 100644 --- a/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st +++ b/src/Pyramid-Tests/PyramidFlowLayoutOrientationPresenterTest.class.st @@ -27,7 +27,7 @@ PyramidFlowLayoutOrientationPresenterTest >> expectedMixedValues [ { #category : #tests } PyramidFlowLayoutOrientationPresenterTest >> makeNewInput [ - ^ PyramidAbstractLayoutOrientationPresenter new + ^ PyramidFlowLayoutOrientationPresenter new ] { #category : #'as yet unclassified' } diff --git a/src/Pyramid-Tests/PyramidLinearLayoutOrientationPresenterTest.class.st b/src/Pyramid-Tests/PyramidLinearLayoutOrientationPresenterTest.class.st new file mode 100644 index 00000000..65542524 --- /dev/null +++ b/src/Pyramid-Tests/PyramidLinearLayoutOrientationPresenterTest.class.st @@ -0,0 +1,42 @@ +Class { + #name : #PyramidLinearLayoutOrientationPresenterTest, + #superclass : #TestCase, + #traits : 'TPyramidInputPresenterTest', + #classTraits : 'TPyramidInputPresenterTest classTrait', + #category : #'Pyramid-Tests-cases-specs-custom' +} + +{ #category : #accessing } +PyramidLinearLayoutOrientationPresenterTest >> dummyValues [ + + ^ { + BlLinearLayoutHorizontalOrientation new. + BlLinearLayoutVerticalOrientation new. + BlLinearLayoutHorizontalOrientation new. + BlLinearLayoutVerticalOrientation new. + BlLinearLayoutHorizontalOrientation new } +] + +{ #category : #accessing } +PyramidLinearLayoutOrientationPresenterTest >> expectedEmptyValue [ + + ^ PyramidUnknowState new +] + +{ #category : #accessing } +PyramidLinearLayoutOrientationPresenterTest >> expectedMixedValues [ + + ^ PyramidUnknowState new +] + +{ #category : #tests } +PyramidLinearLayoutOrientationPresenterTest >> makeNewInput [ + + ^ PyramidLinearLayoutOrientationPresenter new +] + +{ #category : #'as yet unclassified' } +PyramidLinearLayoutOrientationPresenterTest >> triggerValueChangedOf: anInput [ + + anInput button click +]