11Class {
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 }
2842PyramidDynamicResizer >> createBottomAndRightResizerElement: aBlElement [
2943
@@ -228,36 +242,51 @@ PyramidDynamicResizer >> moveSpaceEventBottom: aBlElement [
228242{ #category : #' event creation' }
229243PyramidDynamicResizer >> 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' }
0 commit comments