Terminality’s layout engine follows the same three-phase pipeline used by WPF and similar retained-mode UI frameworks: Measure, Arrange, and Render. Each phase runs in a top-down traversal of the visual tree. Only nodes whose dirty flags are set participate in a given pass, so the engine does the minimum work required to update the display after any property change.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Rikitav/Terminality/llms.txt
Use this file to discover all available pages before exploring further.
The three-phase pipeline
Measure
The tree root calls
Measure(availableSize) on each child, passing the space it has to offer. Each node’s ControlBase::Measure() clamps the available size against MinSize, MaxSize, and Margin, then delegates to MeasureOverride(), which you implement. The result is stored as actualSize_ and returned to the parent so it can size itself.Arrange
After measuring, the root calls
Arrange(finalRect) on each child with the rectangle the parent has allocated. ControlBase::Arrange() applies Margin and resolves HorizontalAlignment/VerticalAlignment to produce an arrangedRect_, then calls your ArrangeOverride() so you can position sub-children.*Override methods — never the public Measure, Arrange, or Render methods directly.
Alignment
EveryControlBase carries HorizontalAlignment and VerticalAlignment properties. They control how the control positions itself inside the slot its parent allocates.
HorizontalAlign
| Value | Behaviour |
|---|---|
Left | Pins to the left edge; uses natural content width |
Center | Centres horizontally; uses natural content width |
Right | Pins to the right edge; uses natural content width |
Stretch | Expands to fill available slot width, clamped by MinSize/MaxSize |
VerticalAlign
| Value | Behaviour |
|---|---|
Top | Pins to the top edge; uses natural content height |
Center | Centres vertically; uses natural content height |
Bottom | Pins to the bottom edge; uses natural content height |
Stretch | Expands to fill available slot height, clamped by MinSize/MaxSize |
Stretch, so controls fill their parent slot unless you override them.
Margin (Thickness)
Margin is a Thickness value that reserves space around the control’s content on all four sides. It is subtracted from the available space before MeasureOverride is called, and also from the arranged rectangle.
Thickness::Zero and Thickness::Single are predefined constants.
Size constraints: MinSize, MaxSize, ExpSize
ThreeProperty<ControlBase, Size> members constrain the space reported by MeasureOverride.
| Property | Effect | Default |
|---|---|---|
MinSize | Floor for the measured dimension | Size::Auto (no minimum) |
MaxSize | Ceiling for the measured dimension | Size::Auto (no maximum) |
ExpSize | Shorthand that sets both MinSize and MaxSize to the same value, making the control a fixed size | Size::Auto |
-1 in Size or Thickness means “automatic” or “unconstrained”. Any non-negative value is applied as a hard limit.
Grid layout
Grid divides its space into rows and columns, each described by a RowDefinition or ColumnDefinition with a GridLength.
GridLength sizing modes
| Factory | Meaning |
|---|---|
GridLength::Auto() | Size to the largest child in that track |
GridLength::Cell(n) | Fixed size of n terminal cells |
GridLength::Star(w) | Proportional share of remaining space after Auto and Cell tracks |
Placing children
AddChild accepts an optional rowSpan and colSpan (both default to 1):
RowDefinition and ColumnDefinition also carry MinHeight/MaxHeight and MinWidth/MaxWidth fields (defaulting to 0 and -1 respectively).
StackPanel layout
StackPanel stacks children one after another along an Orientation axis.
HorizontalContentAlignment and VerticalContentAlignment control how each child aligns within its slot along the cross axis.
Geometry types
All layout computation uses four value types fromterminality:Geometry.
Point
Point
A 2D integer position.
Size
Size
Width and height in terminal cells. A dimension of
-1 means unconstrained.Rect
Rect
Position and size combined. Provides
Right(), Bottom(), AsSize(), Contains(), Intersects(), and static helpers Union, Enclose, and Clip.Thickness
Thickness
Four-sided spacing value used for margins and padding.