Table of Contents

Class TextFormatter<T>

Namespace
MagicUI.Elements
Assembly
MagicUI.dll

An element that formats an underlying TextObject according to a formatter for an immutable data type

public sealed class TextFormatter<T> : ArrangableElement, ILayoutParent

Type Parameters

T

The type of data to format

Inheritance
TextFormatter<T>
Implements
Inherited Members
Extension Methods

Constructors

TextFormatter(LayoutRoot, T, Func<T, string>, string)

Creates a text formatter

public TextFormatter(LayoutRoot onLayout, T initialValue, Func<T, string> formatter, string name = "New TextFormatter")

Parameters

onLayout LayoutRoot

The layout to draw the text formatter on

initialValue T

The initial data value

formatter Func<T, string>

A function to use to format text

name string

The name of the text formatter

Properties

Data

The data to be formatted. This should be treated as immutable data to update properly. In other words,

Data.X = Y
will not trigger an update, but
Data = new(...)
will.
public T Data { get; set; }

Property Value

T

Text

The underlying TextObject to be formatted. You control all other properties of the TextObject directly, this element will control the Text property via Data

public TextObject? Text { get; set; }

Property Value

TextObject

Methods

ArrangeOverride(Vector2)

Internal implementation to position the object within the allocated space.

protected override void ArrangeOverride(Vector2 alignedTopLeftCorner)

Parameters

alignedTopLeftCorner Vector2

The space available for the element.

DestroyOverride()

Internal implementation to perform any additional cleanup when the element is destroyed

protected override void DestroyOverride()

HandleChildDestroyed(ArrangableElement)

Additional handling for when a child is being destroyed

public void HandleChildDestroyed(ArrangableElement child)

Parameters

child ArrangableElement

The child being destroyed

MeasureOverride()

Internal implementation to calculate desired size.

protected override Vector2 MeasureOverride()

Returns

Vector2