Skip to content

Commit

Permalink
Merge pull request #70 from OpenSmock/ft_layout
Browse files Browse the repository at this point in the history
Ft layout
  • Loading branch information
Nyan11 authored Aug 9, 2023
2 parents 622b8a6 + 2362cac commit 7c35631
Show file tree
Hide file tree
Showing 42 changed files with 2,081 additions and 15 deletions.
7 changes: 7 additions & 0 deletions src/Pyramid-Bloc/BlBasicLayout.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #BlBasicLayout }

{ #category : #'*Pyramid-Bloc' }
BlBasicLayout >> setLayoutOn: aPyramidLayoutInputPresenter [

aPyramidLayoutInputPresenter setBasic
]
18 changes: 18 additions & 0 deletions src/Pyramid-Bloc/BlFlowLayout.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Extension { #name : #BlFlowLayout }

{ #category : #'*Pyramid-Bloc' }
BlFlowLayout >> = anObject [

self == anObject ifTrue: [ ^ true ].
self class = anObject class ifFalse: [ ^ false ].
self orientation = anObject orientation ifFalse: [ ^ false ].
self horizontalAlignment = anObject horizontalAlignment ifFalse: [ ^ false ].
self verticalAlignment = anObject verticalAlignment ifFalse: [ ^ false ].
^ true
]

{ #category : #'*Pyramid-Bloc' }
BlFlowLayout >> setLayoutOn: aPyramidLayoutInputPresenter [

aPyramidLayoutInputPresenter setFlow
]
8 changes: 8 additions & 0 deletions src/Pyramid-Bloc/BlLayout.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : #BlLayout }

{ #category : #'*Pyramid-Bloc' }
BlLayout >> = anObject [

self == anObject ifTrue: [ ^ true ].
^ self class = anObject class
]
13 changes: 13 additions & 0 deletions src/Pyramid-Bloc/BlLayoutCommonConstraintsAxis.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #BlLayoutCommonConstraintsAxis }

{ #category : #'*Pyramid-Bloc' }
BlLayoutCommonConstraintsAxis >> asPyramidConstraintsArgument [

^ self resizer asPyramidConstraintsArgument
]

{ #category : #'*Pyramid-Bloc' }
BlLayoutCommonConstraintsAxis >> setConstraintsOn: aPyramidBasicConstraintsInputPresenter [

self resizer setResizerConstraintsOn: aPyramidBasicConstraintsInputPresenter
]
15 changes: 15 additions & 0 deletions src/Pyramid-Bloc/BlLayoutExactResizer.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Extension { #name : #BlLayoutExactResizer }

{ #category : #'*Pyramid-Bloc' }
BlLayoutExactResizer >> asPyramidConstraintsArgument [

^ {
#exact:.
self size }
]

{ #category : #'*Pyramid-Bloc' }
BlLayoutExactResizer >> setResizerConstraintsOn: aPyramidBasicConstraintsInputPresenter [

aPyramidBasicConstraintsInputPresenter setExact
]
13 changes: 13 additions & 0 deletions src/Pyramid-Bloc/BlLayoutFitContentResizer.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #BlLayoutFitContentResizer }

{ #category : #'*Pyramid-Bloc' }
BlLayoutFitContentResizer >> asPyramidConstraintsArgument [

^ #fitContent
]

{ #category : #'*Pyramid-Bloc' }
BlLayoutFitContentResizer >> setResizerConstraintsOn: aPyramidBasicConstraintsInputPresenter [

aPyramidBasicConstraintsInputPresenter setFitContent
]
13 changes: 13 additions & 0 deletions src/Pyramid-Bloc/BlLayoutHorizontal.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #BlLayoutHorizontal }

{ #category : #'*Pyramid-Bloc' }
BlLayoutHorizontal >> asBooleanForPyramid [

^ false
]

{ #category : #'*Pyramid-Bloc' }
BlLayoutHorizontal >> switchOrientation [

^ BlLayoutOrientation vertical
]
13 changes: 13 additions & 0 deletions src/Pyramid-Bloc/BlLayoutMatchParentResizer.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #BlLayoutMatchParentResizer }

{ #category : #'*Pyramid-Bloc' }
BlLayoutMatchParentResizer >> asPyramidConstraintsArgument [

^ #matchParent
]

{ #category : #'*Pyramid-Bloc' }
BlLayoutMatchParentResizer >> setResizerConstraintsOn: aPyramidBasicConstraintsInputPresenter [

aPyramidBasicConstraintsInputPresenter setMatchParent
]
13 changes: 13 additions & 0 deletions src/Pyramid-Bloc/BlLayoutVertical.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : #BlLayoutVertical }

{ #category : #'*Pyramid-Bloc' }
BlLayoutVertical >> asBooleanForPyramid [

^ true
]

{ #category : #'*Pyramid-Bloc' }
BlLayoutVertical >> switchOrientation [

^ BlLayoutOrientation horizontal
]
7 changes: 7 additions & 0 deletions src/Pyramid-Bloc/BlProportionalLayout.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #BlProportionalLayout }

{ #category : #'*Pyramid-Bloc' }
BlProportionalLayout >> setLayoutOn: aPyramidLayoutInputPresenter [

aPyramidLayoutInputPresenter setProportionnal
]
7 changes: 7 additions & 0 deletions src/Pyramid-Bloc/False.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #False }

{ #category : #'*Pyramid-Bloc' }
False >> asOrientationForPyramid [

^ BlLayoutOrientation horizontal
]
21 changes: 21 additions & 0 deletions src/Pyramid-Bloc/PyramidBasicConstraintsCommand.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Class {
#name : #PyramidBasicConstraintsCommand,
#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 }
]
140 changes: 140 additions & 0 deletions src/Pyramid-Bloc/PyramidBasicConstraintsInputPresenter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
Class {
#name : #PyramidBasicConstraintsInputPresenter,
#superclass : #PyramidInputPresenter,
#instVars : [
'buttonExact',
'buttonMatchParent',
'buttonFitContent',
'whenValueChangedDo',
'value'
],
#category : #'Pyramid-Bloc-plugin-bloc-layout'
}

{ #category : #accessing }
PyramidBasicConstraintsInputPresenter >> buttonExact [

^ buttonExact
]

{ #category : #accessing }
PyramidBasicConstraintsInputPresenter >> buttonFitContent [

^ buttonFitContent
]

{ #category : #accessing }
PyramidBasicConstraintsInputPresenter >> buttonMatchParent [

^ buttonMatchParent
]

{ #category : #layout }
PyramidBasicConstraintsInputPresenter >> defaultLayout [

^ SpBoxLayout newHorizontal
spacing: 4;
add: self buttonExact;
add: self buttonMatchParent;
add: self buttonFitContent;
yourself
]

{ #category : #initialization }
PyramidBasicConstraintsInputPresenter >> initializePresenters [

whenValueChangedDo := [ :visibility | ].
buttonExact := SpButtonPresenter new
label: 'Exact';
action: [
self value:
(BlLayoutCommonConstraintsAxis new exact: 50).
self whenValueChangedDo value: self value ];
enabled: false;
yourself.
buttonMatchParent := SpButtonPresenter new
label: 'Match Parent';
action: [
self value:
(BlLayoutCommonConstraintsAxis new matchParent).
self whenValueChangedDo value: self value ];
enabled: false;
yourself.
buttonFitContent := SpButtonPresenter new
label: 'Fit Content';
action: [
self value:
(BlLayoutCommonConstraintsAxis new fitContent).
self whenValueChangedDo value: self value ];
enabled: false;
yourself
]

{ #category : #initialization }
PyramidBasicConstraintsInputPresenter >> setExact [

self buttonExact
enabled: true;
icon: (self iconNamed: #checkboxSelected).
self buttonFitContent
enabled: true;
icon: (self iconNamed: #checkboxUnselected).
self buttonMatchParent
enabled: true;
icon: (self iconNamed: #checkboxUnselected)
]

{ #category : #initialization }
PyramidBasicConstraintsInputPresenter >> setFitContent [

self buttonExact
enabled: true;
icon: (self iconNamed: #checkboxUnselected).
self buttonFitContent
enabled: true;
icon: (self iconNamed: #checkboxSelected).
self buttonMatchParent
enabled: true;
icon: (self iconNamed: #checkboxUnselected)
]

{ #category : #initialization }
PyramidBasicConstraintsInputPresenter >> setMatchParent [

self buttonExact enabled: true; icon: (self iconNamed: #checkboxUnselected).
self buttonFitContent enabled: true; icon: (self iconNamed: #checkboxUnselected).
self buttonMatchParent enabled: true; icon: (self iconNamed: #checkboxSelected).
]

{ #category : #initialization }
PyramidBasicConstraintsInputPresenter >> setUnknowValue [

self buttonExact enabled: false; icon: (self iconNamed: #checkboxUnselected).
self buttonFitContent enabled: false; icon: (self iconNamed: #checkboxUnselected).
self buttonMatchParent enabled: false; icon: (self iconNamed: #checkboxUnselected).
]

{ #category : #'as yet unclassified' }
PyramidBasicConstraintsInputPresenter >> value [

^ value asPyramidConstraintsArgument
]

{ #category : #'as yet unclassified' }
PyramidBasicConstraintsInputPresenter >> value: aCommonConstraints [

value := aCommonConstraints.
aCommonConstraints setConstraintsOn: self
]

{ #category : #accessing }
PyramidBasicConstraintsInputPresenter >> whenValueChangedDo [

^ whenValueChangedDo
]

{ #category : #accessing }
PyramidBasicConstraintsInputPresenter >> whenValueChangedDo: anObject [

whenValueChangedDo := anObject
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Class {
#name : #PyramidBasicExactHorizontalConstraintsBlocCommand,
#superclass : #PyramidBasicConstraintsCommand,
#category : #'Pyramid-Bloc-plugin-bloc-layout'
}

{ #category : #'as yet unclassified' }
PyramidBasicExactHorizontalConstraintsBlocCommand >> canBeUsedFor: anObject [

^ (super canBeUsedFor: anObject) and: [
anObject constraints horizontal resizer isExact ]
]

{ #category : #'as yet unclassified' }
PyramidBasicExactHorizontalConstraintsBlocCommand >> getValueFor: anObject [

^ anObject constraints horizontal resizer size
]

{ #category : #'as yet unclassified' }
PyramidBasicExactHorizontalConstraintsBlocCommand >> setValueFor: anObject with: anArgument [

^ anObject constraintsDo: [ :c | c horizontal exact: anArgument ]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Class {
#name : #PyramidBasicExactVerticalConstraintsBlocCommand,
#superclass : #PyramidBasicConstraintsCommand,
#category : #'Pyramid-Bloc-plugin-bloc-layout'
}

{ #category : #'as yet unclassified' }
PyramidBasicExactVerticalConstraintsBlocCommand >> canBeUsedFor: anObject [

^ (super canBeUsedFor: anObject) and: [
anObject constraints vertical resizer isExact ]
]

{ #category : #'as yet unclassified' }
PyramidBasicExactVerticalConstraintsBlocCommand >> getValueFor: anObject [

^ anObject constraints vertical resizer size
]

{ #category : #'as yet unclassified' }
PyramidBasicExactVerticalConstraintsBlocCommand >> setValueFor: anObject with: anArgument [

^ anObject constraintsDo: [ :c | c vertical exact: anArgument ]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Class {
#name : #PyramidBasicHorizontalConstraintsBlocCommand,
#superclass : #PyramidBasicConstraintsCommand,
#category : #'Pyramid-Bloc-plugin-bloc-layout'
}

{ #category : #'as yet unclassified' }
PyramidBasicHorizontalConstraintsBlocCommand >> getValueFor: anObject [

^ anObject constraints horizontal
]

{ #category : #'as yet unclassified' }
PyramidBasicHorizontalConstraintsBlocCommand >> saveStatesOf: aCollection withCommand: aCommand withArguments: anArguments [

| mementos |
mementos := aCollection collect: [ :each |
PyramidCommandMemento new
command: aCommand;
target: each;
arguments: (self getValueFor: each) asPyramidConstraintsArgument;
yourself ].
mementos size = 1 ifTrue: [ ^ mementos first ].
^ PyramidCompositeMemento new
mementos: mementos;
yourself
]

{ #category : #'as yet unclassified' }
PyramidBasicHorizontalConstraintsBlocCommand >> setValueFor: anObject with: anArgument [

anArgument isSymbol
ifFalse: [
anObject constraintsDo: [ :c |
c horizontal perform: anArgument first with: anArgument last ] ]
ifTrue: [
anObject constraintsDo: [ :c | c horizontal perform: anArgument ] ]
]
Loading

0 comments on commit 7c35631

Please sign in to comment.