GridBox
Multi-column grid container placing children into uniform cells or custom track templates.
Overview
GridBox arranges children in a two-dimensional grid. By default, it splits available width into a fixed number of uniform columns (columns(n)) and lays out children sequentially in row-major order.
Spacing can be configured globally via spacing(px) or independently via horizontalSpacing(px) and verticalSpacing(px).
For complex tracks (proportional fr, pixel px, or minmax), assign custom track templates with gridColumns(GridTrack...).
Inventory Grid
GridBox grid = new GridBox()
.columns(4)
.spacing(6.0f);
for (ItemSlot slot : slots) {
grid.addChild(slot);
}
Related links
API
GridBox::columns(int)
Set Columns
Sets fixed column count for automatic grid distribution.
| Parameter | Type | Description |
|---|---|---|
columns |
int |
number of columns; minimum 1 |
Returns GridBox: this widget for fluent configuration.
GridBox::spacing(float)
Set Spacing
Sets uniform row and column spacing in UI pixels.
| Parameter | Type | Description |
|---|---|---|
spacing |
float |
gap in UI pixels |
Returns GridBox: this widget for fluent configuration.
GridBox::horizontalSpacing(float)
Set Horizontal Spacing
Sets column gap in UI pixels.
| Parameter | Type | Description |
|---|---|---|
horizontalSpacing |
float |
horizontal gap in pixels |
Returns GridBox: this widget for fluent configuration.
GridBox::verticalSpacing(float)
Set Vertical Spacing
Sets row gap in UI pixels.
| Parameter | Type | Description |
|---|---|---|
verticalSpacing |
float |
vertical gap in pixels |
Returns GridBox: this widget for fluent configuration.