API reference
Class Grid
Namespace: MicroEngine.UI
Assembly: MicroEngine.UI.dll
Guide: UI widgets
Children in rows of Columns equal cells, left to right then top to bottom: an inventory, a level select, a character roster, a keyboard on screen. Every cell is as large as the largest child; hidden children take no cell. Focus moves between cells by direction, as it does anywhere in the tree.
public sealed class Grid : WidgetInheritance
Inherited Members
Widget.Measure(UiContext), Widget.Arrange(RectF, UiContext), Widget.Draw(IRenderer, UiContext), Widget.Bounds, Widget.Visible, Widget.Enabled, Widget.Width, Widget.Height, Widget.Offset, Widget.Opacity, Widget.BlocksPointer, Widget.Parent, Widget.Root, Widget.Children, Widget.Focusable, Widget.ClipsChildren, Widget.IsFocused, Widget.IsHovered, Widget.IsPressed, Widget.IsEnabledInTree, Widget.IsVisibleInTree, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
Grid(int)
A grid of columns columns.
public Grid(int columns)Parameters
columns int
Exceptions
columns is less than 1.
Properties
Align
How a child sits in its cell (Stretch by default: it fills the cell; otherwise it keeps its size, aligned on both axes).
public Align Align { get; set; }Property Value
Children
The widgets this one contains, in focus and drawing order.
public override IReadOnlyList<Widget> Children { get; }Property Value
Columns
The number of cells in a row, at least 1.
public int Columns { get; set; }Property Value
Exceptions
The value is less than 1.
Spacing
Space between cells in UI units, across and down; null (the default) is 4 layout units.
public float? Spacing { get; set; }Property Value
Methods
Add(Widget)
Adds child in the next cell and returns the grid, so grids can be written in one expression.
public Grid Add(Widget child)Parameters
child Widget
Returns
Exceptions
The child already belongs to another widget or root.
ArrangeContent(RectF, UiContext)
Places the children within bounds; nothing by default.
protected override void ArrangeContent(RectF bounds, UiContext context)Parameters
bounds RectF
context UiContext
DrawContent(IRenderer, UiContext)
Draws the widget in Bounds, and its children.
protected override void DrawContent(IRenderer renderer, UiContext context)Parameters
renderer IRenderer
context UiContext
MeasureContent(UiContext)
The size the widget’s content needs, in UI units.
protected override Vector2 MeasureContent(UiContext context)Parameters
context UiContext
Returns
Remove(Widget)
Removes child; the children after it move back one cell. False when it was not in the grid.
public bool Remove(Widget child)Parameters
child Widget