Skip to content

API reference

Class Label

Namespace: MicroEngine.UI
Assembly: MicroEngine.UI.dll
Guide: UI widgets

Text that does nothing: a heading, a value, a hint, a line of dialogue. Lines are separated by \n; with Wrap and a fixed Width the text also breaks between words to fit. Set VisibleCharacters to reveal it a little at a time: the lines stay where the whole text puts them.

C#
public sealed class Label : Widget

Inheritance

object ← Widget ← Label

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

Label(string)

A label showing text.

C#
public Label(string text = "")

Parameters

text string

Properties

Color

The text’s colour; null (the default) is the theme’s text colour, or its muted colour while disabled.

C#
public Color? Color { get; set; }

Property Value

Color?

Lines

The lines the text is drawn in, after wrapping, as of the last layout.

C#
public IReadOnlyList<string> Lines { get; }

Property Value

IReadOnlyList<string>

Shadow

Whether the text has the theme’s shadow under it (true by default).

C#
public bool Shadow { get; set; }

Property Value

bool

Text

The text; null counts as empty.

C#
public string Text { get; set; }

Property Value

string

VisibleCharacters

How many characters of Text are drawn, counted in the text as written (spaces and \n included); null (the default) draws all of it. The label keeps the size and the lines of its whole text, so a text revealed a little at a time never moves. Raise it over time for a typewriter effect.

C#
public int? VisibleCharacters { get; set; }

Property Value

int?

VisibleLines

The part of each of Lines that VisibleCharacters shows.

C#
public IReadOnlyList<string> VisibleLines { get; }

Property Value

IReadOnlyList<string>

Wrap

Whether the text breaks between words so no line is wider than the label’s fixed Width (false by default); a word wider than that on its own is broken between characters. Without a fixed width the text keeps its lines. The label grows in height to hold the lines.

C#
public bool Wrap { get; set; }

Property Value

bool

Methods

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