genhvbox

Genhvbox is a generic, abstract horizontal/vertical box layout calculator for dynamic layouts. The caller builds a tree representing the layout and specifies various constraints. Genhvbox's update solves the constraints so that sizes and coordinates of each element of the layout is known.

When used properly, such a dynamic layout can grow in size (when the user resizes a window for example) with the newly gained space allocated to the most important widgets.

concepts

A layout is a tree. The root node is special, as it has to match the size of the window or screen area hosting the layout. The root has exactly one child. Leaf nodes are usually widgets; widgets have no children. Widgets have minimal size constraint specified by the caller. Intermediate nodes are boxes.

A box has zero or more children. A box has a main and an auxiliary direction:

box type main direction auxiliary direction
hbox horizontal vertical
vbox vertical horizontal

Children of the box inherit the auxiliary size of the box, which is no smaller than the largest children (plus two times the passing of the box) in that direction. The rules for determining sizes in the main directions are:

The alignments parameter of a box affects how available space is distributed in the gaps left by non-filling children of the box. Alignments are:

The span parameter determines how much room the given node tries to claim in the main direction of its parent box:

The padding field is used to pad content by inserting a few pixels wide frame of empty space around the given node. The default value of padding is 0. The minimum size a given node claims in its parent is increased by 2*node->padding in both directions.