Class TextFormatter<T>
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
LayoutRootThe layout to draw the text formatter on
initialValue
TThe initial data value
formatter
Func<T, string>A function to use to format text
name
stringThe 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
Methods
ArrangeOverride(Vector2)
Internal implementation to position the object within the allocated space.
protected override void ArrangeOverride(Vector2 alignedTopLeftCorner)
Parameters
alignedTopLeftCorner
Vector2The 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
ArrangableElementThe child being destroyed
MeasureOverride()
Internal implementation to calculate desired size.
protected override Vector2 MeasureOverride()