Skip to content

Commit 8133ba3

Browse files
authored
Merge pull request #245 from OpenSmock/devStage
Dev stage - Add new plugin filtering list for the add element presenter
2 parents da7bcb5 + 674ac77 commit 8133ba3

9 files changed

Lines changed: 148 additions & 35 deletions

src/Pyramid-Bloc/PyramidDynamicResizer.class.st

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Class {
22
#name : #PyramidDynamicResizer,
33
#superclass : #Object,
4+
#traits : 'TPyramidKeyboardExtension',
5+
#classTraits : 'TPyramidKeyboardExtension classTrait',
46
#instVars : [
57
'pyramidSelectionWidgetExtension',
68
'pyramidPositionExtension',
79
'projectModel',
810
'editor',
911
'rightDynamicSize',
10-
'overlayElement',
1112
'moveEventRight',
1213
'bottomDynamicSize',
1314
'moveEventBottom',
@@ -19,11 +20,24 @@ Class {
1920
'currentTranslation',
2021
'positionOrigin',
2122
'minimumSizeForBottomAndRight',
22-
'resizeContainer'
23+
'resizeContainer',
24+
'builder'
2325
],
2426
#category : #'Pyramid-Bloc-plugin-space-extensions'
2527
}
2628

29+
{ #category : #accessing }
30+
PyramidDynamicResizer >> builder [
31+
32+
^ builder
33+
]
34+
35+
{ #category : #accessing }
36+
PyramidDynamicResizer >> builder: aBuilder [
37+
38+
builder := aBuilder
39+
]
40+
2741
{ #category : #adding }
2842
PyramidDynamicResizer >> createBottomAndRightResizerElement: aBlElement [
2943

@@ -228,36 +242,51 @@ PyramidDynamicResizer >> moveSpaceEventBottom: aBlElement [
228242
{ #category : #'event creation' }
229243
PyramidDynamicResizer >> moveSpaceEventBottomAndRight: aBlElement [
230244

245+
| ratio initialeSize newWidth newHeight candidateWidth candidateHeight |
246+
231247
^ BlEventHandler
232-
on: BlMouseMoveEvent
233-
do: [ :evt |
234-
evt primaryButtonPressed
235-
ifFalse: [
248+
on: BlMouseMoveEvent
249+
do: [ :evt |
250+
evt primaryButtonPressed
251+
ifFalse: [
236252
evt consumed: true.
237253
self resizeCommand: aBlElement with: aBlElement extent.
238254
aBlElement userData removeKey: #pyramidPreviousDynamicResize.
239255
pyramidSelectionWidgetExtension elementAtEvents
240256
removeEventHandler: moveEventBottomAndRight ]
241-
ifTrue: [
242-
pyramidSelectionWidgetExtension movingForGrid:
243-
aBlElement position.
244-
self currentTranslation:
245-
pyramidPositionExtension position - self positionOrigin.
246-
aBlElement extent: self currentTranslation x
257+
ifTrue: [
258+
pyramidSelectionWidgetExtension movingForGrid: aBlElement position.
259+
self isOnlyCtrlKeyPressed
260+
ifTrue: [
261+
initialeSize := aBlElement userData at: #pyramidPreviousDynamicResize.
262+
ratio := initialeSize x / initialeSize y.
263+
candidateWidth := (pyramidPositionExtension position x - self positionOrigin x).
264+
candidateHeight := (pyramidPositionExtension position y - self positionOrigin y).
265+
266+
((candidateWidth / candidateHeight) > ratio)
267+
ifTrue: [ newHeight := candidateHeight.
268+
newWidth := (newHeight * ratio) ]
269+
ifFalse: [ newWidth := candidateWidth.
270+
newHeight := (newWidth / ratio) ].
271+
self currentTranslation: (newWidth @ newHeight) ]
272+
ifFalse: [ self currentTranslation:
273+
pyramidPositionExtension position - self positionOrigin. ].
274+
275+
aBlElement extent: self currentTranslation x
247276
- pyramidSelectionWidgetExtension movingForGrid x
248277
@ (self currentTranslation y
249278
- pyramidSelectionWidgetExtension movingForGrid y).
250-
aBlElement extent y < minimumSizeForRightOrBottom
279+
280+
aBlElement extent y < minimumSizeForRightOrBottom
251281
ifTrue: [ rightDynamicSize extent: 0 @ 0 ]
252282
ifFalse: [ rightDynamicSize extent: resizeElementSize ].
253-
aBlElement extent x < minimumSizeForRightOrBottom
283+
aBlElement extent x < minimumSizeForRightOrBottom
254284
ifTrue: [ bottomDynamicSize extent: 0 @ 0 ]
255285
ifFalse: [ bottomDynamicSize extent: resizeElementSize ].
256-
(aBlElement extent x < minimumSizeForBottomAndRight and: [
286+
(aBlElement extent x < minimumSizeForBottomAndRight and: [
257287
aBlElement extent y < minimumSizeForBottomAndRight ])
258288
ifTrue: [ bottomAndRightDynamicSize extent: 0 @ 0 ]
259-
ifFalse: [
260-
bottomAndRightDynamicSize extent: resizeElementSize ] ] ]
289+
ifFalse: [ bottomAndRightDynamicSize extent: resizeElementSize ] ] ]
261290
]
262291

263292
{ #category : #'event creation' }
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
Class {
2+
#name : #PyramidFilteringListNavigationAddElementPlugin,
3+
#superclass : #Object,
4+
#traits : 'TPyramidPlugin',
5+
#classTraits : 'TPyramidPlugin classTrait',
6+
#instVars : [
7+
'navigationPlugin',
8+
'libraryPresenter'
9+
],
10+
#category : #'Pyramid-Bloc-plugin-filtering-list-navigation-add-element'
11+
}
12+
13+
{ #category : #connecting }
14+
PyramidFilteringListNavigationAddElementPlugin >> connectOn: aPyramidEditor [
15+
16+
self pluginFromPyramid: aPyramidEditor.
17+
18+
libraryPresenter ifNil: [ ^ self ].
19+
20+
self installOnAddElementFilteringList.
21+
22+
libraryPresenter libraryController initializeCategories.
23+
24+
25+
26+
27+
]
28+
29+
{ #category : #'as yet unclassified' }
30+
PyramidFilteringListNavigationAddElementPlugin >> installOnAddElementFilteringList [
31+
32+
| elementPresenter categoryPresenter |
33+
34+
elementPresenter := SpFilteringListPresenter new
35+
display: [ :class | class name ];
36+
displayIcon: [ :each | each icon ].
37+
elementPresenter whenSelectionChangedDo: [ :e |
38+
| index element |
39+
index := e selectedIndex.
40+
index <= 0 ifFalse: [
41+
element := elementPresenter items at: index.
42+
libraryPresenter addButtonPresenter enabled: element isNotNil.
43+
libraryPresenter addButtonPresenter action: [
44+
libraryPresenter libraryController addNewElement: element ].
45+
element
46+
ifNil: [ libraryPresenter imagePresenter image: (Form extent: 1 asPoint) ]
47+
ifNotNil: [ libraryPresenter imagePresenter image: element asForm ] ] ].
48+
49+
categoryPresenter := SpFilteringListPresenter new
50+
display: [ :class | class name ];
51+
displayIcon: [ :each | each icon ].
52+
categoryPresenter whenSelectionChangedDo: [ :category | | index elements |
53+
index := category selectedIndex.
54+
index <= 0 ifFalse: [
55+
elements := (categoryPresenter items at: index).
56+
elementPresenter items: elements elements.
57+
elementPresenter selectItem: elementPresenter items first ] ].
58+
59+
libraryPresenter categoryPresenter: categoryPresenter.
60+
libraryPresenter elementPresenter: elementPresenter.
61+
]
62+
63+
{ #category : #'accessing - classes' }
64+
PyramidFilteringListNavigationAddElementPlugin >> pluginFromPyramid: aPyramidEditor [
65+
66+
| listOfPlugins pluginSorted |
67+
listOfPlugins := aPyramidEditor plugins.
68+
pluginSorted := listOfPlugins select: [ :extensions | extensions isKindOf: PyramidNavigationPlugin ].
69+
pluginSorted size = 1
70+
ifFalse: [^ self].
71+
navigationPlugin := pluginSorted asArray first.
72+
73+
libraryPresenter := navigationPlugin navigation library
74+
]

src/Pyramid-Bloc/PyramidLibraryController.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ PyramidLibraryController >> addCategories: aCollection [
1717
self library categoryPresenter items = aCollection ifTrue: [ ^ self ].
1818
self library categoryPresenter
1919
items: aCollection;
20-
selectIndex: 1
20+
selectItem: aCollection first
2121
]
2222

2323
{ #category : #accessing }

src/Pyramid-Bloc/PyramidLibraryPresenter.class.st

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ PyramidLibraryPresenter >> categoryPresenter [
2323
^ categoryPresenter
2424
]
2525

26+
{ #category : #accessing }
27+
PyramidLibraryPresenter >> categoryPresenter: anCategoryPresenter [
28+
29+
categoryPresenter := anCategoryPresenter
30+
]
31+
2632
{ #category : #initialization }
2733
PyramidLibraryPresenter >> connectPresenters [
2834

@@ -70,6 +76,12 @@ PyramidLibraryPresenter >> elementPresenter [
7076
^ elementPresenter
7177
]
7278

79+
{ #category : #accessing }
80+
PyramidLibraryPresenter >> elementPresenter: anElementPresenter [
81+
82+
elementPresenter := anElementPresenter
83+
]
84+
7385
{ #category : #accessing }
7486
PyramidLibraryPresenter >> imagePresenter [
7587

src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ PyramidSelectionWidgetExtension >> editor: aPyramidEditor [
120120
self commandExecutor:
121121
aPyramidEditor commandExecutor.
122122

123-
pyramidDynamicResizer setupExtension: aPyramidEditor
123+
pyramidDynamicResizer setupExtension: aPyramidEditor.
124+
pyramidDynamicResizer builder: self builder
124125
]
125126

126127
{ #category : #events }

src/Pyramid-Bloc/PyramidSpacePlugin.class.st

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ PyramidSpacePlugin >> defaultShortcutsForEditor: aPyramidEditor [
6868
KeyboardKey space control unix |
6969
KeyboardKey space control win
7070
action: [
71-
aPyramidEditor projectModel selection size = 1 ifFalse: [ ^ self ].
72-
aPyramidEditor projectModel selection first.
73-
aPyramidEditor commandExecutor
74-
use: PyramidPositionCommand new
75-
on: { aPyramidEditor projectModel selection first }
76-
with: (pyramidPositionExtension asArray first) position ]
71+
aPyramidEditor projectModel selection size = 1
72+
ifTrue: [
73+
aPyramidEditor projectModel selection first.
74+
aPyramidEditor commandExecutor
75+
use: PyramidPositionCommand new
76+
on: { aPyramidEditor projectModel selection first }
77+
with: (pyramidPositionExtension asArray first) position ] ]
7778
name: 'Shortcut Spec Move element to the mouse position' ].
7879
]
7980

src/Pyramid-Bloc/PyramidSpaceZoomPlugin.class.st

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ PyramidSpaceZoomPlugin >> editScaleDisplayElement: aBlElement scaleValue: aValue
262262
pyramidSelectionWidgetExtension scaleFactor: self currentScaleFactor.
263263
pyramidPositionExtension scaleFactor: self currentScaleFactor.
264264

265-
self refreshScaledZoom.
265+
self refreshScaledZoom: aBlElement.
266266

267267
self installOnPixelGrid.
268268

@@ -298,7 +298,7 @@ PyramidSpaceZoomPlugin >> initialize [
298298
"imagePixel := self class imagePixelGrid2000x2000WhiteLine1x."
299299
"imagePixel := self class imagePixelGrid2000x2000BlackDot4x4."
300300
"imagePixel := self class imagePixelGrid2000x2000WhiteDot4x4."
301-
pixelGridEnable := false.
301+
pixelGridEnable := false
302302
]
303303

304304
{ #category : #'as yet unclassified' }
@@ -420,13 +420,9 @@ PyramidSpaceZoomPlugin >> refreshPixelGrid: aPoint [
420420
]
421421

422422
{ #category : #'as yet unclassified' }
423-
PyramidSpaceZoomPlugin >> refreshScaledZoom [
423+
PyramidSpaceZoomPlugin >> refreshScaledZoom: aBlElement [
424424

425-
scaledZoom := pyramidSelectionWidgetExtension elementAtMain extent x
426-
* (self currentScaleFactor - 1 / 2)
427-
@
428-
(pyramidSelectionWidgetExtension elementAtMain extent y
429-
* (self currentScaleFactor - 1 / 2))
425+
scaledZoom := (aBlElement extent * (self currentScaleFactor - 1)) / 2.
430426
]
431427

432428
{ #category : #accessing }

src/Pyramid-Bloc/PyramidVisualPystonForCly.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ PyramidVisualPystonForCly >> update [
242242
blElement isCollection ifTrue: [
243243
blElement := BlElement new
244244
addChildren: blElement;
245-
size: 1500 @ 1500;
245+
extent: 1500 @ 1500;
246246
yourself ].
247247

248248
imageMorph form: blElement exportAsForm

src/Pyramid-Toplo/PyramidToploThemePlugin.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ PyramidToploThemePlugin class >> toploIconThemeCategoryFromClass: aClass withCat
4141
block: [
4242
| image |
4343
image := ToImage new
44-
size: 48 asPoint;
44+
extent: 48 asPoint;
4545
innerImage:
4646
(PyramidExternalRessourceProxy new
4747
pyramidExternalRessourceSource:

0 commit comments

Comments
 (0)