[Cuis-dev] LayoutMorph subclass instance #beColumn has not effect

Mariano Montone marianomontone at gmail.com
Mon Mar 13 16:11:57 PDT 2023


You are right that there's something odd with the LayoutMorph 
initialization in subclasses.

I'm solving it like this:

On class side, instantiate with either #newColumn or #newRow:

MyLayoutMorphSubclass class>>new
     ^ self newColumn

I attach a class as an example, and example code in class comments.

       Mariano


El 13/3/23 a las 18:30, Alexandre Rousseau escribió:
>
>     You may want to try with #beRow if you want submorphs to align
>     vertically (in rows).
>
>
> Hmm... I'm not sure about this.
>
> I've attached the filed-out test class to this email, if you want to 
> take a closer look.
>
> Basically it is a LayoutMorph subclass, initialized as:
>
>     initialize
>     | b1 b2 b3 |
>
>     super initialize.
>     self beRow.
>     b1 BoxedMorph new :: color: Color red.
>     b2 BoxedMorph new :: color: Color green.
>     b3 BoxedMorph new :: color: Color blue.
>     self addMorph: b1.
>     self addMorph: b2.
>     self addMorph: b3.
>     self morphExtent: self minimumExtent.
>
> and the instantiation of which results in this (attached image 1).
>
> image1.png
> image 2.png
> Changing line 4 to "self beColumn" does not lay the items out 
> vertically. See attached image 2.
>
>
>
> On Mon, Mar 13, 2023 at 4:01 PM marianomontone--- via Cuis-dev 
> <cuis-dev at lists.cuis.st> wrote:
>
>     On 13/3/23 13:36, Alexandre Rousseau via Cuis-dev
>     <cuis-dev at lists.cuis.st> wrote:
>     > Defining a class as subclass of LayoutMorph and initializing it
>     thus:
>     >
>     >     initialize
>     >        super initialize.
>     >        self beColumn.
>     >
>     >
>     > morphs added to it still appear next to each other,
>     horizontally, as if
>     > #beColumn was ignored.
>     >
>     > Is this expected behaviour for a subclass of LayoutMorph?
>
>     I think it is. You may want to try with #beRow if you want
>     submorphs to align vertically (in rows).
>
>           Mariano
>     -- 
>     Cuis-dev mailing list
>     Cuis-dev at lists.cuis.st
>     https://lists.cuis.st/mailman/listinfo/cuis-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230313/586aef91/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image1.png
Type: image/png
Size: 4032 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230313/586aef91/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image 2.png
Type: image/png
Size: 5004 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230313/586aef91/attachment-0003.png>
-------------- next part --------------
'From Cuis 6.0 [latest update: #5686] on 13 March 2023 at 8:09:59 pm'!
!classDefinition: #LayoutMorphTest category: 'Mariano'!
LayoutMorph subclass: #LayoutMorphTest
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Mariano'!
!LayoutMorphTest commentStamp: 'MM 3/13/2023 20:09:45' prior: 0!
Example1:

LayoutMorphTest new openInWorld
	morphExtent: 0 at 0.
	
Example 2:

LayoutMorph newRow ::
	addMorph: LayoutMorphTest new;
	addMorph: LayoutMorphTest new;
	openInWorld!


!LayoutMorphTest methodsFor: 'as yet unclassified' stamp: 'MM 3/13/2023 20:08:01'!
initialize
    | b1 b2 b3 |

    super initialize.
   
    b1 := BoxedMorph new :: color: Color red.
    b2 := BoxedMorph new :: color: Color green.
    b3 := BoxedMorph new :: color: Color blue.
    self addMorph: b1.
    self addMorph: b2.
    self addMorph: b3.

	! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

!classDefinition: 'LayoutMorphTest class' category: 'Mariano'!
LayoutMorphTest class
	instanceVariableNames: ''!

!LayoutMorphTest class methodsFor: 'as yet unclassified' stamp: 'MM 3/13/2023 20:05:01'!
new
	^ self newColumn! !


More information about the Cuis-dev mailing list