Skip to content

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:

  1. Its fixed size (if specified via LayoutSpec)

  2. 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 stack
auto hstack = std::make_shared<Container>(
std::make_shared<StackLayout>(Axis::Horizontal, 2)
);
ReturnNameDescription
StackLayout inline explicitCreates a stack layout.
voidapplyApplies the layout by stacking children along the axis.

inline explicit

inline explicit StackLayout(Axis axis, int gap)

Creates a stack layout.

  • axis The direction to stack (default: Vertical)

  • gap Spacing 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.

ReturnNameDescription
Axisaxis
intgap

Axis axis

int gap
ReturnNameDescription
core::RectresolveSlot

core::Rect resolveSlot(const core::ChildSlot & slot, int x, int y, int w, int h)