API reference
Class Layer
Namespace: MicroEngine.UI
Assembly: MicroEngine.UI.dll
Guide: UI widgets
The whole UI view, with each child placed on its own: against an edge or a corner (a banner in a corner, a HUD block), or at a point (a speech bubble over a character, a damage number, a marker that follows something in the world). Children keep the size they measure; later children draw over earlier ones. Where no child is, the pointer passes through to gameplay. Use it as a root’s Content.
public sealed class Layer : 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
Layer()
public Layer()Properties
BlocksPointer
The layer’s empty areas are not the UI’s: presses there reach gameplay.
public override bool BlocksPointer { get; }Property Value
Children
The widgets this one contains, in focus and drawing order.
public override IReadOnlyList<Widget> Children { get; }Property Value
Methods
Add(Widget, Anchor, Vector2)
Adds child with its anchor point on the layer’s same point, moved by
offset: Add(banner, Anchor.TopRight, new(-4, 4)) puts a banner 4 units from the top-right
corner. Returns the layer.
public Layer Add(Widget child, Anchor anchor = Anchor.TopLeft, Vector2 offset = default)Parameters
child Widget
anchor Anchor
offset Vector2
Returns
Exceptions
The child already belongs to another widget or root.
AddAt(Widget, Vector2, Anchor)
Adds child with its pivot point at point (UI units from the
layer’s top-left): AddAt(bubble, head, Anchor.Bottom) puts a bubble’s bottom centre over a head. Returns the
layer.
public Layer AddAt(Widget child, Vector2 point, Anchor pivot = Anchor.Center)Parameters
child Widget
point Vector2
pivot Anchor
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 UI view’s size: a layer fills it.
protected override Vector2 MeasureContent(UiContext context)Parameters
context UiContext
Returns
Move(Widget, Vector2)
Moves child’s pivot to point, keeping its pivot (the centre if it was placed
against an edge). Call it every update to follow something that moves.
public void Move(Widget child, Vector2 point)Parameters
child Widget
point Vector2
Exceptions
The child is not in this layer.
Place(Widget, Anchor, Vector2)
Places child against the layer’s anchor point, as Add does.
public void Place(Widget child, Anchor anchor, Vector2 offset = default)Parameters
child Widget
anchor Anchor
offset Vector2
Exceptions
The child is not in this layer.
Remove(Widget)
Removes child; false when it was not in the layer.
public bool Remove(Widget child)Parameters
child Widget