StackLayout
StackLayout
Section titled “StackLayout”#include <StackLayout.hpp>Inherits:
Layout
A layout that stacks children in a single row or column.
StackLayout arranges children either horizontally or vertically. Each child’s size is determined by:
-
Its fixed size (if specified via LayoutSpec)
-
Its ratio weight (if dividing remaining space)
Features:
-
Vertical (default) or horizontal arrangement
-
Flexible sizing with ratio weights
-
Fixed sizing with cells() or pct()
-
Spacing between children (gap)
Example Usage:
// Vertical stack (default)auto vstack = std::make_shared<Container>( std::make_shared<StackLayout>(Axis::Vertical, 1) // 1 cell gap);
// Horizontal stackauto hstack = std::make_shared<Container>( std::make_shared<StackLayout>(Axis::Horizontal, 2));Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
StackLayout inline explicit | Creates a stack layout. | |
void | apply | Applies the layout by stacking children along the axis. |
StackLayout
Section titled “StackLayout”inline explicit
inline explicit StackLayout(Axis axis, int gap)Creates a stack layout.
Parameters
Section titled “Parameters”-
axisThe direction to stack (default: Vertical) -
gapSpacing between children in cells (default: 0)
void apply(std::vector< core::ChildSlot > & children, core::Rect inner)Applies the layout by stacking children along the axis.
Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
Axis | axis | |
int | gap |
Axis axisint gapPrivate Methods
Section titled “Private Methods”| Return | Name | Description |
|---|---|---|
core::Rect | resolveSlot |
resolveSlot
Section titled “resolveSlot”core::Rect resolveSlot(const core::ChildSlot & slot, int x, int y, int w, int h)