Layout controls in Terminality act as containers that measure, arrange, and render their children. You never position controls manually — instead, you express structure throughDocumentation 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.
Grid rows and columns, StackPanel orientation, or ScrollViewer clipping, and the layout engine resolves sizes automatically at each frame.
Grid
Grid divides its space into rows and columns. You define the dimensions of each track with a GridLength, then place child controls into specific cells. Children can span multiple rows or columns.
GridLength
Every row height and column width is described by aGridLength value, which combines a numeric value with a sizing mode.
Size the track to the largest
DesiredSize of any child in that track. The track takes exactly as much space as its contents need.Size the track to exactly
n terminal cells (characters). Use this for fixed-width columns or fixed-height rows.Distribute remaining space proportionally. A track with
Star(2.0f) gets twice the remaining space as a Star(1.0f) track. This is the default when you default-construct a GridLength.RowDefinition and ColumnDefinition
Sizing mode for this row.
Minimum height in cells. The row will never shrink below this value.
Maximum height in cells.
-1 means no limit.Sizing mode for this column.
Minimum width in cells.
Maximum width in cells.
-1 means no limit.Methods
Append a row definition. Rows are indexed in the order they are added, starting from
0.Append a column definition. Columns are indexed in the order they are added, starting from
0.Place a control in a single cell at
(row, col). The control occupies exactly one row and one column.Place a control starting at
(row, col) and extending across rowSpan rows and colSpan columns. Useful for headers or panels that need to span the full width.Example — messenger layout
TheMessangerTest in the test app uses a three-row grid: a star-sized chat area, a fixed-height input panel, and a fixed-height status bar.
StackPanel
StackPanel arranges children in a single line — either vertically (the default) or horizontally. It is the go-to container when you need a simple list of controls without the overhead of a grid.
Properties
Direction in which children are stacked. Set to
Orientation::Horizontal for a row of controls.How each child is aligned on the horizontal axis within the panel’s width.
How each child is aligned on the vertical axis within the panel’s height.
Allow the panel to scroll when children overflow. Requires
InvalidationKind::Arrange to take effect after the first layout pass.Automatically advance the scroll offset after every child addition so the last item is always visible. Combine with
Scrollable = true for a live-updating log or chat list.When focus reaches the last child and the user navigates forward (or vice versa), wrap focus back to the opposite end instead of leaving the panel.
Methods
Append a control to the end of the stack.
Insert a control at the given zero-based position, shifting later children down.
Find and remove the first child matching
predicate. Returns the removed control as a unique_ptr so you can reuse it.Remove the child at
index and return it.Remove all children at once.
Example — vertical menu
StackPanel is the base class of ItemsControl<T>. All properties and methods above are inherited by ItemsControl.ScrollViewer
ScrollViewer wraps a single child control and provides panning when the child’s desired size exceeds the viewport. The user can scroll with the arrow keys when the control is focused.
Properties
The single child to display and scroll. Assign with
std::move or init<T>.Horizontal scroll offset in cells. Increasing this value pans the content left.
Vertical scroll offset in cells. Increasing this value pans the content up.
Measurement methods
The total width of the scrollable content in cells (the child’s desired width).
The total height of the scrollable content in cells.
The visible width of the
ScrollViewer in cells.The visible height of the
ScrollViewer in cells.Example
ItemsControl<T>
ItemsControl<T> extends StackPanel with data-binding: you supply an ObservableCollection<T> as the data source and a factory lambda as the item template, and the control keeps its children in sync with the collection automatically.
Key API
Bind the control to a collection.
ItemsControl subscribes to ItemAdded, ItemRemoved, ItemReplaced, and CollectionCleared events and rebuilds or patches its children accordingly. Pass nullptr to detach.Provide a factory function with signature
std::unique_ptr<ControlBase>(const T&). Called once per item when the control is bound or when a new item is added. Rebuilds all items immediately when set.Returns the currently bound
ObservableCollection<T>*, or nullptr if none is set.ObservableCollection<T>
ObservableCollection<T> is a std::vector-like container that fires events on every mutation. You own the collection instance; ItemsControl only holds a pointer to it.
| Event | Signature | Fired when |
|---|---|---|
ItemAdded | (size_t index, const T&) | push_back or insert |
ItemRemoved | (size_t index, const T&) | pop_back or erase |
ItemReplaced | (size_t index, const T& oldItem, const T& newItem) | replace |
CollectionCleared | () | clear |
push_back, insert, erase, replace, pop_back, clear) mirror the std::vector API and fire the corresponding events automatically.