TextBlock Class
Namespace: Stride.UI.ControlsAssembly: Stride.UI.dll
Provides a lightweight control for displaying small amounts of text.
[DataContract("TextBlock")]
public class TextBlock : UIElement, IUIElementUpdate, IUIElementChildren, IIdentifiable
Name | Description | |
---|---|---|
Properties | ||
ActualTextSize | Returns the actual size of the text in virtual pixels unit. |
|
DoNotSnapText | Gets or sets the value indicating if the snapping of the Text of the TextBlock to the closest screen pixel should be skipped. |
|
Font | Gets or sets the font of the text block. |
|
SynchronousCharacterGeneration | Gets or sets the value indicating if the text block should generate Stride.Graphics.Font.RuntimeRasterizedSpriteFont characters synchronously or asynchronously. |
|
Text | Gets or sets the text of the text block. |
|
TextAlignment | Gets or sets the alignment of the text to display. |
|
TextColor | Gets or sets the color of the text. |
|
TextSize | Gets or sets the size of the text in virtual pixels unit. |
|
TextToDisplay | Returns the text to display during the draw call. |
|
WrapText | Gets or sets the value indicating if the Text of the TextBlock should automatically return to the beginning of the line when it is too long for the line width. |
|
Methods | ||
ArrangeOverride(Vector3) | When overridden in a derived class, positions possible child elements and determines a size for a UIElement derived class. |
|
CalculateTextSize() | Calculate and returns the size of the Text in virtual pixels size. |
|
CalculateTextSize(String) | Calculate and returns the size of the provided |
|
MeasureOverride(Vector3) | When overridden in a derived class, measures the size in layout required for possible child elements and determines a size for the UIElement-derived class. |
|
OnTextChanged() | Method triggered when the Text changes. Can be overridden in inherited class to changed the default behavior. |
Properties
ActualTextSize
Returns the actual size of the text in virtual pixels unit.
public float ActualTextSize { get; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
See Also
DoNotSnapText
Gets or sets the value indicating if the snapping of the Text of the TextBlock to the closest screen pixel should be skipped.
[DataMember]
[Display(null, "Behavior")]
public bool DoNotSnapText { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
When
Font
Gets or sets the font of the text block.
[DataMember]
[Display(null, "Appearance")]
public SpriteFont Font { get; set; }
Property Value
Type | Description |
---|---|
SpriteFont |
SynchronousCharacterGeneration
Gets or sets the value indicating if the text block should generate Stride.Graphics.Font.RuntimeRasterizedSpriteFont characters synchronously or asynchronously.
[DataMember]
[Display(null, "Behavior")]
public bool SynchronousCharacterGeneration { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
If synchronous generation is activated, the game will be block until all the characters have finished to be generate. If asynchronous generation is activated, some characters can appears with one or two frames of delay.
Text
Gets or sets the text of the text block.
[DataMember]
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String |
TextAlignment
Gets or sets the alignment of the text to display.
[DataMember]
[Display(null, "Appearance")]
public TextAlignment TextAlignment { get; set; }
Property Value
Type | Description |
---|---|
TextAlignment |
TextColor
Gets or sets the color of the text.
[DataMember]
[Display(null, "Appearance")]
public Color TextColor { get; set; }
Property Value
Type | Description |
---|---|
Color |
TextSize
Gets or sets the size of the text in virtual pixels unit.
[DataMember]
[DataMemberRange(0, 3)]
[Display(null, "Appearance")]
public float TextSize { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
If the value set is null
, the default size of the Font will be used instead.
See Also
TextToDisplay
Returns the text to display during the draw call.
public virtual string TextToDisplay { get; }
Property Value
Type | Description |
---|---|
System.String |
WrapText
Gets or sets the value indicating if the Text of the TextBlock should automatically return to the beginning of the line when it is too long for the line width.
[DataMember]
[Display(null, "Behavior")]
public bool WrapText { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
ArrangeOverride(Vector3)
When overridden in a derived class, positions possible child elements and determines a size for a UIElement derived class.
protected override Vector3 ArrangeOverride(Vector3 finalSizeWithoutMargins)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | finalSizeWithoutMargins | The final area within the parent that this element should use to arrange itself and its children. |
Returns
Type | Description |
---|---|
Vector3 | The actual size used. |
Overrides
CalculateTextSize()
Calculate and returns the size of the Text in virtual pixels size.
public Vector2 CalculateTextSize()
Returns
Type | Description |
---|---|
Vector2 | The size of the Text in virtual pixels. |
CalculateTextSize(String)
Calculate and returns the size of the provided textToMeasure
"/> in virtual pixels size.
protected Vector2 CalculateTextSize(string textToMeasure)
Parameters
Type | Name | Description |
---|---|---|
System.String | textToMeasure | The text to measure |
Returns
Type | Description |
---|---|
Vector2 | The size of the text in virtual pixels |
MeasureOverride(Vector3)
When overridden in a derived class, measures the size in layout required for possible child elements and determines a size for the UIElement-derived class.
protected override Vector3 MeasureOverride(Vector3 availableSizeWithoutMargins)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | availableSizeWithoutMargins | The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available. |
Returns
Type | Description |
---|---|
Vector3 | The size desired by the children |
Overrides
OnTextChanged()
Method triggered when the Text changes. Can be overridden in inherited class to changed the default behavior.
protected virtual void OnTextChanged()