From 1ce760bb683418323c2a15c2502f4d24372bb452 Mon Sep 17 00:00:00 2001 From: Yann Le Goff Date: Fri, 27 Sep 2024 10:27:17 +0200 Subject: [PATCH] Fix buttons serialization and remove tooltips TU --- .../ToButton.extension.st | 4 +- .../BlElement.extension.st | 8 ++++ .../TToCheckable.extension.st | 8 ++-- .../TToElementWithLabeledIcon.extension.st | 25 ------------ .../TToElementWithTooltip.extension.st | 7 +++- .../TToEnableable.extension.st | 8 ---- .../TToTripletElement.extension.st | 28 +++++++++++++ .../ToButton.extension.st | 9 ----- .../ToSerializerTest.class.st | 39 ------------------- .../TToElementWithPlaceholder.extension.st | 7 ---- src/Toplo-Serialization/ToPane.extension.st | 7 ++++ 11 files changed, 55 insertions(+), 95 deletions(-) delete mode 100644 src/Toplo-Serialization-Stash/TToElementWithLabeledIcon.extension.st delete mode 100644 src/Toplo-Serialization-Stash/TToEnableable.extension.st create mode 100644 src/Toplo-Serialization-Stash/TToTripletElement.extension.st delete mode 100644 src/Toplo-Serialization-Stash/ToButton.extension.st delete mode 100644 src/Toplo-Serialization/TToElementWithPlaceholder.extension.st create mode 100644 src/Toplo-Serialization/ToPane.extension.st diff --git a/src/Toplo-Serialization-STON/ToButton.extension.st b/src/Toplo-Serialization-STON/ToButton.extension.st index ab49373..2e08796 100644 --- a/src/Toplo-Serialization-STON/ToButton.extension.st +++ b/src/Toplo-Serialization-STON/ToButton.extension.st @@ -28,8 +28,8 @@ ToButton >> stonUserDataOn: aIdentityDictionary [ super stonUserDataOn: aIdentityDictionary. "LabeledIcon" - (self class usesTrait: TToElementWithLabeledIcon) ifTrue: [ - aIdentityDictionary at: #stonLabeledIcon put: self labeledIcon ]. + "(self class usesTrait: TToLabeledIcon) ifTrue: [ + aIdentityDictionary at: #stonLabeledIcon put: self labeledIcon ]." "Checkable" self isCheckable ifFalse: [ ^ self ]. diff --git a/src/Toplo-Serialization-Stash/BlElement.extension.st b/src/Toplo-Serialization-Stash/BlElement.extension.st index 30afb42..aa7ed1f 100644 --- a/src/Toplo-Serialization-Stash/BlElement.extension.st +++ b/src/Toplo-Serialization-Stash/BlElement.extension.st @@ -28,3 +28,11 @@ BlElement >> allSetterAndGettersForMyStashAllTokens [ ] + +{ #category : #'*Toplo-Serialization-Stash' } +BlElement >> stashEnabled [ + + + self isEnabled ifTrue: [ ^ { } ]. + ^ { (#enabled: -> #isEnabled) } +] diff --git a/src/Toplo-Serialization-Stash/TToCheckable.extension.st b/src/Toplo-Serialization-Stash/TToCheckable.extension.st index 2df4b58..947f1e9 100644 --- a/src/Toplo-Serialization-Stash/TToCheckable.extension.st +++ b/src/Toplo-Serialization-Stash/TToCheckable.extension.st @@ -1,12 +1,14 @@ Extension { #name : #TToCheckable } { #category : #'*Toplo-Serialization-Stash' } -TToCheckable >> allSetterAndGettersOfTraitForMyStash: aToElement [ +TToCheckable >> stashAccessorsForTToCheckable [ + | settersAndGetters | self isCheckable ifFalse: [ ^ { } ]. settersAndGetters := OrderedCollection new. - settersAndGetters add: #checked. - settersAndGetters add: #group. + settersAndGetters add: #initializeCheckable onlySetOnStash. + self checked ifTrue: [ settersAndGetters add: #checked ]. + self group ifNotNil: [ settersAndGetters add: #group ]. ^ settersAndGetters ] diff --git a/src/Toplo-Serialization-Stash/TToElementWithLabeledIcon.extension.st b/src/Toplo-Serialization-Stash/TToElementWithLabeledIcon.extension.st deleted file mode 100644 index 9f66a7a..0000000 --- a/src/Toplo-Serialization-Stash/TToElementWithLabeledIcon.extension.st +++ /dev/null @@ -1,25 +0,0 @@ -Extension { #name : #TToElementWithLabeledIcon } - -{ #category : #'*Toplo-Serialization-Stash' } -TToElementWithLabeledIcon >> allSetterAndGettersOfTraitForMyStash: aToElement [ - - | settersAndGetters | - settersAndGetters := OrderedCollection new. - aToElement isStartToEnd ifTrue: [ settersAndGetters add: (#beStartToEnd -> nil) onlySetOnStash ]. - aToElement isEndToStart ifTrue: [ settersAndGetters add: (#beEndToStart -> nil) onlySetOnStash ]. - - aToElement isVertical ifTrue: [ settersAndGetters add: (#isVertical -> nil) onlySetOnStash ]. - aToElement isHorizontal ifTrue: [ settersAndGetters add: (#isHorizontal -> nil) onlySetOnStash ]. - - settersAndGetters add: #endAlignment. - settersAndGetters add: #endElement. - settersAndGetters add: #endInterspace. - settersAndGetters add: #flexible. - settersAndGetters add: #icon. - settersAndGetters add: #iconContainerHeight. - settersAndGetters add: #iconContainerWidth. - settersAndGetters add: #label. - settersAndGetters add: #startAlignment. - settersAndGetters add: #startInterspace. - ^ settersAndGetters -] diff --git a/src/Toplo-Serialization-Stash/TToElementWithTooltip.extension.st b/src/Toplo-Serialization-Stash/TToElementWithTooltip.extension.st index e9b36c7..ae258b6 100644 --- a/src/Toplo-Serialization-Stash/TToElementWithTooltip.extension.st +++ b/src/Toplo-Serialization-Stash/TToElementWithTooltip.extension.st @@ -1,8 +1,11 @@ Extension { #name : #TToElementWithTooltip } { #category : #'*Toplo-Serialization-Stash' } -TToElementWithTooltip >> allSetterAndGettersOfTraitForMyStash: aToElement [ +TToElementWithTooltip >> stashAccessorsForTToElementWithTooltip [ + + self hasTooltip ifFalse: [ ^ { } ]. - ^ { #tooltipBuilder. #closeTooltipWindowOnMouseLeave . #tooltipPopupDelay } + ^ { #tooltipBuilder. #closeTooltipWindowOnMouseLeave. + #tooltipPopupDelay } ] diff --git a/src/Toplo-Serialization-Stash/TToEnableable.extension.st b/src/Toplo-Serialization-Stash/TToEnableable.extension.st deleted file mode 100644 index db1ccc9..0000000 --- a/src/Toplo-Serialization-Stash/TToEnableable.extension.st +++ /dev/null @@ -1,8 +0,0 @@ -Extension { #name : #TToEnableable } - -{ #category : #'*Toplo-Serialization-Stash' } -TToEnableable >> allSetterAndGettersOfTraitForMyStash: aToElement [ - - aToElement isEnabled ifTrue: [ ^ { } ]. - ^ { #enabled: -> #isEnabled } -] diff --git a/src/Toplo-Serialization-Stash/TToTripletElement.extension.st b/src/Toplo-Serialization-Stash/TToTripletElement.extension.st new file mode 100644 index 0000000..3b5380e --- /dev/null +++ b/src/Toplo-Serialization-Stash/TToTripletElement.extension.st @@ -0,0 +1,28 @@ +Extension { #name : #TToTripletElement } + +{ #category : #'*Toplo-Serialization-Stash' } +TToTripletElement >> stashAccessorsForTToTripletElement [ + + + + | settersAndGetters | + settersAndGetters := OrderedCollection new. + + self endAlignment ifNotNil: [ settersAndGetters add: #endAlignment ]. + self endElement ifNotNil: [ settersAndGetters add: #endElement ]. + self endFlexible ifTrue: [ settersAndGetters add: #endFlexible ]. + self endInterspace = 0 ifFalse: [ + settersAndGetters add: #endInterspace ]. + + self flexible ifTrue: [ settersAndGetters add: #flexible ]. + self middleElement ifNotNil: [ settersAndGetters add: #middleElement ]. + + self startAlignment ifNotNil: [ + settersAndGetters add: #startAlignment ]. + self startElement ifNotNil: [ settersAndGetters add: #startElement ]. + self startFlexible ifTrue: [ settersAndGetters add: #startFlexible ]. + self startInterspace = 0 ifFalse: [ + settersAndGetters add: #startInterspace ]. + + ^ settersAndGetters +] diff --git a/src/Toplo-Serialization-Stash/ToButton.extension.st b/src/Toplo-Serialization-Stash/ToButton.extension.st deleted file mode 100644 index 3ecfe1e..0000000 --- a/src/Toplo-Serialization-Stash/ToButton.extension.st +++ /dev/null @@ -1,9 +0,0 @@ -Extension { #name : #ToButton } - -{ #category : #'*Toplo-Serialization-Stash' } -ToButton >> stashToButtonCheckable [ - - - self isCheckable ifFalse: [ ^ { } ]. - ^ { (#beCheckable -> self) onlySetOnStash } -] diff --git a/src/Toplo-Serialization-Tests/ToSerializerTest.class.st b/src/Toplo-Serialization-Tests/ToSerializerTest.class.st index bbefa76..97d317e 100644 --- a/src/Toplo-Serialization-Tests/ToSerializerTest.class.st +++ b/src/Toplo-Serialization-Tests/ToSerializerTest.class.st @@ -368,42 +368,3 @@ ToSerializerTest >> testTokens [ self assert: (element valueOfTokenNamed: #hello) value equals: #goodbye. self assert: (element valueOfTokenNamed: #titi) value equals: #toto ] ] - -{ #category : #tests } -ToSerializerTest >> testTooltip1 [ - - | origin | - origin := ToElement new. - - self - test: origin - on: [ :element | self assert: element hasTooltip equals: false ] -] - -{ #category : #tests } -ToSerializerTest >> testTooltip2 [ - - | origin | - origin := ToElement new - tooltipText: 'hello tooltip'; - closeTooltipWindowOnMouseLeave: false; - yourself. - - self test: origin on: [ :element | - self assert: element hasTooltip. - self deny: element closeTooltipWindowOnMouseLeave. ] -] - -{ #category : #tests } -ToSerializerTest >> testTooltip3 [ - - | origin | - origin := ToElement new - tooltipText: 'hello tooltip'; - tooltipPopupDelay: 5; - yourself. - - self test: origin on: [ :element | - self assert: element hasTooltip. - self assert: element tooltipPopupDelay equals: 5 ] -] diff --git a/src/Toplo-Serialization/TToElementWithPlaceholder.extension.st b/src/Toplo-Serialization/TToElementWithPlaceholder.extension.st deleted file mode 100644 index 43f8369..0000000 --- a/src/Toplo-Serialization/TToElementWithPlaceholder.extension.st +++ /dev/null @@ -1,7 +0,0 @@ -Extension { #name : #TToElementWithPlaceholder } - -{ #category : #'*Toplo-Serialization' } -TToElementWithPlaceholder >> shouldSerializedChildren [ - - ^ true -] diff --git a/src/Toplo-Serialization/ToPane.extension.st b/src/Toplo-Serialization/ToPane.extension.st new file mode 100644 index 0000000..49b04ec --- /dev/null +++ b/src/Toplo-Serialization/ToPane.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #ToPane } + +{ #category : #'*Toplo-Serialization' } +ToPane >> shouldSerializedChildren [ + + ^ self class == ToPane +]