How to lay out submorphs - example 4 (ProportionalLayout and TableLayout)
Last updated at 5:01 pm UTC on 11 August 2020
Craig Latta asked Mon, 04 Feb 2002 on the mailing list:
> I'd like to nest a proportional layout in a table layout.

You can execute one statement at a time in a workspace and see the results as the example develops:
``` m := Morph new.
m openInWorld.
m color: Color green.
m extent: 300 @ 300.
m layoutPolicy: ProportionalLayout new.```

``` bm := Morph new.
bm openInWorld.
m
fullFrame: (
LayoutFrame
fractions: (0@1 corner: 1 @ 1) offsets: (0@100 negated corner: 0@0)
).```
```bm color: (Color blue alpha: 0.5).

sm := Morph new.
sm openInWorld.
LayoutFrame fractions: (0@0 corner: 1 @ 1) offsets: (0@0 corner: 0@100 negated)).
sm color: (Color red alpha: 0.5).
sm layoutPolicy: ProportionalLayout new.

tm := Morph new.
tm openInWorld.
sm
fullFrame: (LayoutFrame fractions: (0@0 corner: 0.9 @ 0.9) offsets: nil).
tm color: (Color yellow alpha: 0.5).
tm layoutPolicy: TableLayout new.
tm listDirection: #topToBottom.
tm listCentering: #center.

fm := Morph new.
fm openInWorld.
fm extent: 100@2.
fm color: Color black.
fm hResizing: #spaceFill.
```

The example above is a refactored version given by
Bob Arning:
```Morph new
color: Color green;
extent: 300 @ 300;
layoutPolicy: ProportionalLayout new;
Morph new color: (Color blue alpha: 0.5)
)
fullFrame: (
LayoutFrame
fractions: (0@1 corner: 1 @ 1) offsets: (0@100 negated corner: 0@0)
);

Morph new
color: (Color red alpha: 0.5);
layoutPolicy: ProportionalLayout new;
Morph new
color: (Color yellow alpha: 0.5);
layoutPolicy: TableLayout new;
listDirection: #topToBottom;
listCentering: #center;
Morph new extent: 100@2; color: Color black; hResizing: #spaceFill
)
)
fullFrame: (LayoutFrame fractions: (0@0 corner: 0.9 @ 0.9) offsets: nil)
)
fullFrame: (
LayoutFrame fractions: (0@0 corner: 1 @ 1) offsets: (0@0 corner: 0@100 negated)
);
openInWorld
```

Sean DeNigris