Skip to content

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.

C#
public sealed class Grid : Widget

Inheritance

object ← Widget ← Grid

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.

C#
public Grid(int columns)

Parameters

columns int

Exceptions

ArgumentOutOfRangeException

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).

C#
public Align Align { get; set; }

Property Value

Align

Children

The widgets this one contains, in focus and drawing order.

C#
public override IReadOnlyList<Widget> Children { get; }

Property Value

IReadOnlyList<Widget>

Columns

The number of cells in a row, at least 1.

C#
public int Columns { get; set; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is less than 1.

Spacing

Space between cells in UI units, across and down; null (the default) is 4 layout units.

C#
public float? Spacing { get; set; }

Property Value

float?

Methods

Add(Widget)

Adds child in the next cell and returns the grid, so grids can be written in one expression.

C#
public Grid Add(Widget child)

Parameters

child Widget

Returns

Grid

Exceptions

InvalidOperationException

The child already belongs to another widget or root.

ArrangeContent(RectF, UiContext)

Places the children within bounds; nothing by default.

C#
protected override void ArrangeContent(RectF bounds, UiContext context)

Parameters

bounds RectF

context UiContext

DrawContent(IRenderer, UiContext)

Draws the widget in Bounds, and its children.

C#
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.

C#
protected override Vector2 MeasureContent(UiContext context)

Parameters

context UiContext

Returns

Vector2

Remove(Widget)

Removes child; the children after it move back one cell. False when it was not in the grid.

C#
public bool Remove(Widget child)

Parameters

child Widget

Returns

bool