diff --git a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st index 0e8b6e10..51abeb67 100644 --- a/src/Pyramid-Bloc/PyramidBlocPlugin.class.st +++ b/src/Pyramid-Bloc/PyramidBlocPlugin.class.st @@ -84,6 +84,47 @@ PyramidBlocPlugin class >> visibility [ ^ property ] +{ #category : #accessing } +PyramidBlocPlugin class >> visibility2 [ + + | property | + property := PyramidProperty new + name: 'Visibility2'; + command: PyramidVisibilityCommand new; + inputPresenterClass: PyramidMagicButtonsInputPresenter; + yourself. + property inputPresenterModel + addButtonModel: (PyramidMagicButtonModel new + icon: (Smalltalk ui icons iconNamed: #windowMaximize); + helpSelected: 'The object is visible.'; + helpNotSelected: 'Set the value to visible.'; + label: 'Visible'; + inputValue: [ BlVisibility visible ]; + inputValidation: [ :value | value isVisible ]; + yourself); + addButtonModel: (PyramidMagicButtonModel new + icon: (Smalltalk ui icons iconNamed: #windowMaximize); + helpSelected: + 'The object is hidden. (Still computed for the layout)'; + helpNotSelected: + 'Set the value to hidden. (Still computed for the layout)'; + label: 'Hidden'; + inputValue: [ BlVisibility hidden ]; + inputValidation: [ :value | + value isHidden and: [ value isGone not ] ]; + yourself); + addButtonModel: (PyramidMagicButtonModel new + icon: (Smalltalk ui icons iconNamed: #windowMaximize); + helpSelected: 'The object is gone. (Not computed for the layout)'; + helpNotSelected: + 'Set the value to gone. (Not computed for the layout)'; + label: 'Gone'; + inputValue: [ BlVisibility gone ]; + inputValidation: [ :value | value isGone ]; + yourself). + ^ property +] + { #category : #accessing } PyramidBlocPlugin class >> zIndex [ @@ -192,13 +233,14 @@ PyramidBlocPlugin >> groupMenuBlockSingle [ PyramidBlocPlugin >> initialize [ super initialize. - + groupCommand := PyramidGroupCommand new. - + propertiesManager := PyramidPropertiesManagerForSelection new. propertiesManager addProperty: self class elementId. propertiesManager addProperty: self class visibility. + propertiesManager addProperty: self class visibility2. propertiesManager addProperty: self class zIndex. propertiesManager addProperty: self class clipChildren. propertiesManager addProperty: self class geometry. diff --git a/src/Pyramid-Bloc/PyramidElementsManipulationHelper.class.st b/src/Pyramid-Bloc/PyramidElementsManipulationHelper.class.st index 30c82f83..b1afef44 100644 --- a/src/Pyramid-Bloc/PyramidElementsManipulationHelper.class.st +++ b/src/Pyramid-Bloc/PyramidElementsManipulationHelper.class.st @@ -36,6 +36,17 @@ PyramidElementsManipulationHelper class >> accumulateParentsOf: aCollectionOfBlE self accumulateParentsOf: nextCollection in: result ] +{ #category : #'as yet unclassified' } +PyramidElementsManipulationHelper class >> countElementsIn: aCollection [ + + | result | + aCollection ifEmpty: [ ^ 0 ]. + result := aCollection size. + aCollection do: [ :each | + result := result + (self recursiveCountElementsIn: each) ]. + ^ result +] + { #category : #'as yet unclassified' } PyramidElementsManipulationHelper class >> flattenChildrenOfCollection: aCollection [ "Consider: @@ -79,3 +90,13 @@ PyramidElementsManipulationHelper class >> onlyParents: aCollectionOfBlElement [ self accumulateParentsOf: aCollectionOfBlElement in: result. ^ result asArray ] + +{ #category : #'as yet unclassified' } +PyramidElementsManipulationHelper class >> recursiveCountElementsIn: aBlElement [ + + | result | + aBlElement childrenCount = 0 ifTrue: [ ^ 0 ]. + result := aBlElement childrenCount. + aBlElement childrenDo: [ :each | result := result + (self recursiveCountElementsIn: each) ]. + ^ result +] diff --git a/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st b/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st index 5bab04d8..f37b41c2 100644 --- a/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st +++ b/src/Pyramid-Bloc/PyramidNavigationTreePresenter.class.st @@ -5,7 +5,8 @@ Class { 'navigationModel', 'treeTable', 'editor', - 'shouldUpdateSelection' + 'shouldUpdateSelection', + 'previousNumberOfElement' ], #category : #'Pyramid-Bloc-plugin-navigation' } @@ -127,6 +128,18 @@ PyramidNavigationTreePresenter >> navigationModel: anObject [ self treeTable expandAll ] ] +{ #category : #accessing } +PyramidNavigationTreePresenter >> previousNumberOfElement [ + + ^ previousNumberOfElement +] + +{ #category : #accessing } +PyramidNavigationTreePresenter >> previousNumberOfElement: anObject [ + + previousNumberOfElement := anObject +] + { #category : #api } PyramidNavigationTreePresenter >> roots: aCollection [ @@ -154,14 +167,23 @@ PyramidNavigationTreePresenter >> treeTable [ { #category : #'as yet unclassified' } PyramidNavigationTreePresenter >> updateRoots [ - | currentTreeRoots roots parent shouldOrder | + | currentTreeRoots roots parent shouldOrder calculatedNumberOfElement | self shouldUpdateSelection: false. roots := self editor projectModel firstLevelElements asArray. currentTreeRoots := self treeTable roots. - - (roots size = currentTreeRoots size and: [ roots includesAll: currentTreeRoots ] )ifTrue: [ self shouldUpdateSelection: true. ^ self ]. - + + (roots size = currentTreeRoots size and: [ + (roots includesAll: currentTreeRoots) and: [ + calculatedNumberOfElement := self editor projectModel + numberOfElements. + calculatedNumberOfElement = self previousNumberOfElement ] ]) + ifTrue: [ + self shouldUpdateSelection: true. + ^ self ]. + + self previousNumberOfElement: calculatedNumberOfElement. + parent := nil. "If roots all have the same parent then it should be ordered by the parent children order." diff --git a/src/Pyramid-Bloc/PyramidProjectModel.extension.st b/src/Pyramid-Bloc/PyramidProjectModel.extension.st index b4728115..c337776f 100644 --- a/src/Pyramid-Bloc/PyramidProjectModel.extension.st +++ b/src/Pyramid-Bloc/PyramidProjectModel.extension.st @@ -6,3 +6,10 @@ PyramidProjectModel >> allElements [ ^ PyramidElementsManipulationHelper flattenChildrenOfCollection: self firstLevelElements ] + +{ #category : #'*Pyramid-Bloc' } +PyramidProjectModel >> numberOfElements [ + + ^ PyramidElementsManipulationHelper countElementsIn: + self firstLevelElements. +] diff --git a/src/Pyramid-Tests/PyramidElementsManipulationHelperTest.class.st b/src/Pyramid-Tests/PyramidElementsManipulationHelperTest.class.st index 691ca691..f5dd54cf 100644 --- a/src/Pyramid-Tests/PyramidElementsManipulationHelperTest.class.st +++ b/src/Pyramid-Tests/PyramidElementsManipulationHelperTest.class.st @@ -38,6 +38,42 @@ D1 -> D2 -> D3. ] +{ #category : #'as yet unclassified' } +PyramidElementsManipulationHelperTest >> makeNestedElement: aNumber [ + + | origin current | + origin := current := BlElement new. + 2 to: aNumber do: [ :i | + | temp | + temp := BlElement new. + current addChild: temp. + current := temp ]. + ^ origin +] + +{ #category : #tests } +PyramidElementsManipulationHelperTest >> testCountElement [ + "selection := {A1 . B1 . B2 . C1 . C3}. + PyramidElementsManipulationHelper onlyParents: selection + returns: { A1 . B1 . C1 }" + + self + assert: (PyramidElementsManipulationHelper countElementsIn: { }) + equals: 0. + self + assert: (PyramidElementsManipulationHelper countElementsIn: + { (self makeNestedElement: 1) }) + equals: 1. + self + assert: (PyramidElementsManipulationHelper countElementsIn: + { (self makeNestedElement: 10) }) + equals: 10. + self + assert: (PyramidElementsManipulationHelper countElementsIn: + { (self makeNestedElement: 10) . (self makeNestedElement: 10) . (self makeNestedElement: 10) }) + equals: 30 +] + { #category : #tests } PyramidElementsManipulationHelperTest >> testFlattenChildrenOfCollection [ diff --git a/src/Pyramid/PyramidProjectModel.class.st b/src/Pyramid/PyramidProjectModel.class.st index 1d53fa03..4cb9ccf6 100644 --- a/src/Pyramid/PyramidProjectModel.class.st +++ b/src/Pyramid/PyramidProjectModel.class.st @@ -42,10 +42,10 @@ PyramidProjectModel >> firstLevelElements [ { #category : #'as yet unclassified' } PyramidProjectModel >> informElementsChanged [ - self announce: (PyramidElementsChangedEvent new - firstLevelElements: self firstLevelElements; - selection: self selection; - yourself) + self announce: (PyramidElementsChangedEvent new + firstLevelElements: self firstLevelElements; + selection: self selection; + yourself) ] { #category : #'as yet unclassified' }