From 21740844ccf4fcc5b73a085efa944f866dc5550a Mon Sep 17 00:00:00 2001 From: Thiago da Silva Lino Date: Thu, 16 Oct 2025 13:08:05 -0300 Subject: [PATCH] Fix LayoutSpec usage and other issues --- chapter-02/contents.texinfo | 16 ++++++++-------- chapter-04/contents.texinfo | 16 ++++++++-------- chapter-05/contents.texinfo | 4 ++-- misc/MemoryGameV1-untabbed.pck.st | 2 +- misc/MemoryGameV1.pck.st | 2 +- misc/MemoryGameV2-untabbed.pck.st | 2 +- misc/MemoryGameV2.pck.st | 2 +- misc/MemoryGameV3-untabbed.pck.st | 2 +- misc/MemoryGameV3.pck.st | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/chapter-02/contents.texinfo b/chapter-02/contents.texinfo index ab0b945..16551c9 100644 --- a/chapter-02/contents.texinfo +++ b/chapter-02/contents.texinfo @@ -188,7 +188,7 @@ subclasses: Instances of @class{LayoutSpec} have @smalltalk{morph} as an instance variable. There are methods to set each of these instance variables. -@smalltalkExample{box2 layoutSpec proportionalWidth: 1} +@smalltalkExample{box2 layoutSpec: (LayoutSpec proportionalWidth: 1)} @figure{Using proportionalWidth, ch03-layoutmorph-example7, 6} @@ -198,7 +198,7 @@ message @msg{add:proportionWidth:} which adds a submorph and sets the However, an issue with this approach is that it creates a new instance of @class{LayoutSizeSpec} and sets both @smalltalk{proportionalWidth} and @smalltalk{proportionalHeight} to 1. To modify only one of those -properties, it is best to set it directly on the @class{LayoutSizedSpec} +properties, it is best to set it directly on the @class{LayoutSizeSpec} instance of the morph. @cindex layout @subentry spacer @@ -211,9 +211,9 @@ box1 := ColoredBoxMorph new color: Color red; morphExtent: 50 @@ 75. box2 := ColoredBoxMorph new color: Color green; morphExtent: 75 @@ 50. box3 := ColoredBoxMorph new color: Color blue; morphExtent: 100 @@ 100. spacer1 := ColoredBoxMorph new color: Color transparent. -spacer1 layoutSpec proportionalWidth: 1. +spacer1 layoutSpec: (LayoutSpec proportionalWidth: 1). spacer2 := ColoredBoxMorph new color: Color transparent. -spacer2 layoutSpec proportionalWidth: 1. +spacer2 layoutSpec: (LayoutSpec proportionalWidth: 1). layout := LayoutMorph newRow morphExtent: 350 @@ 150; separation: 10; @@ -246,14 +246,14 @@ column1 := LayoutMorph newColumn addMorph: (LabelMorph contents: 'Apple'); addMorph: (LabelMorph contents: 'Banana'); addMorph: (LabelMorph contents: 'Cherry'). -column1 layoutSpec proportionalHeight: 0. "defaults to 1" +column1 layoutSpec: (LayoutSpec proportionalHeight: 0). "defaults to 1" column2 := LayoutMorph newColumn addMorph: (LabelMorph contents: 'Spring'); addMorph: (LabelMorph contents: 'Winter'); addMorph: (LabelMorph contents: 'Summer'); addMorph: (LabelMorph contents: 'Fall'). -column2 layoutSpec proportionalHeight: 0. "defaults to 1" +column2 layoutSpec: (LayoutSpec proportionalHeight: 0). "defaults to 1" row := LayoutMorph newRow separation: 20; @@ -277,7 +277,7 @@ column1 := LayoutMorph newColumn addMorph: (LabelMorph contents: 'Banana'); addMorph: (LabelMorph contents: 'Cherry'); borderColor: Color red; borderWidth: 2. -column1 layoutSpec proportionalHeight: 0. +column1 layoutSpec: (LayoutSpec proportionalHeight: 0). column2 := LayoutMorph newColumn addMorph: (LabelMorph contents: 'Spring'); @@ -285,7 +285,7 @@ column2 := LayoutMorph newColumn addMorph: (LabelMorph contents: 'Summer'); addMorph: (LabelMorph contents: 'Fall'); borderColor: Color blue; borderWidth: 2. -column2 layoutSpec proportionalHeight: 0. +column2 layoutSpec: (LayoutSpec proportionalHeight: 0). center := LabelMorph contents: 'What are your favorites?' :: borderColor: Color green; borderWidth: 2. diff --git a/chapter-04/contents.texinfo b/chapter-04/contents.texinfo index 709bc3b..3f00844 100644 --- a/chapter-04/contents.texinfo +++ b/chapter-04/contents.texinfo @@ -69,8 +69,8 @@ button morphExtent: (extent x + 15) @@ extent y. layout := window layoutMorph. layout padding: 10. window - morphExtent: 300 @@ layout minimumExtent y; - openInWorld.} + openInWorld; + morphExtent: 300 @@ layout minimumExtent y.} @smalltalkMethod{toggleColor, layout color: ( @@ -619,7 +619,7 @@ colorList := PluggableListMorph listGetter: #colors indexGetter: #selectedColorIndex indexSetter: #selectedColorIndex:. -colorList layoutSpec proportionalWidth: 1. +colorList layoutSpec: (LayoutSpec proportionalWidth: 1). newColorEntry := self textEntryOn: #newColor. newColorEntry emptyTextDisplayMessage: 'new color'. @@ -652,7 +652,7 @@ self selectedColorIndex: 0. "Set window size to the smallest height that contains its submorphs." layout := window layoutMorph. layout separation: 10. -window morphExtent: 250 @ layout minimumExtent y} +window morphExtent: 250 @@ layout minimumExtent y} Observe at the beginning of the @method{initialize} method the creation of the list; its model is @smalltalk{self}, therefore an @@ -695,7 +695,7 @@ potentialColor := aText asString withBlanksTrimmed. potentialColor ifNotEmpty: [ colors add: potentialColor asSymbol. colorList updateList. - self selectedColorIndex: (colors indexOf: potentialColor ) + self selectedColorIndex: (colors indexOf: potentialColor ). self changed: #clearUserEdits. self changed: #newColor ]} @@ -720,7 +720,7 @@ color of the window. selectedColorIndex := anIndex. selected := anIndex ~= 0. -deleteButton enable: selected. +deleteButton enableSelector: selected. colorName := selected ifTrue: [ colors at: anIndex ]. selectedLabel contents: (colorName @@ -743,7 +743,7 @@ entry := TextModelMorph hideScrollBarsIndefinitely. entry morphExtent: 0 @@ 0. -entry layoutSpec proportionalWidth: 1. +entry layoutSpec: (LayoutSpec proportionalWidth: 1). @return{} entry} @node Memory game @@ -882,7 +882,7 @@ colors := self distributeColors shuffled. row := LayoutMorph newRow. 1 to: size x do: [:x | | card | card := MemoryCard model: self action: #flip: actionArgument: x@@y. - card layoutSpec proportionalWidth: 1; proportionalHeight: 1. + card layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). card cardColor: colors removeFirst. row addMorph: card. cards at: x@@y put: card ]. diff --git a/chapter-05/contents.texinfo b/chapter-05/contents.texinfo index b5e9473..018047d 100644 --- a/chapter-05/contents.texinfo +++ b/chapter-05/contents.texinfo @@ -265,7 +265,7 @@ size := model size. action: #flip: actionArgument: x@@y. @dots{} - cardView layoutSpec proportionalWidth: 1; proportionalHeight: 1. + cardView layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). cardView color: cardModel backColor. row addMorph: cardView]. playground addMorph: row ]} @@ -489,7 +489,7 @@ cardModel when: #lock send:#lock to: cardView; when: #unlock send: #unlock to: cardView; when: #flash send: #flash to: cardView. -cardView layoutSpec proportionalWidth: 1; proportionalHeight: 1. +cardView layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). @dots{}} One last detail: to foster your understanding of the relation between these two diff --git a/misc/MemoryGameV1-untabbed.pck.st b/misc/MemoryGameV1-untabbed.pck.st index 5e032b0..db1a47b 100644 --- a/misc/MemoryGameV1-untabbed.pck.st +++ b/misc/MemoryGameV1-untabbed.pck.st @@ -131,7 +131,7 @@ installCards row := LayoutMorph newRow. 1 to: size x do: [:x | | card | card := MemoryCard model: self action: #flip: actionArgument: x@y. - card layoutSpec proportionalWidth: 1; proportionalHeight: 1. + card layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). card cardColor: colors removeFirst. row addMorph: card. cards at: x@y put: card ]. diff --git a/misc/MemoryGameV1.pck.st b/misc/MemoryGameV1.pck.st index 790d48a..cc05eb1 100644 --- a/misc/MemoryGameV1.pck.st +++ b/misc/MemoryGameV1.pck.st @@ -131,7 +131,7 @@ installCards row := LayoutMorph newRow. 1 to: size x do: [:x | | card | card := MemoryCard model: self action: #flip: actionArgument: x@y. - card layoutSpec proportionalWidth: 1; proportionalHeight: 1. + card layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). card cardColor: colors removeFirst. row addMorph: card. cards at: x@y put: card ]. diff --git a/misc/MemoryGameV2-untabbed.pck.st b/misc/MemoryGameV2-untabbed.pck.st index 2ac1cbd..000ce7f 100644 --- a/misc/MemoryGameV2-untabbed.pck.st +++ b/misc/MemoryGameV2-untabbed.pck.st @@ -250,7 +250,7 @@ installCards when: #lock send:#lock to: cardView; when: #unlock send: #unlock to: cardView; when: #flash send: #flash to: cardView. - cardView layoutSpec proportionalWidth: 1; proportionalHeight: 1. + cardView layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). cardView color: cardModel backColor. row addMorph: cardView]. playground addMorph: row ]! ! diff --git a/misc/MemoryGameV2.pck.st b/misc/MemoryGameV2.pck.st index 7124676..d3ad0c0 100644 --- a/misc/MemoryGameV2.pck.st +++ b/misc/MemoryGameV2.pck.st @@ -250,7 +250,7 @@ installCards when: #lock send:#lock to: cardView; when: #unlock send: #unlock to: cardView; when: #flash send: #flash to: cardView. - cardView layoutSpec proportionalWidth: 1; proportionalHeight: 1. + cardView layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). cardView color: cardModel backColor. row addMorph: cardView]. playground addMorph: row ]! ! diff --git a/misc/MemoryGameV3-untabbed.pck.st b/misc/MemoryGameV3-untabbed.pck.st index 2de7447..4cce23c 100644 --- a/misc/MemoryGameV3-untabbed.pck.st +++ b/misc/MemoryGameV3-untabbed.pck.st @@ -462,7 +462,7 @@ installCards when: #lock send:#lock to: cardView; when: #unlock send: #unlock to: cardView; when: #flash send: #flash to: cardView. - cardView layoutSpec proportionalWidth: 1; proportionalHeight: 1. + cardView layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). cardView color: cardModel backColor. row addMorph: cardView]. playground addMorph: row ]! ! diff --git a/misc/MemoryGameV3.pck.st b/misc/MemoryGameV3.pck.st index f0f59c1..5470612 100644 --- a/misc/MemoryGameV3.pck.st +++ b/misc/MemoryGameV3.pck.st @@ -462,7 +462,7 @@ installCards when: #lock send:#lock to: cardView; when: #unlock send: #unlock to: cardView; when: #flash send: #flash to: cardView. - cardView layoutSpec proportionalWidth: 1; proportionalHeight: 1. + cardView layoutSpec: (LayoutSpec proportionalWidth: 1 proportionalHeight: 1). cardView color: cardModel backColor. row addMorph: cardView]. playground addMorph: row ]! !