Skip to content
Merged
63 changes: 46 additions & 17 deletions src/Pyramid-Bloc/PyramidDynamicResizer.class.st
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Class {
#name : #PyramidDynamicResizer,
#superclass : #Object,
#traits : 'TPyramidKeyboardExtension',
#classTraits : 'TPyramidKeyboardExtension classTrait',
#instVars : [
'pyramidSelectionWidgetExtension',
'pyramidPositionExtension',
'projectModel',
'editor',
'rightDynamicSize',
'overlayElement',
'moveEventRight',
'bottomDynamicSize',
'moveEventBottom',
Expand All @@ -19,11 +20,24 @@ Class {
'currentTranslation',
'positionOrigin',
'minimumSizeForBottomAndRight',
'resizeContainer'
'resizeContainer',
'builder'
],
#category : #'Pyramid-Bloc-plugin-space-extensions'
}

{ #category : #accessing }
PyramidDynamicResizer >> builder [

^ builder
]

{ #category : #accessing }
PyramidDynamicResizer >> builder: aBuilder [

builder := aBuilder
]

{ #category : #adding }
PyramidDynamicResizer >> createBottomAndRightResizerElement: aBlElement [

Expand Down Expand Up @@ -228,36 +242,51 @@ PyramidDynamicResizer >> moveSpaceEventBottom: aBlElement [
{ #category : #'event creation' }
PyramidDynamicResizer >> moveSpaceEventBottomAndRight: aBlElement [

| ratio initialeSize newWidth newHeight candidateWidth candidateHeight |

^ BlEventHandler
on: BlMouseMoveEvent
do: [ :evt |
evt primaryButtonPressed
ifFalse: [
on: BlMouseMoveEvent
do: [ :evt |
evt primaryButtonPressed
ifFalse: [
evt consumed: true.
self resizeCommand: aBlElement with: aBlElement extent.
aBlElement userData removeKey: #pyramidPreviousDynamicResize.
pyramidSelectionWidgetExtension elementAtEvents
removeEventHandler: moveEventBottomAndRight ]
ifTrue: [
pyramidSelectionWidgetExtension movingForGrid:
aBlElement position.
self currentTranslation:
pyramidPositionExtension position - self positionOrigin.
aBlElement extent: self currentTranslation x
ifTrue: [
pyramidSelectionWidgetExtension movingForGrid: aBlElement position.
self isOnlyCtrlKeyPressed
ifTrue: [
initialeSize := aBlElement userData at: #pyramidPreviousDynamicResize.
ratio := initialeSize x / initialeSize y.
candidateWidth := (pyramidPositionExtension position x - self positionOrigin x).
candidateHeight := (pyramidPositionExtension position y - self positionOrigin y).

((candidateWidth / candidateHeight) > ratio)
ifTrue: [ newHeight := candidateHeight.
newWidth := (newHeight * ratio) ]
ifFalse: [ newWidth := candidateWidth.
newHeight := (newWidth / ratio) ].
self currentTranslation: (newWidth @ newHeight) ]
ifFalse: [ self currentTranslation:
pyramidPositionExtension position - self positionOrigin. ].

aBlElement extent: self currentTranslation x
- pyramidSelectionWidgetExtension movingForGrid x
@ (self currentTranslation y
- pyramidSelectionWidgetExtension movingForGrid y).
aBlElement extent y < minimumSizeForRightOrBottom

aBlElement extent y < minimumSizeForRightOrBottom
ifTrue: [ rightDynamicSize extent: 0 @ 0 ]
ifFalse: [ rightDynamicSize extent: resizeElementSize ].
aBlElement extent x < minimumSizeForRightOrBottom
aBlElement extent x < minimumSizeForRightOrBottom
ifTrue: [ bottomDynamicSize extent: 0 @ 0 ]
ifFalse: [ bottomDynamicSize extent: resizeElementSize ].
(aBlElement extent x < minimumSizeForBottomAndRight and: [
(aBlElement extent x < minimumSizeForBottomAndRight and: [
aBlElement extent y < minimumSizeForBottomAndRight ])
ifTrue: [ bottomAndRightDynamicSize extent: 0 @ 0 ]
ifFalse: [
bottomAndRightDynamicSize extent: resizeElementSize ] ] ]
ifFalse: [ bottomAndRightDynamicSize extent: resizeElementSize ] ] ]
]

{ #category : #'event creation' }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Class {
#name : #PyramidFilteringListNavigationAddElementPlugin,
#superclass : #Object,
#traits : 'TPyramidPlugin',
#classTraits : 'TPyramidPlugin classTrait',
#instVars : [
'navigationPlugin',
'libraryPresenter'
],
#category : #'Pyramid-Bloc-plugin-filtering-list-navigation-add-element'
}

{ #category : #connecting }
PyramidFilteringListNavigationAddElementPlugin >> connectOn: aPyramidEditor [

self pluginFromPyramid: aPyramidEditor.

libraryPresenter ifNil: [ ^ self ].

self installOnAddElementFilteringList.

libraryPresenter libraryController initializeCategories.




]

{ #category : #'as yet unclassified' }
PyramidFilteringListNavigationAddElementPlugin >> installOnAddElementFilteringList [

| elementPresenter categoryPresenter |

elementPresenter := SpFilteringListPresenter new
display: [ :class | class name ];
displayIcon: [ :each | each icon ].
elementPresenter whenSelectionChangedDo: [ :e |
| index element |
index := e selectedIndex.
index <= 0 ifFalse: [
element := elementPresenter items at: index.
libraryPresenter addButtonPresenter enabled: element isNotNil.
libraryPresenter addButtonPresenter action: [
libraryPresenter libraryController addNewElement: element ].
element
ifNil: [ libraryPresenter imagePresenter image: (Form extent: 1 asPoint) ]
ifNotNil: [ libraryPresenter imagePresenter image: element asForm ] ] ].

categoryPresenter := SpFilteringListPresenter new
display: [ :class | class name ];
displayIcon: [ :each | each icon ].
categoryPresenter whenSelectionChangedDo: [ :category | | index elements |
index := category selectedIndex.
index <= 0 ifFalse: [
elements := (categoryPresenter items at: index).
elementPresenter items: elements elements.
elementPresenter selectItem: elementPresenter items first ] ].

libraryPresenter categoryPresenter: categoryPresenter.
libraryPresenter elementPresenter: elementPresenter.
]

{ #category : #'accessing - classes' }
PyramidFilteringListNavigationAddElementPlugin >> pluginFromPyramid: aPyramidEditor [

| listOfPlugins pluginSorted |
listOfPlugins := aPyramidEditor plugins.
pluginSorted := listOfPlugins select: [ :extensions | extensions isKindOf: PyramidNavigationPlugin ].
pluginSorted size = 1
ifFalse: [^ self].
navigationPlugin := pluginSorted asArray first.

libraryPresenter := navigationPlugin navigation library
]
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidLibraryController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PyramidLibraryController >> addCategories: aCollection [
self library categoryPresenter items = aCollection ifTrue: [ ^ self ].
self library categoryPresenter
items: aCollection;
selectIndex: 1
selectItem: aCollection first
]

{ #category : #accessing }
Expand Down
12 changes: 12 additions & 0 deletions src/Pyramid-Bloc/PyramidLibraryPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ PyramidLibraryPresenter >> categoryPresenter [
^ categoryPresenter
]

{ #category : #accessing }
PyramidLibraryPresenter >> categoryPresenter: anCategoryPresenter [

categoryPresenter := anCategoryPresenter
]

{ #category : #initialization }
PyramidLibraryPresenter >> connectPresenters [

Expand Down Expand Up @@ -70,6 +76,12 @@ PyramidLibraryPresenter >> elementPresenter [
^ elementPresenter
]

{ #category : #accessing }
PyramidLibraryPresenter >> elementPresenter: anElementPresenter [

elementPresenter := anElementPresenter
]

{ #category : #accessing }
PyramidLibraryPresenter >> imagePresenter [

Expand Down
3 changes: 2 additions & 1 deletion src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ PyramidSelectionWidgetExtension >> editor: aPyramidEditor [
self commandExecutor:
aPyramidEditor commandExecutor.

pyramidDynamicResizer setupExtension: aPyramidEditor
pyramidDynamicResizer setupExtension: aPyramidEditor.
pyramidDynamicResizer builder: self builder
]

{ #category : #events }
Expand Down
13 changes: 7 additions & 6 deletions src/Pyramid-Bloc/PyramidSpacePlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ PyramidSpacePlugin >> defaultShortcutsForEditor: aPyramidEditor [
KeyboardKey space control unix |
KeyboardKey space control win
action: [
aPyramidEditor projectModel selection size = 1 ifFalse: [ ^ self ].
aPyramidEditor projectModel selection first.
aPyramidEditor commandExecutor
use: PyramidPositionCommand new
on: { aPyramidEditor projectModel selection first }
with: (pyramidPositionExtension asArray first) position ]
aPyramidEditor projectModel selection size = 1
ifTrue: [
aPyramidEditor projectModel selection first.
aPyramidEditor commandExecutor
use: PyramidPositionCommand new
on: { aPyramidEditor projectModel selection first }
with: (pyramidPositionExtension asArray first) position ] ]
name: 'Shortcut Spec Move element to the mouse position' ].
]

Expand Down
12 changes: 4 additions & 8 deletions src/Pyramid-Bloc/PyramidSpaceZoomPlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ PyramidSpaceZoomPlugin >> editScaleDisplayElement: aBlElement scaleValue: aValue
pyramidSelectionWidgetExtension scaleFactor: self currentScaleFactor.
pyramidPositionExtension scaleFactor: self currentScaleFactor.

self refreshScaledZoom.
self refreshScaledZoom: aBlElement.

self installOnPixelGrid.

Expand Down Expand Up @@ -298,7 +298,7 @@ PyramidSpaceZoomPlugin >> initialize [
"imagePixel := self class imagePixelGrid2000x2000WhiteLine1x."
"imagePixel := self class imagePixelGrid2000x2000BlackDot4x4."
"imagePixel := self class imagePixelGrid2000x2000WhiteDot4x4."
pixelGridEnable := false.
pixelGridEnable := false
]

{ #category : #'as yet unclassified' }
Expand Down Expand Up @@ -420,13 +420,9 @@ PyramidSpaceZoomPlugin >> refreshPixelGrid: aPoint [
]

{ #category : #'as yet unclassified' }
PyramidSpaceZoomPlugin >> refreshScaledZoom [
PyramidSpaceZoomPlugin >> refreshScaledZoom: aBlElement [

scaledZoom := pyramidSelectionWidgetExtension elementAtMain extent x
* (self currentScaleFactor - 1 / 2)
@
(pyramidSelectionWidgetExtension elementAtMain extent y
* (self currentScaleFactor - 1 / 2))
scaledZoom := (aBlElement extent * (self currentScaleFactor - 1)) / 2.
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/Pyramid-Bloc/PyramidVisualPystonForCly.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ PyramidVisualPystonForCly >> update [
blElement isCollection ifTrue: [
blElement := BlElement new
addChildren: blElement;
size: 1500 @ 1500;
extent: 1500 @ 1500;
yourself ].

imageMorph form: blElement exportAsForm
Expand Down
2 changes: 1 addition & 1 deletion src/Pyramid-Toplo/PyramidToploThemePlugin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ PyramidToploThemePlugin class >> toploIconThemeCategoryFromClass: aClass withCat
block: [
| image |
image := ToImage new
size: 48 asPoint;
extent: 48 asPoint;
innerImage:
(PyramidExternalRessourceProxy new
pyramidExternalRessourceSource:
Expand Down
Loading