Skip to content
191 changes: 133 additions & 58 deletions src/Pyramid-Bloc/PyramidMainExtension.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,62 @@ Class {
'gridColor',
'selectionWidgetExtension'
],
#classInstVars : [
'currentGridWindowSize',
'currentGridVisibility',
'currentGridSpacing',
'currentGridColor'
],
#category : #'Pyramid-Bloc-plugin-space-extensions'
}

{ #category : #accessing }
PyramidMainExtension class >> currentGridColor [

^ currentGridColor ifNil: [ ^ Color black ]
]

{ #category : #accessing }
PyramidMainExtension class >> currentGridColor: aColor [

currentGridColor := aColor
]

{ #category : #accessing }
PyramidMainExtension class >> currentGridSpacing [

^ currentGridSpacing ifNil: [ ^ 10 ]
]

{ #category : #accessing }
PyramidMainExtension class >> currentGridSpacing: anInteger [

currentGridSpacing := anInteger
]

{ #category : #accessing }
PyramidMainExtension class >> currentGridVisibility [
^ currentGridVisibility ifNil: [ ^ false ]


]

{ #category : #accessing }
PyramidMainExtension class >> currentGridVisibility: aBoolean [
currentGridVisibility := aBoolean
]

{ #category : #accessing }
PyramidMainExtension class >> currentGridWindowSize [

^ currentGridWindowSize ifNil: [ ^ 800 @ 600 ]
]

{ #category : #accessing }
PyramidMainExtension class >> currentGridWindowSize: aPoint [
currentGridWindowSize := aPoint
]

{ #category : #accessing }
PyramidMainExtension >> borderElement [

Expand All @@ -40,23 +93,23 @@ PyramidMainExtension >> containerElement [

{ #category : #'as yet unclassified' }
PyramidMainExtension >> createGrid [

"Remove the current all the line of the grid"

self gridElement removeChildWithId: #gridHorizontal.
self gridElement removeChildWithId: #gridVertical.
self gridElement removeChildWithId: #pixelGrid.

"Create the grid if gridVisibility is true"
gridVisibility ifTrue: [ self grid: self gridElement
cellSpacing: self gridSpacing
color: self gridColor
width: (self gridWindowSize x)
height: (self gridWindowSize y).
self selectionWidgetExtension movingLap: self gridSpacing
]
ifFalse: [ self selectionWidgetExtension movingLap: 1 ].

gridVisibility
ifTrue: [
self
grid: self gridElement
cellSpacing: self gridSpacing
color: self gridColor
width: self gridWindowSize x
height: self gridWindowSize y.
self selectionWidgetExtension movingLap: self gridSpacing ]
ifFalse: [ self selectionWidgetExtension movingLap: 1 ]
]

{ #category : #accessing }
Expand All @@ -80,22 +133,25 @@ PyramidMainExtension >> defaultGridColor [
{ #category : #'as yet unclassified' }
PyramidMainExtension >> defaultGridSpacing [
"Default spacing value of the grid"

^ 10
]

{ #category : #'as yet unclassified' }
PyramidMainExtension >> defaultGridVisibility [
"Default visibility value of the grid"
^ false
"Default visibility value of the grid"
^ false
]

{ #category : #accessing }
PyramidMainExtension >> editor: aPyramidEditor [

aPyramidEditor window at: #topRight addItem: [ :buttonBuilder |
buttonBuilder makeButtonWithIcon: self workplacePropertiesButton order: 10 ].

buttonBuilder
makeButtonWithIcon: self workplacePropertiesButton
order: 10 ].
self getSelectionWidgetExtension: aPyramidEditor.

]

{ #category : #geometry }
Expand All @@ -104,6 +160,7 @@ PyramidMainExtension >> extent: aPoint [
self elementAtWidgets extent: aPoint.
self sizeElement extent: aPoint.
self gridWindowSize: aPoint.
self class currentGridWindowSize: aPoint.

self createGrid
]
Expand Down Expand Up @@ -185,15 +242,10 @@ PyramidMainExtension >> gridColor [
^ gridColor
]

{ #category : #'as yet unclassified' }
PyramidMainExtension >> gridDefaultValueInitializer [

"Set the default parameter values of the grid"
gridWindowSize := self defaultExtent.
gridVisibility := self defaultGridVisibility.
gridSpacing := self defaultGridSpacing.
gridColor := self defaultGridColor.
self createGrid.
{ #category : #accessing }
PyramidMainExtension >> gridColor: aColor [

gridColor := aColor
]

{ #category : #accessing }
Expand All @@ -206,9 +258,22 @@ PyramidMainExtension >> gridSpacing [
^ gridSpacing
]

{ #category : #accessing }
PyramidMainExtension >> gridSpacing: anInteger [

gridSpacing := anInteger.
]

{ #category : #accessing }
PyramidMainExtension >> gridVisibility [
^ gridVisibility

^ gridVisibility
]

{ #category : #accessing }
PyramidMainExtension >> gridVisibility: aBoolean [

gridVisibility := aBoolean
]

{ #category : #accessing }
Expand All @@ -231,36 +296,54 @@ PyramidMainExtension >> informTransformationChanged [
{ #category : #initialization }
PyramidMainExtension >> initialize [
"Set the default parameter value of the grid"

self class currentGridWindowSize: self defaultExtent.
self class currentGridVisibility: self defaultGridVisibility.
self class currentGridSpacing: self defaultGridSpacing.
self class currentGridColor: self defaultGridColor.

gridWindowSize := self defaultExtent.
gridVisibility := self defaultGridVisibility.
gridSpacing := self defaultGridSpacing.
gridColor := self defaultGridColor.

"Set up the graphical parameter windows of the grid and the space extension"
workplacePropertiesView := PyramidWorkplacePropertiesPresenter new
workplaceSizeValue: self defaultExtent;
workplaceSizeValue: self defaultExtent;
whenWorkplaceValuesChangedDo: [ :point |
self extent: point ];
whenVisibilityChangedDo: [
self switchGridvisibility.
self createGrid ];
gridVisibility := workplacePropertiesView
visibilityButton
state.

self class currentGridVisibility:
gridVisibility.
self createGrid ];
spacingTextValue: self defaultGridSpacing;
whenSpacingTextChangedDo: [ :value |
(self checkZeroOrSubZeroGridSpacingValue: value)
ifTrue: [
self defaultGridSpacing <= 0 ifTrue: [
gridSpacing := 1.
^ self ].
gridSpacing := self defaultGridSpacing ]
ifFalse: [ gridSpacing := value ].
self createGrid ];
(self
checkZeroOrSubZeroGridSpacingValue:
value)
ifTrue: [
self defaultGridSpacing <= 0
ifTrue: [
gridSpacing := 1.
^ self ].
gridSpacing := self
defaultGridSpacing ]
ifFalse: [ gridSpacing := value ].
self class currentGridSpacing:
gridSpacing.
self createGrid ];
gridColorValue: self defaultGridColor;
whenColorValuesChangedDo: [ :color |
gridColor := color.
self createGrid ];
gridColor := color.
self class currentGridColor: color.
self createGrid ];
yourself.

workplacePropertiesView visibilityButton state: gridVisibility.


self defaultGridSpacing <= 0 ifTrue: [ gridSpacing := 1 ].
workplacePropertiesView spacingText value: gridSpacing.

Expand All @@ -271,8 +354,8 @@ PyramidMainExtension >> initialize [
help:
'Edit the properties of the workplace';
action: [
self workplacePropertiesPopover popup.
self refreshPopupWorkplaceProperties ];
self workplacePropertiesPopover popup.
self refreshPopupWorkplaceProperties ];
yourself.

"Creation of the pop-up"
Expand All @@ -286,8 +369,8 @@ PyramidMainExtension >> initialize [
containerElement := BlElement new
id: #MainExtension_containerElement;
constraintsDo: [ :c |
c vertical matchParent.
c horizontal matchParent ];
c vertical matchParent.
c horizontal matchParent ];
clipChildren: false;
zIndex: 0;
yourself.
Expand All @@ -298,8 +381,8 @@ PyramidMainExtension >> initialize [
border: self defaultBorder;
outskirts: BlOutskirts outside;
constraintsDo: [ :c |
c vertical matchParent.
c horizontal matchParent ];
c vertical matchParent.
c horizontal matchParent ];
clipChildren: false;
zIndex: 1;
preventMeAndChildrenMouseEvents;
Expand All @@ -309,18 +392,18 @@ PyramidMainExtension >> initialize [
gridElement := BlElement new
id: #MainExtension_gridElement;
constraintsDo: [ :c |
c vertical matchParent.
c horizontal matchParent ];
c vertical matchParent.
c horizontal matchParent ];
zIndex: 2.

borderElement addChild: gridElement.

sizeElement := BlElement new
id: #MainExtension_sizeElement;
extent: self defaultExtent;
clipChildren: false;
addChildren: {
containerElement .
containerElement.
borderElement } yourself
]

Expand Down Expand Up @@ -383,14 +466,6 @@ PyramidMainExtension >> sizeElement [
^ sizeElement
]

{ #category : #'as yet unclassified' }
PyramidMainExtension >> switchGridvisibility [
"Switch the visibility from true to false or false to true"
gridVisibility := self gridVisibility not.

^ self gridVisibility
]

{ #category : #accessing }
PyramidMainExtension >> workplacePropertiesButton [

Expand Down
Loading
Loading