How to lay out submorphs
Last updated at 10:45 am UTC on 14 July 2022
Every Morph now has the capability to layout it's submorphs if it is given a LayoutPolicy. The default is to have no layout policy.
Previously, only the AlignmentMorph could implement layout policies.
Each Morph may have its own LayoutPolicy: either a ProportionalLayout or a TableLayout (as of 2009 and later).
Please read the dynamic essay project MorphLayoutArticle (2001?).
Citation from this article:
"Control Your Submorphs
by Ted Kaehler and Andreas Raab
Last Fall Andreas reworked how objects in Squeak display their "submorphs", the objects that are inside of them. Class AlignmentMorph was eliminated, but a vestigial class of that name remains, in order to be backward compatible. The goal is to control how the objects inside a display object line up, and to control their spacing on the display. This essay is a "quick reference card" for the properties that control layout and alignment."
So AlignmentMorph is still available because of compatibility reasons and some utility methods it implements.
You should also be able to make your own subclasses of LayoutPolicy.
You can find other layout methods under Morph->layout-properties. Also, play with a Morphs Layout Properties using the red halo menu by direct manipulation.
Here is some code to lay out some morphs in this system.
More examples are needed – add yours here!