[Q] Morphic strategies

Brian Brown rbb at techgame.net
Wed May 21 17:01:27 UTC 2003


> First, you probably don't want to use a PasteUpMorph as your master
> container unless you're going to be dropping things into it and need that
> kind of behavior.
>
Ok, for this app I don't need to drop things, so I could just use a Rectangle? 
Or just a Morph? If I was creating a Connectors based window then a 
PasteUpMorph would be the way to go, right?

> Second, you don't need to specify sizes of the submorphs if you're using a
> layout policy; the layout policy will set the submorph sizes.
>

ok

> There are some utility constructors (in AlignmentMorph right now)
> that can help when you need to make rows/columns of things:
>
> AlignmentMorph inARow: someMorphs
> AlignmentMorph inAColumn: someMorphs
> AlignmentMorph newRow
> AlignmentMorph newColumn
> AlignmentMorph newVariableTransparentSpacer
>
> etc.
>
I thought I read that AlignmentMorph was deprecated, so I hadn't been even 
looking at it... 

> But your example might be easier expressed as:
>
> window := RectangleMorph newBounds: ((0 at 460) extent: (640 at 480)).
> window layoutPolicy: ProportionalLayout new.
> window addMorph: (RectangleMorph new color: Color green) fullFrame:
> (LayoutFrame fractions: (0 at 0 extent: 0.5 at 0.5)). window addMorph:
> (RectangleMorph new color: Color red) fullFrame: (LayoutFrame fractions:
> (0 at 0.5 extent: 0.5 at 0.5)). window addMorph: (RectangleMorph new color: Color
> yellow) fullFrame: (LayoutFrame fractions: (0.5 at 0 extent: 0.5 at 1)). window
> openInWorld.
>
> > (this will do no dynamic resizing though... I assume I need
> > ProportionalLayout for that)
>
> No, the table layout does dynamic resizing too.
> But in something like a "window" where you have a clear idea of how big
> things are, it often makes sense to use a proportional layout.
>
Alright...

> When using a LayoutFrame:
> The fractions are relative to the owner.
> So the fraction rectangle should have no corners outside (0 at 0 corner: 1 at 1).
> The offsets are in pixels, and are relative to the fractional rectangle.
>

I don't understand the fraction thing at all... does it act as separator 
around the morph that the LayoutFrame is associated with?

> So if you wanted to have a row of buttons along the bottom of a Morph that
> always had to be 30 pixels tall, you could use a LayoutFrame like this:
>
> window addMorph: (AlignmentMorph inARow: buttons)
> 	fullFrame: (LayoutFrame fractions: (0 at 1 corner: 1 at 1) offsets: (0 at -30
> corner: 0 at 0)).

So this is creating a LayoutFrame with a 1 pixel wide buffer (for lack of a 
better word) and 30 pixel y-axis offset? (I just don't understand what it is 
doing %^)

This is the exact sort of thing that I would like to do, so if I can get my 
brain around it....

>
> So the button row would be laid out using a TableLayout, and its owner
> would use a ProportionalLayout.

btw, this is great stuff and tremendously helpful. Thanks a million, Ned.



More information about the Squeak-dev mailing list