Layout API
v0.5 introduces native layout builders and child placement APIs. Row and Column use the stack API, SplitPane manages two panes, and Grid places children into fixed or weighted tracks.
Row And Column
Row and Column are stack layout parents. Attach existing children or create new child objects through the stack helpers, then tune gap, padding, justify, align, and optional background color.
row_uid = objects.create_object(builders.ROW, 'Main', 0.9, 0.2, 0.05, 0.05)
row = objects.get_object_by_uid(row_uid)
objects.tuix_stack_set_gap(row, 2)
objects.tuix_stack_set_padding(row, 1, 1, 1, 1)
objects.tuix_stack_set_justify(row, builders.JUSTIFY_SPACE_BETWEEN)
objects.tuix_stack_set_align(row, builders.ALIGN_STRETCH)
label_uid = objects.tuix_stack_add_object(row, 'Main', builders.TEXT, 1.0, 1.0)
buffers.set_buffer_layout_slot_by_uid(label_uid, grow=1.0, min_w=12)Layout Slot Overrides
A layout slot describes how a child participates in parent layout. It supports grow, shrink, basis, min/max sizes, align_self, and grid placement fields.
| Function | Purpose |
|---|---|
| buffers.set_buffer_layout_slot_by_uid(uid, ...) | Sets flex/grid slot values for a child buffer. |
| buffers.get_buffer_layout_slot_by_uid(uid) | Returns current slot fields as a dict. |
| buffers.set_buffer_layout_rect_by_uid(uid, left, top, width, height) | Sets an explicit rectangle override in terminal cells. |
| buffers.clear_buffer_layout_rect_by_uid(uid) | Clears the explicit rectangle override. |
Grid
Grid uses fixed and weighted row/column tracks. Place children with buffers.set_buffer_grid_placement_by_uid(...) or by supplying grid fields in the layout slot.
grid_uid = objects.create_object(builders.GRID, 'Main', 0.9, 0.5, 0.35, 0.05)
grid = objects.get_object_by_uid(grid_uid)
objects.tuix_grid_set_columns(grid, [
(builders.GRID_TRACK_WEIGHT, 1),
(builders.GRID_TRACK_FIXED, 24),
])
objects.tuix_grid_set_rows(grid, [
(builders.GRID_TRACK_FIXED, 3),
(builders.GRID_TRACK_WEIGHT, 1),
])
objects.tuix_grid_set_gaps(grid, 1, 1)
child_uid = objects.tuix_grid_add_object(grid, 'Main', builders.TEXT, 1.0, 1.0)
buffers.set_buffer_grid_placement_by_uid(child_uid, row=1, col=0, row_span=1, col_span=2)SplitPane
SplitPane manages two attached children. Configure orientation, split ratio or absolute split pixels, divider size, minimum pane sizes, and colors.
split_uid = objects.create_object(builders.SPLITPANE, 'Main', 0.9, 0.6, 0.2, 0.05)
split = objects.get_object_by_uid(split_uid)
objects.tuix_splitpane_set_orientation(split, builders.AXIS_HORIZONTAL)
objects.tuix_splitpane_set_split_ratio(split, 0.35)
objects.tuix_splitpane_set_min_sizes(split, 10, 10)Constants
| Constant | Meaning |
|---|---|
| AXIS_HORIZONTAL / AXIS_VERTICAL | Orientation for split panes and axis-aware widgets. |
| JUSTIFY_START / CENTER / END / SPACE_BETWEEN | Main-axis distribution for Row and Column. |
| ALIGN_START / CENTER / END / STRETCH / AUTO | Cross-axis alignment for stack children. |
| GRID_TRACK_FIXED / GRID_TRACK_WEIGHT | Grid track sizing modes. |