• A LUIContainerLayouter must answer the following quest:

Where exactly are all children placed in the given parent?

The parent and children are of LUIElement and can be seen Rectangles with annotation.

  • Basic Example:
perform(parent:LUIElement):void {
// At this point parent's position is set and can be accessed via: e.getPosition()

// Let's iterate over all children
for (let i=0; i<parent.numChildren(); i++) {
const child = parent.getChildAt(i);

// Yes, you can even decide how to handle
// 'invisible' children,
if (!child.isVisible())
continue;

// With e.getPosition() you can get the position of the
// parent and layout it any way you like.
//
// Here: all children consume the same space as the parent does
child.getPosition().set(
parent.getPosition().getX(),
parent.getPosition().getY(),
parent.getPosition().getWidth(),
parent.getPosition().getHeight(),
)
}
}
  • NOTE: parent.getPosition() must not be changed. A child cannot force the parent to change it's position. It can only take the parent's position and try to fit in.

If the parent needs to resize based on it's parent you need to connect the container-layouts of the parents.

  • Layout-Properties

It's possible to set layout-properties on LUIElements which can be read druing the perform() call. There are two categories of properties:

  1. parent properties
  2. children properties
class MyLayouter implements LUIContainerLayouter {

public defaultSpace:number = 10; // (1) parent property

// In layout
perform(parent:LUIElement):void {
for (let i=0; i<parent.numChildren(); i++) {
const child = parent.getChildAt(i);
const childSpace = child.getLayoutProperty("space"); // (2) childrens property!
const space = childSpace === undefined ? this.defaultSpace : childSpace;

// now consider space
}
}
}

Parent Properties can be set as normal class members during the LUIContainerLayouter implementation. Children Properties on the other hand are set using child.setLayoutProperties(..).

The idea is that you can annotate the children with information that help the parent's container layout implementation to do it's job.

See

  • LUIFreeStackLayout
  • LUILineLayout
  • LUISpaceLayout
  • LUIStackLayout

Hierarchy

  • LUIContainerLayouter

Implemented by

Methods

Methods

Generated using TypeDoc