[Cuis-dev] LayoutMorph and handling layouts

Juan Vuletich juan at jvuletich.org
Sun Oct 24 08:48:17 PDT 2021


Hi Eric,

On 10/23/2021 5:21 PM, Eric Gade via Cuis-dev wrote:
> Hi All,
>
> I'm experimenting with creating some new widgets using VectorGraphics 
> and friends. Coming from the Squeak/Pharo side of things, the Morphic 
> layout structure is completely different in Cuis. I have a couple of 
> questions.

Cool.

> First, how do we handle the situation where we have a WidgetMorph 
> whose sole submorph is a LayoutMorph? Is it possible to simply make it 
> match dimensions?

A LayoutMorph does layout on submorphs. WidgetMorph doesn't know hot to 
do that. But, for example, SystemWindow does what you say. See 
#layoutSubmorphs.

> You might be thinking, "just use a LayoutMorph as the root,

Yes. That would be my suggestion.

> " which leads me to my next question: are we supposed to subclass 
> LayoutMorph and use it by ourselves to make widgets?

No. there's no need to do that.The system uses instances of LayoutMorph 
all over the place. You can cycle the halo on any SystemBrowser, or 
explore the submorphs structure and see for yourself.

> The reason I ask is because sending LayoutMorph >> #new always results 
> in an MNU about direction not being specified. This is true even in 
> cases where you subclass LayoutMorph and explicitly set a direction 
> (column or row) in the initialize method. I am not sure what is 
> "correct" here.

Take a look and spend some time playing with the examples in the 
'examples' class category in LayoutMorph. Evaluate the comment to run 
each method, then resize the morph (using the halo) and see what layout 
can do. Use the bottomRight handle to resize the morph. You can keep an 
inspector on it open, to see state change. (the rightCenter handle, with 
a magnifying glass doesn't resize but rescale / zoom, and so doesn't 
change layout).

> One final question about LayoutSpecs. It seems that any settings you 
> make to a submorph's layoutSpec (for example, getting rid of 
> proportionality) will be reset when you add it to a parent 
> LayoutMorph. So for now, I am only adjusting the layouSpecs of my 
> submorphs after they have been added to their parent. Is this correct, 
> or is there some better way to do it?

Most (all?) the examples use #addMorph:layoutSpec: to add as submorph 
and set layout spec at the same time. Use them as a guide on suggested 
style.

>
> Thanks!
>
> -- 
> Eric

Cheers,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich



More information about the Cuis-dev mailing list