wijjit.layout.engine.LayoutNode
- class wijjit.layout.engine.LayoutNode(width='auto', height='auto', id=None)[source]
Base class for layout tree nodes.
A layout node can be either a container (with children) or a leaf (wrapping an Element).
- Parameters:
- Variables:
width_spec (
Size) – Width specificationheight_spec (
Size) – Height specificationconstraints (
SizeConstraintsorNone) – Calculated size constraintsbounds (
BoundsorNone) – Assigned position and size
Methods
__init__([width, height, id])assign_bounds(x, y, width, height)Assign absolute position and size (top-down pass).
Calculate size constraints (bottom-up pass).
Collect all Element objects in this subtree.
get_height_for_width(width)Return the height this node needs when laid out at
width.- abstractmethod calculate_constraints()[source]
Calculate size constraints (bottom-up pass).
- Returns:
Calculated constraints
- Return type:
- abstractmethod assign_bounds(x, y, width, height)[source]
Assign absolute position and size (top-down pass).
- get_height_for_width(width)[source]
Return the height this node needs when laid out at
width.The bottom-up constraint pass has to guess a height before any width is known, which is wrong for anything whose height depends on its width. Wrapped text is the case that bites: a long line measures as one row, is allocated one row, and paints its continuation lines over whichever sibling was laid out beneath it. Containers call this on the way down, once a child’s width is settled, to correct the guess.