LayoutSpec
LayoutSpec
Section titled “LayoutSpec”#include <Layout.hpp>Specifies how a widget should be sized and positioned within its layout slot.
This is passed to Container::addChild() to control layout behavior. Different layout engines may use different fields.
Common usage:
// Widget takes 50% of available widthcontainer->addChild(widget, LayoutSpec{.fixedW = pct(50)});
// Widget has equal weight with siblings (stretches)container->addChild(widget, LayoutSpec{.ratio = 1.0f});Public Attributes
Section titled “Public Attributes”| Return | Name | Description |
|---|---|---|
float | ratio | Relative weight among siblings in stack layouts. Used when dividing remaining space among children. |
ScalarSpec | fixedW | Fixed slot width - overrides ratio in horizontal stacks. |
ScalarSpec | fixedH | Fixed slot height - overrides ratio in vertical stacks. |
ScalarSpec | sizeW | If set, widget is this size inside its slot. If not set, widget fills slot according to alignH/alignV. |
ScalarSpec | sizeH | |
ScalarSpec | minW | |
ScalarSpec | minH | Minimum widget size. |
ScalarSpec | maxW | |
ScalarSpec | maxH | Maximum widget size. |
Align | alignH | Horizontal alignment. |
Align | alignV | Vertical alignment. |
MarginSpec | margin | Spacing around widget. |
int | col | Column in grid (0-based) |
int | row | Row in grid (0-based) |
int | colSpan | How many columns this widget spans. |
int | rowSpan | How many rows this widget spans. |
ScalarSpec | absX | Absolute X position. |
ScalarSpec | absY | Absolute Y position. |
float ratio = 1.0fRelative weight among siblings in stack layouts. Used when dividing remaining space among children.
fixedW
Section titled “fixedW”ScalarSpec fixedWFixed slot width - overrides ratio in horizontal stacks.
fixedH
Section titled “fixedH”ScalarSpec fixedHFixed slot height - overrides ratio in vertical stacks.
ScalarSpec sizeWIf set, widget is this size inside its slot. If not set, widget fills slot according to alignH/alignV.
ScalarSpec sizeHScalarSpec minWScalarSpec minHMinimum widget size.
ScalarSpec maxWScalarSpec maxHMaximum widget size.
alignH
Section titled “alignH”Align alignH = Align::StretchHorizontal alignment.
Alignment of widget within slot. Only meaningful when sizeW/sizeH is set or widget is smaller than slot.
alignV
Section titled “alignV”Align alignV = Align::StretchVertical alignment.
margin
Section titled “margin”MarginSpec marginSpacing around widget.
int col = 0Column in grid (0-based)
int row = 0Row in grid (0-based)
colSpan
Section titled “colSpan”int colSpan = 1How many columns this widget spans.
rowSpan
Section titled “rowSpan”int rowSpan = 1How many rows this widget spans.
ScalarSpec absXAbsolute X position.
ScalarSpec absYAbsolute Y position.