diff --git a/src/Pyramid-Bloc/PyramidDynamicResizer.class.st b/src/Pyramid-Bloc/PyramidDynamicResizer.class.st index 507c919d..1810b085 100644 --- a/src/Pyramid-Bloc/PyramidDynamicResizer.class.st +++ b/src/Pyramid-Bloc/PyramidDynamicResizer.class.st @@ -1,13 +1,14 @@ Class { #name : #PyramidDynamicResizer, #superclass : #Object, + #traits : 'TPyramidKeyboardExtension', + #classTraits : 'TPyramidKeyboardExtension classTrait', #instVars : [ 'pyramidSelectionWidgetExtension', 'pyramidPositionExtension', 'projectModel', 'editor', 'rightDynamicSize', - 'overlayElement', 'moveEventRight', 'bottomDynamicSize', 'moveEventBottom', @@ -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 [ @@ -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' } diff --git a/src/Pyramid-Bloc/PyramidFilteringListNavigationAddElementPlugin.class.st b/src/Pyramid-Bloc/PyramidFilteringListNavigationAddElementPlugin.class.st new file mode 100644 index 00000000..33a9250e --- /dev/null +++ b/src/Pyramid-Bloc/PyramidFilteringListNavigationAddElementPlugin.class.st @@ -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 +] diff --git a/src/Pyramid-Bloc/PyramidLibraryController.class.st b/src/Pyramid-Bloc/PyramidLibraryController.class.st index 43c2a811..9029ede1 100644 --- a/src/Pyramid-Bloc/PyramidLibraryController.class.st +++ b/src/Pyramid-Bloc/PyramidLibraryController.class.st @@ -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 } diff --git a/src/Pyramid-Bloc/PyramidLibraryPresenter.class.st b/src/Pyramid-Bloc/PyramidLibraryPresenter.class.st index 74b66c54..a97fa238 100644 --- a/src/Pyramid-Bloc/PyramidLibraryPresenter.class.st +++ b/src/Pyramid-Bloc/PyramidLibraryPresenter.class.st @@ -23,6 +23,12 @@ PyramidLibraryPresenter >> categoryPresenter [ ^ categoryPresenter ] +{ #category : #accessing } +PyramidLibraryPresenter >> categoryPresenter: anCategoryPresenter [ + + categoryPresenter := anCategoryPresenter +] + { #category : #initialization } PyramidLibraryPresenter >> connectPresenters [ @@ -70,6 +76,12 @@ PyramidLibraryPresenter >> elementPresenter [ ^ elementPresenter ] +{ #category : #accessing } +PyramidLibraryPresenter >> elementPresenter: anElementPresenter [ + + elementPresenter := anElementPresenter +] + { #category : #accessing } PyramidLibraryPresenter >> imagePresenter [ diff --git a/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st b/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st index d7a9ca5e..d2fd805f 100644 --- a/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st +++ b/src/Pyramid-Bloc/PyramidSelectionWidgetExtension.class.st @@ -120,7 +120,8 @@ PyramidSelectionWidgetExtension >> editor: aPyramidEditor [ self commandExecutor: aPyramidEditor commandExecutor. - pyramidDynamicResizer setupExtension: aPyramidEditor + pyramidDynamicResizer setupExtension: aPyramidEditor. + pyramidDynamicResizer builder: self builder ] { #category : #events } diff --git a/src/Pyramid-Bloc/PyramidSpacePlugin.class.st b/src/Pyramid-Bloc/PyramidSpacePlugin.class.st index c413e199..46e4cc5a 100644 --- a/src/Pyramid-Bloc/PyramidSpacePlugin.class.st +++ b/src/Pyramid-Bloc/PyramidSpacePlugin.class.st @@ -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' ]. ] diff --git a/src/Pyramid-Bloc/PyramidSpaceZoomPlugin.class.st b/src/Pyramid-Bloc/PyramidSpaceZoomPlugin.class.st index c0faff85..bf59a1c0 100644 --- a/src/Pyramid-Bloc/PyramidSpaceZoomPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidSpaceZoomPlugin.class.st @@ -262,7 +262,7 @@ PyramidSpaceZoomPlugin >> editScaleDisplayElement: aBlElement scaleValue: aValue pyramidSelectionWidgetExtension scaleFactor: self currentScaleFactor. pyramidPositionExtension scaleFactor: self currentScaleFactor. - self refreshScaledZoom. + self refreshScaledZoom: aBlElement. self installOnPixelGrid. @@ -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' } @@ -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 } diff --git a/src/Pyramid-Bloc/PyramidVisualPystonForCly.class.st b/src/Pyramid-Bloc/PyramidVisualPystonForCly.class.st index ce080c70..bd92ec7f 100644 --- a/src/Pyramid-Bloc/PyramidVisualPystonForCly.class.st +++ b/src/Pyramid-Bloc/PyramidVisualPystonForCly.class.st @@ -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 diff --git a/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st b/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st index d3238d93..a36f36d5 100644 --- a/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st +++ b/src/Pyramid-Toplo/PyramidToploThemePlugin.class.st @@ -41,7 +41,7 @@ PyramidToploThemePlugin class >> toploIconThemeCategoryFromClass: aClass withCat block: [ | image | image := ToImage new - size: 48 asPoint; + extent: 48 asPoint; innerImage: (PyramidExternalRessourceProxy new pyramidExternalRessourceSource: