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
TThe 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
onLayoutLayoutRootThe layout to draw the text formatter on
initialValueTThe initial data value
formatterFunc<T, string>A function to use to format text
namestringThe 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
alignedTopLeftCornerVector2The 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
childArrangableElementThe child being destroyed
MeasureOverride()
Internal implementation to calculate desired size.
protected override Vector2 MeasureOverride()