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

Mariano Montone marianomontone at gmail.com
Mon Mar 13 15:53:53 PDT 2023


I got it wrong. Seems that row layout layouts things horizontally, and 
column vertically.

As Hilaire mentioned, unless you want to define your own layout 
algorithm, the idea is to use the layout morphs, not subclass from them.

Layouts in a column (vertically):

LayoutMorph newColumn ::
         addMorph: (BoxedMorph new color: Color red; yourself);
         addMorph: (BoxedMorph new color: Color green; yourself);
         addMorph: (BoxedMorph new color: Color blue; yourself);
         openInWorld.

Layouts in a row (horizontally):
  LayoutMorph newRow ::
         addMorph: (BoxedMorph new color: Color red; yourself);
         addMorph: (BoxedMorph new color: Color green; yourself);
         addMorph: (BoxedMorph new color: Color blue; yourself);
         openInWorld.

     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/1604abef/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/1604abef/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/1604abef/attachment-0003.png>


More information about the Cuis-dev mailing list