From 5eb437ad520c356a7cfce8cd2ace771019d45aac Mon Sep 17 00:00:00 2001 From: Thiago da Silva Lino Date: Wed, 9 Jul 2025 14:36:10 -0300 Subject: [PATCH 1/3] fix MemoryGame: LayoutSpec new -> LayoutSizeSpec new --- misc/MemoryGameV1-untabbed.pck.st | 4 +-- misc/MemoryGameV1.pck.st | 12 ++++---- misc/MemoryGameV2-untabbed.pck.st | 4 +-- misc/MemoryGameV2.pck.st | 30 ++++++++++---------- misc/MemoryGameV3-untabbed.pck.st | 4 +-- misc/MemoryGameV3.pck.st | 46 +++++++++++++++---------------- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/misc/MemoryGameV1-untabbed.pck.st b/misc/MemoryGameV1-untabbed.pck.st index 9a10f29..5e032b0 100644 --- a/misc/MemoryGameV1-untabbed.pck.st +++ b/misc/MemoryGameV1-untabbed.pck.st @@ -145,7 +145,7 @@ installStatusBar borderWidth: 1; borderColor: self borderColor twiceLighter ; setHeightOnContent. - self addMorph: statusBar layoutSpec: LayoutSpec new useMorphHeight. + self addMorph: statusBar layoutSpec: LayoutSizeSpec new useMorphHeight. self message: 'Welcome to ', 'Memory Game' bold! ! !MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 3/18/2025 23:30:19'! @@ -166,7 +166,7 @@ installToolbar setBalloonText: 'Stop the game'; morphExtent: 32 asPoint. toolbar addMorph: button. - self addMorph: toolbar layoutSpec: LayoutSpec new useMorphHeight + self addMorph: toolbar layoutSpec: LayoutSizeSpec new useMorphHeight ! ! !MemoryGameWindow methodsFor: 'updating' stamp: 'hlsf 3/19/2025 16:37:56'! diff --git a/misc/MemoryGameV1.pck.st b/misc/MemoryGameV1.pck.st index e0e37c8..790d48a 100644 --- a/misc/MemoryGameV1.pck.st +++ b/misc/MemoryGameV1.pck.st @@ -1,6 +1,6 @@ -'From Cuis7.3 [latest update: #7095] on 10 April 2025 at 10:53:03 am'! +'From Cuis7.5 [latest update: #7342] on 9 July 2025 at 1:15:16 pm'! 'Description '! -!provides: 'MemoryGameV1' 1 6! +!provides: 'MemoryGameV1' 1 7! SystemOrganization addCategory: #MemoryGameV1! @@ -137,7 +137,7 @@ installCards cards at: x@y put: card ]. playground addMorph: row ]! ! -!MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 3/18/2025 23:14:00'! +!MemoryGameWindow methodsFor: 'initialization' stamp: 'tsl 7/9/2025 13:14:39'! installStatusBar statusBar := TextParagraphMorph new padding: 2; @@ -145,10 +145,10 @@ installStatusBar borderWidth: 1; borderColor: self borderColor twiceLighter ; setHeightOnContent. - self addMorph: statusBar layoutSpec: LayoutSpec new useMorphHeight. + self addMorph: statusBar layoutSpec: LayoutSizeSpec new useMorphHeight. self message: 'Welcome to ', 'Memory Game' bold! ! -!MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 3/18/2025 23:30:19'! +!MemoryGameWindow methodsFor: 'initialization' stamp: 'tsl 7/9/2025 13:14:32'! installToolbar | toolbar button | toolbar := LayoutMorph newRow separation: 2. @@ -166,7 +166,7 @@ installToolbar setBalloonText: 'Stop the game'; morphExtent: 32 asPoint. toolbar addMorph: button. - self addMorph: toolbar layoutSpec: LayoutSpec new useMorphHeight + self addMorph: toolbar layoutSpec: LayoutSizeSpec new useMorphHeight ! ! !MemoryGameWindow methodsFor: 'updating' stamp: 'hlsf 3/19/2025 16:37:56'! diff --git a/misc/MemoryGameV2-untabbed.pck.st b/misc/MemoryGameV2-untabbed.pck.st index c2a7ab8..2ac1cbd 100644 --- a/misc/MemoryGameV2-untabbed.pck.st +++ b/misc/MemoryGameV2-untabbed.pck.st @@ -263,7 +263,7 @@ installStatusBar borderWidth: 1; borderColor: self borderColor twiceLighter ; setHeightOnContent. - self addMorph: statusBar layoutSpec: LayoutSpec new useMorphHeight. + self addMorph: statusBar layoutSpec: LayoutSizeSpec new useMorphHeight. self message: 'Welcome to ', 'Memory Game' bold! ! !MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 3/22/2025 15:40:23'! @@ -284,7 +284,7 @@ installToolbar setBalloonText: 'Stop the game'; morphExtent: 32 asPoint. toolbar addMorph: button. - self addMorph: toolbar layoutSpec: LayoutSpec new useMorphHeight + self addMorph: toolbar layoutSpec: LayoutSizeSpec new useMorphHeight ! ! !MemoryGameWindow class methodsFor: 'instance creation' stamp: 'hlsf 3/22/2025 15:37:23'! diff --git a/misc/MemoryGameV2.pck.st b/misc/MemoryGameV2.pck.st index ef34365..7124676 100644 --- a/misc/MemoryGameV2.pck.st +++ b/misc/MemoryGameV2.pck.st @@ -1,46 +1,46 @@ -'From Cuis7.3 [latest update: #7095] on 10 April 2025 at 10:56:43 am'! +'From Cuis7.5 [latest update: #7342] on 9 July 2025 at 1:21:51 pm'! 'Description '! -!provides: 'MemoryGameV2' 1 9! -SystemOrganization addCategory: 'MemoryGameV2'! +!provides: 'MemoryGameV2' 1 10! +SystemOrganization addCategory: #MemoryGameV2! -!classDefinition: #MemoryCardModel category: 'MemoryGameV2'! +!classDefinition: #MemoryCardModel category: #MemoryGameV2! Object subclass: #MemoryCardModel instanceVariableNames: 'flipped done color' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV2'! -!classDefinition: 'MemoryCardModel class' category: 'MemoryGameV2'! +!classDefinition: 'MemoryCardModel class' category: #MemoryGameV2! MemoryCardModel class instanceVariableNames: ''! -!classDefinition: #MemoryGame category: 'MemoryGameV2'! +!classDefinition: #MemoryGame category: #MemoryGameV2! Object subclass: #MemoryGame instanceVariableNames: 'model view playing' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV2'! -!classDefinition: 'MemoryGame class' category: 'MemoryGameV2'! +!classDefinition: 'MemoryGame class' category: #MemoryGameV2! MemoryGame class instanceVariableNames: ''! -!classDefinition: #MemoryGameModel category: 'MemoryGameV2'! +!classDefinition: #MemoryGameModel category: #MemoryGameV2! Object subclass: #MemoryGameModel instanceVariableNames: 'size tupleSize cards' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV2'! -!classDefinition: 'MemoryGameModel class' category: 'MemoryGameV2'! +!classDefinition: 'MemoryGameModel class' category: #MemoryGameV2! MemoryGameModel class instanceVariableNames: ''! -!classDefinition: #MemoryGameWindow category: 'MemoryGameV2'! +!classDefinition: #MemoryGameWindow category: #MemoryGameV2! SystemWindow subclass: #MemoryGameWindow instanceVariableNames: 'presenter statusBar playground' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV2'! -!classDefinition: 'MemoryGameWindow class' category: 'MemoryGameV2'! +!classDefinition: 'MemoryGameWindow class' category: #MemoryGameV2! MemoryGameWindow class instanceVariableNames: ''! @@ -255,7 +255,7 @@ installCards row addMorph: cardView]. playground addMorph: row ]! ! -!MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 3/18/2025 23:14:00'! +!MemoryGameWindow methodsFor: 'initialization' stamp: 'tsl 7/9/2025 13:21:19'! installStatusBar statusBar := TextParagraphMorph new padding: 2; @@ -263,10 +263,10 @@ installStatusBar borderWidth: 1; borderColor: self borderColor twiceLighter ; setHeightOnContent. - self addMorph: statusBar layoutSpec: LayoutSpec new useMorphHeight. + self addMorph: statusBar layoutSpec: LayoutSizeSpec new useMorphHeight. self message: 'Welcome to ', 'Memory Game' bold! ! -!MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 3/22/2025 15:40:23'! +!MemoryGameWindow methodsFor: 'initialization' stamp: 'tsl 7/9/2025 13:21:12'! installToolbar | toolbar button | toolbar := LayoutMorph newRow separation: 2. @@ -284,7 +284,7 @@ installToolbar setBalloonText: 'Stop the game'; morphExtent: 32 asPoint. toolbar addMorph: button. - self addMorph: toolbar layoutSpec: LayoutSpec new useMorphHeight + self addMorph: toolbar layoutSpec: LayoutSizeSpec new useMorphHeight ! ! !MemoryGameWindow class methodsFor: 'instance creation' stamp: 'hlsf 3/22/2025 15:37:23'! diff --git a/misc/MemoryGameV3-untabbed.pck.st b/misc/MemoryGameV3-untabbed.pck.st index f174740..2de7447 100644 --- a/misc/MemoryGameV3-untabbed.pck.st +++ b/misc/MemoryGameV3-untabbed.pck.st @@ -475,7 +475,7 @@ installStatusBar borderWidth: 1; borderColor: self borderColor twiceLighter ; setHeightOnContent. - self addMorph: statusBar layoutSpec: LayoutSpec new useMorphHeight. + self addMorph: statusBar layoutSpec: LayoutSizeSpec new useMorphHeight. self message: 'Welcome to ', 'Memory Game' bold! ! !MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 5/24/2025 10:32:50'! @@ -506,7 +506,7 @@ installToolbar setBalloonText: 'Redo the last play'; morphExtent: 32 asPoint. toolbar addMorph: button. - self addMorph: toolbar layoutSpec: LayoutSpec new useMorphHeight + self addMorph: toolbar layoutSpec: LayoutSizeSpec new useMorphHeight ! ! !MemoryGameWindow class methodsFor: 'instance creation' stamp: 'hlsf 3/22/2025 15:37:23'! diff --git a/misc/MemoryGameV3.pck.st b/misc/MemoryGameV3.pck.st index 563d94d..f0f59c1 100644 --- a/misc/MemoryGameV3.pck.st +++ b/misc/MemoryGameV3.pck.st @@ -1,86 +1,86 @@ -'From Cuis7.3 [latest update: #7158] on 24 May 2025 at 4:26:24 pm'! +'From Cuis7.5 [latest update: #7342] on 9 July 2025 at 1:20:31 pm'! 'Description '! -!provides: 'MemoryGameV3' 1 3! -SystemOrganization addCategory: 'MemoryGameV3'! +!provides: 'MemoryGameV3' 1 4! +SystemOrganization addCategory: #MemoryGameV3! -!classDefinition: #Command category: 'MemoryGameV3'! +!classDefinition: #Command category: #MemoryGameV3! Object subclass: #Command instanceVariableNames: 'presenter' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'Command class' category: 'MemoryGameV3'! +!classDefinition: 'Command class' category: #MemoryGameV3! Command class instanceVariableNames: ''! -!classDefinition: #PlayCardCommand category: 'MemoryGameV3'! +!classDefinition: #PlayCardCommand category: #MemoryGameV3! Command subclass: #PlayCardCommand instanceVariableNames: 'status position' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'PlayCardCommand class' category: 'MemoryGameV3'! +!classDefinition: 'PlayCardCommand class' category: #MemoryGameV3! PlayCardCommand class instanceVariableNames: ''! -!classDefinition: #CommandManager category: 'MemoryGameV3'! +!classDefinition: #CommandManager category: #MemoryGameV3! Object subclass: #CommandManager instanceVariableNames: 'stack presenter' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'CommandManager class' category: 'MemoryGameV3'! +!classDefinition: 'CommandManager class' category: #MemoryGameV3! CommandManager class instanceVariableNames: ''! -!classDefinition: #MemoryCardModel category: 'MemoryGameV3'! +!classDefinition: #MemoryCardModel category: #MemoryGameV3! Object subclass: #MemoryCardModel instanceVariableNames: 'flipped done color' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'MemoryCardModel class' category: 'MemoryGameV3'! +!classDefinition: 'MemoryCardModel class' category: #MemoryGameV3! MemoryCardModel class instanceVariableNames: ''! -!classDefinition: #MemoryGame category: 'MemoryGameV3'! +!classDefinition: #MemoryGame category: #MemoryGameV3! Object subclass: #MemoryGame instanceVariableNames: 'model view playing cmdManager' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'MemoryGame class' category: 'MemoryGameV3'! +!classDefinition: 'MemoryGame class' category: #MemoryGameV3! MemoryGame class instanceVariableNames: ''! -!classDefinition: #MemoryGameModel category: 'MemoryGameV3'! +!classDefinition: #MemoryGameModel category: #MemoryGameV3! Object subclass: #MemoryGameModel instanceVariableNames: 'size tupleSize cards' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'MemoryGameModel class' category: 'MemoryGameV3'! +!classDefinition: 'MemoryGameModel class' category: #MemoryGameV3! MemoryGameModel class instanceVariableNames: ''! -!classDefinition: #CommandStack category: 'MemoryGameV3'! +!classDefinition: #CommandStack category: #MemoryGameV3! ReadWriteStream subclass: #CommandStack instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'CommandStack class' category: 'MemoryGameV3'! +!classDefinition: 'CommandStack class' category: #MemoryGameV3! CommandStack class instanceVariableNames: ''! -!classDefinition: #MemoryGameWindow category: 'MemoryGameV3'! +!classDefinition: #MemoryGameWindow category: #MemoryGameV3! SystemWindow subclass: #MemoryGameWindow instanceVariableNames: 'presenter statusBar playground' classVariableNames: '' poolDictionaries: '' category: 'MemoryGameV3'! -!classDefinition: 'MemoryGameWindow class' category: 'MemoryGameV3'! +!classDefinition: 'MemoryGameWindow class' category: #MemoryGameV3! MemoryGameWindow class instanceVariableNames: ''! @@ -467,7 +467,7 @@ installCards row addMorph: cardView]. playground addMorph: row ]! ! -!MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 3/18/2025 23:14:00'! +!MemoryGameWindow methodsFor: 'initialization' stamp: 'tsl 7/9/2025 13:19:58'! installStatusBar statusBar := TextParagraphMorph new padding: 2; @@ -475,10 +475,10 @@ installStatusBar borderWidth: 1; borderColor: self borderColor twiceLighter ; setHeightOnContent. - self addMorph: statusBar layoutSpec: LayoutSpec new useMorphHeight. + self addMorph: statusBar layoutSpec: LayoutSizeSpec new useMorphHeight. self message: 'Welcome to ', 'Memory Game' bold! ! -!MemoryGameWindow methodsFor: 'initialization' stamp: 'hlsf 5/24/2025 10:32:50'! +!MemoryGameWindow methodsFor: 'initialization' stamp: 'tsl 7/9/2025 13:19:20'! installToolbar | toolbar button | toolbar := LayoutMorph newRow separation: 2. @@ -506,7 +506,7 @@ installToolbar setBalloonText: 'Redo the last play'; morphExtent: 32 asPoint. toolbar addMorph: button. - self addMorph: toolbar layoutSpec: LayoutSpec new useMorphHeight + self addMorph: toolbar layoutSpec: LayoutSizeSpec new useMorphHeight ! ! !MemoryGameWindow class methodsFor: 'instance creation' stamp: 'hlsf 3/22/2025 15:37:23'! From 47825b2b5e97c9fa2cee6b648171bf62c8786816 Mon Sep 17 00:00:00 2001 From: Thiago da Silva Lino Date: Tue, 15 Jul 2025 11:31:31 -0300 Subject: [PATCH 2/3] Chapter 2, LayoutSpec hierarchy review --- chapter-02/contents.texinfo | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/chapter-02/contents.texinfo b/chapter-02/contents.texinfo index e8c4efe..17ca4e1 100644 --- a/chapter-02/contents.texinfo +++ b/chapter-02/contents.texinfo @@ -176,13 +176,24 @@ all the available space. @cindex layout @subentry @class{LayoutSpec} Each morph can have a @class{LayoutSpec} that specifies how it should be laid out within its owner, this ignored if the owner is not a -@class{LayoutMorph} instance. +@class{LayoutMorph} instance. @class{LayoutSpec} is abstract with two +subclasses: +@itemize + @item + @class{LayoutSizeSpec} - for rows/columns. Manages dimensions via + @smalltalk{fixedWidth}, @smalltalk{fixedHeight}, + @smalltalk{proportionalWidth} and @smalltalk{proportionalHeight} + and alignment via @smalltalk{offAxisEdgeWeight}. + + @item + @class{LayoutEdgesSpec} - for form layouts. Defines corner anchors + using @smalltalk{topLeftEdgesWeight}, + @smalltalk{bottomRightEdgesWeight}, @smalltalk{topLeftOffset} and + @smalltalk{bottomRightOffset}. +@end itemize -Instances of @class{LayoutSpec} have the following instance variables: -@smalltalk{morph}, @smalltalk{fixedWidth}, @smalltalk{fixedHeight}, -@smalltalk{offAxisEdgeWeight}, @smalltalk{proportionalWidth}, and -@smalltalk{proportionalHeight}. There are methods to set each of -these instance variables. +Instances of @class{LayoutSpec} have @smalltalk{morph} as instance +variable. There are methods to set each of these instance variables. @smalltalkExample{box2 layoutSpec proportionalWidth: 1} @@ -190,12 +201,12 @@ these instance variables. We could have added @smalltalk{box2} to @smalltalk{layout} using the message @msg{add:proportionWidth:} which adds a submorph AND sets the -@smalltalk{proportionalWidth} property of its @class{LayoutSpec}. +@smalltalk{proportionalWidth} property of its @class{LayoutEdgesSpec}. However, an issue with this approach is that it creates a new instance -of @class{LayoutSpec} where the values of +of @class{LayoutSizeSpec} where the values of @smalltalk{proportionalWidth} and @smalltalk{proportionalHeight} are both 1. To only modify one of those properties, it's best to set it -directly on the @class{LayoutSpec} instance of the morph. +directly on the @class{LayoutSizedSpec} instance of the morph. @cindex layout @subentry spacer Let's modify our example @ref{layoutExample1} so the boxes are spread From 6d5a8d8859d1ab6fc3491557560600cd19aff68b Mon Sep 17 00:00:00 2001 From: Thiago da Silva Lino Date: Tue, 15 Jul 2025 11:40:18 -0300 Subject: [PATCH 3/3] Chapter 2, fix typo --- chapter-02/contents.texinfo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter-02/contents.texinfo b/chapter-02/contents.texinfo index 17ca4e1..d5499af 100644 --- a/chapter-02/contents.texinfo +++ b/chapter-02/contents.texinfo @@ -201,7 +201,7 @@ variable. There are methods to set each of these instance variables. We could have added @smalltalk{box2} to @smalltalk{layout} using the message @msg{add:proportionWidth:} which adds a submorph AND sets the -@smalltalk{proportionalWidth} property of its @class{LayoutEdgesSpec}. +@smalltalk{proportionalWidth} property of its @class{LayoutSizeSpec}. However, an issue with this approach is that it creates a new instance of @class{LayoutSizeSpec} where the values of @smalltalk{proportionalWidth} and @smalltalk{proportionalHeight} are