GridLayout
GridLayout
Section titled “GridLayout”#include <GridLayout.hpp>Inherits:
Layout
A layout that arranges children in a 2D grid.
GridLayout divides the available space into a fixed grid of rows and columns. Children position themselves using the col, row, colSpan, and rowSpan fields in their LayoutSpec.
Example Usage:
// Create a 3x2 grid (3 columns, 2 rows) with 1 cell spacingauto grid = std::make_shared<Container>( std::make_shared<GridLayout>(3, 2, 1, 1));
// Add widgets specifying their grid positionauto widget1 = std::make_shared<Label>("Top-left");auto widget2 = std::make_shared<Label>("Top-right");auto widget3 = std::make_shared<Label>("Bottom (spans 3 cols)");
grid->addChild(widget1, LayoutSpec{.col = 0, .row = 0});grid->addChild(widget2, LayoutSpec{.col = 2, .row = 0});grid->addChild(widget3, LayoutSpec{.col = 0, .row = 1, .colSpan = 3});Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
GridLayout inline | Creates a grid layout. | |
void | apply | Applies the grid layout. |
GridLayout
Section titled “GridLayout”inline
inline GridLayout(int cols, int rows, int gapX, int gapY)Creates a grid layout.
Parameters
Section titled “Parameters”-
colsNumber of columns -
rowsNumber of rows -
gapXHorizontal spacing between columns in cells (default: 0) -
gapYVertical spacing between rows in cells (default: 0)
void apply(std::vector< core::ChildSlot > & children, core::Rect inner)Applies the grid layout.
Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
int | cols | |
int | rows | |
int | gapX | |
int | gapY |
int colsint rowsint gapXint gapY