AdvancedGridLayout

The is a fancier grid layout with support for items that span multiple rows or columns, and per-widget alignment flags. Each row and column additionally stores a stretch factor that controls how additional space is redistributed. The downside of this flexibility is that a layout anchor data structure must be provided for each widget.

An example:

Label label = new Label(window, "A label"); // Add a centered label at grid position (1, 5), which spans two horizontal cells layout.setAnchor(label, AdvancedGridLayout.Anchor(1, 5, 2, 1, Alignment.Middle, Alignment.Middle));

The grid is initialized with user-specified column and row size vectors (which can be expanded later on if desired). If a size value of zero is specified for a column or row, the size is set to the maximum preferred size of any widgets contained in the same row or column. Any remaining space is redistributed according to the row and column stretch factors.

The high level usage somewhat resembles the classic HIG layout:

- https://web.archive.org/web/20070813221705/http://www.autel.cz/dmi/tutorial.html - https://github.com/jaapgeurts/higlayout

Constructors

this
this(int[] cols, int[] rows, int margin)

Creates an AdvancedGridLayout with specified columns, rows, and margin.

Members

Functions

anchor
Anchor anchor(Widget widget)

Retrieve the anchor data structure for a given widget

appendCol
void appendCol(int size, float stretch)

Append a column of the given size (and stretch factor)

appendRow
void appendRow(int size, float stretch)

Append a row of the given size (and stretch factor)

colCount
int colCount()

Return the number of cols

computeLayout
void computeLayout(NanoContext ctx, Widget widget, Array!(int)[2] _grid)

Computes the layout

margin
int margin()

The margin of this AdvancedGridLayout.

margin
void margin(int margin)

Sets the margin of this AdvancedGridLayout.

performLayout
void performLayout(NanoContext ctx, Widget widget)
Undocumented in source. Be warned that the author may not have intended to support it.
preferredSize
Vector2i preferredSize(NanoContext ctx, Widget widget, Widget skipped)
Undocumented in source. Be warned that the author may not have intended to support it.
rowCount
int rowCount()

Return the number of rows

setAnchor
void setAnchor(Widget widget, Anchor anchor)

Specify the anchor data structure for a given widget

setColStretch
void setColStretch(int index, float stretch)

Set the stretch factor of a given column

setRowStretch
void setRowStretch(int index, float stretch)

Set the stretch factor of a given row

Structs

Anchor
struct Anchor

Helper struct to coordinate anchor points for the layout.

Variables

mAnchor
Anchor[const Widget] mAnchor;

The mapping of widgets to their specified anchor points.

mColStretch
Array!float mColStretch;

The stretch for each column of this AdvancedGridLayout.

mCols
Array!int mCols;

The columns of this AdvancedGridLayout.

mMargin
int mMargin;

The margin around this AdvancedGridLayout.

mRowStretch
Array!float mRowStretch;

The stretch for each row of this AdvancedGridLayout.

mRows
Array!int mRows;

The rows of this AdvancedGridLayout.

Inherited Members

From Layout

performLayout
void performLayout(NanoContext ctx, Widget widget)

Performs any and all resizing applicable.

preferredSize
Vector2i preferredSize(NanoContext ctx, Widget widget, Widget skipped)

The preferred size for this layout.

margin
int margin()

The margin of this Layout.

margin
void margin(int )

Sets the margin of this Layout.

Meta