From e3956db08ca41523f7b6c102961678607d4be34f Mon Sep 17 00:00:00 2001 From: Martin Dias Date: Wed, 26 Jun 2024 19:07:28 -0400 Subject: [PATCH] Improve box layout support (driven by ToDoList example) --- .../SpHorizontalLayoutDirection.extension.st | 9 +++++++++ src/Spec-Toplo/SpLayoutDirection.extension.st | 8 ++++++++ src/Spec-Toplo/SpToploBoxAdapter.class.st | 13 +++++++++++++ src/Spec-Toplo/SpToploLayoutAdapter.class.st | 7 +++++++ .../SpVerticalLayoutDirection.extension.st | 9 +++++++++ 5 files changed, 46 insertions(+) create mode 100644 src/Spec-Toplo/SpHorizontalLayoutDirection.extension.st create mode 100644 src/Spec-Toplo/SpLayoutDirection.extension.st create mode 100644 src/Spec-Toplo/SpVerticalLayoutDirection.extension.st diff --git a/src/Spec-Toplo/SpHorizontalLayoutDirection.extension.st b/src/Spec-Toplo/SpHorizontalLayoutDirection.extension.st new file mode 100644 index 0000000..c2ea60f --- /dev/null +++ b/src/Spec-Toplo/SpHorizontalLayoutDirection.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #SpHorizontalLayoutDirection } + +{ #category : #'*Spec-Toplo' } +SpHorizontalLayoutDirection >> setRigidityOfNonExpandedBlElement: aBlElement [ + + aBlElement + vMatchParent; + hFitContent +] diff --git a/src/Spec-Toplo/SpLayoutDirection.extension.st b/src/Spec-Toplo/SpLayoutDirection.extension.st new file mode 100644 index 0000000..104a14e --- /dev/null +++ b/src/Spec-Toplo/SpLayoutDirection.extension.st @@ -0,0 +1,8 @@ +Extension { #name : #SpLayoutDirection } + +{ #category : #'*Spec-Toplo' } +SpLayoutDirection >> setRigidityOfNonExpandedBlElement: aBlElement [ + "Set the layout contraints according to this direction. Inspired on the Morphic backend." + + self subclassResponsibility +] diff --git a/src/Spec-Toplo/SpToploBoxAdapter.class.st b/src/Spec-Toplo/SpToploBoxAdapter.class.st index 9fd09aa..4c51939 100644 --- a/src/Spec-Toplo/SpToploBoxAdapter.class.st +++ b/src/Spec-Toplo/SpToploBoxAdapter.class.st @@ -150,6 +150,19 @@ SpToploBoxAdapter >> updateAsExpandedChild: childBlElement with: aSpBoxConstrain childBlElement matchParent ] +{ #category : #'as yet unclassified' } +SpToploBoxAdapter >> updateAsNonExpandedChild: childBlElement with: aSpBoxConstraints [ + "Set up child to stay rigid in the layout direction." + + layout direction setRigidityOfNonExpandedBlElement: childBlElement. + aSpBoxConstraints width ifNotNil: [ :w | + 1 halt. + childBlElement width: w ]. + aSpBoxConstraints height ifNotNil: [ :h | + 1 halt. + childBlElement height: h ] +] + { #category : #'as yet unclassified' } SpToploBoxAdapter >> updateChildPadding: aBlElement with: aSpBoxConstraints [ diff --git a/src/Spec-Toplo/SpToploLayoutAdapter.class.st b/src/Spec-Toplo/SpToploLayoutAdapter.class.st index dbc60b4..0f8a677 100644 --- a/src/Spec-Toplo/SpToploLayoutAdapter.class.st +++ b/src/Spec-Toplo/SpToploLayoutAdapter.class.st @@ -42,6 +42,13 @@ SpToploLayoutAdapter >> buildWidget [ ^ nil ] +{ #category : #building } +SpToploLayoutAdapter >> buildWithSelector: aSelector [ + "Inspired on SpMorphicLayoutAdapter>>#buildWithSelector:" + + ^ self widget +] + { #category : #accessing } SpToploLayoutAdapter >> children [ "Debug API. Answer the widgets added to this layout." diff --git a/src/Spec-Toplo/SpVerticalLayoutDirection.extension.st b/src/Spec-Toplo/SpVerticalLayoutDirection.extension.st new file mode 100644 index 0000000..dc8c6e7 --- /dev/null +++ b/src/Spec-Toplo/SpVerticalLayoutDirection.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #SpVerticalLayoutDirection } + +{ #category : #'*Spec-Toplo' } +SpVerticalLayoutDirection >> setRigidityOfNonExpandedBlElement: aBlElement [ + + aBlElement + hMatchParent; + vFitContent +]