Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    TextBlock Class

    Namespace: Stride.UI.Controls
    Assembly: Stride.UI.dll

    Provides a lightweight control for displaying small amounts of text.

    System.Object → UIElement → TextBlock
    Derived from TextBlock: ScrollingText

    [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 textToMeasure"/> in virtual pixels size.

    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.

    | Improve this Doc View Source

    Properties


    ActualTextSize

    Returns the actual size of the text in virtual pixels unit.

    public float ActualTextSize { get; }
    Property Value
    Type Description
    System.Single
    Remarks

    If TextSize is System.Single.IsNaN(System.Single), returns the default size of the Font.

    See Also
    TextSize
    Size

    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 true, the element's text is never snapped. When false, it is snapped only if the font is dynamic and the element is rendered by a SceneUIRenderer.


    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
    ActualTextSize
    Size

    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
    | Improve this Doc View Source

    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
    UIElement.ArrangeOverride(Vector3)

    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
    UIElement.MeasureOverride(Vector3)

    OnTextChanged()

    Method triggered when the Text changes. Can be overridden in inherited class to changed the default behavior.

    protected virtual void OnTextChanged()

    Inherited Members

    UIElement.InputCategory
    UIElement.PanelCategory
    UIElement.AppearanceCategory
    UIElement.BehaviorCategory
    UIElement.LayoutCategory
    UIElement.MiscCategory
    UIElement.MarginInternal
    UIElement.ArrangeChanged
    UIElement.LocalMatrixChanged
    UIElement.Id
    UIElement.DependencyProperties
    UIElement.LocalMatrix
    UIElement.BackgroundColor
    UIElement.Opacity
    UIElement.Visibility
    UIElement.ClipToBounds
    UIElement.DrawLayerNumber
    UIElement.IsEnabled
    UIElement.CanBeHitByUser
    UIElement.Width
    UIElement.Height
    UIElement.Depth
    UIElement.Size
    UIElement.HorizontalAlignment
    UIElement.VerticalAlignment
    UIElement.DepthAlignment
    UIElement.Margin
    UIElement.MinimumWidth
    UIElement.MinimumHeight
    UIElement.MinimumDepth
    UIElement.MaximumWidth
    UIElement.MaximumHeight
    UIElement.MaximumDepth
    UIElement.DefaultWidth
    UIElement.DefaultHeight
    UIElement.DefaultDepth
    UIElement.Name
    UIElement.DesiredSize
    UIElement.DesiredSizeWithMargins
    UIElement.IsArrangeValid
    UIElement.IsMeasureValid
    UIElement.WorldMatrix
    UIElement.DepthBias
    UIElement.LayoutingContext
    UIElement.VisualChildrenCollection
    UIElement.InvalidateArrange()
    UIElement.InvalidateMeasure()
    UIElement.OnNameChanged()
    UIElement.IsHierarchyEnabled
    UIElement.IsVisible
    UIElement.IsCollapsed
    UIElement.Parent
    UIElement.VisualParent
    UIElement.VisualChildren
    UIElement.HitableChildren
    UIElement.RenderOpacity
    UIElement.RenderSize
    UIElement.RenderOffsets
    UIElement.ActualWidth
    UIElement.ActualHeight
    UIElement.ActualDepth
    UIElement.IUIElementChildren.Children
    UIElement.EnumerateChildren()
    UIElement.Measure(Vector3)
    UIElement.Arrange(Vector3, Boolean)
    UIElement.CollapseOverride()
    UIElement.PropagateCollapseToChild(UIElement)
    UIElement.FindName(String)
    UIElement.SetParent(UIElement, UIElement)
    UIElement.SetVisualParent(UIElement, UIElement)
    UIElement.Intersects(Ray, Vector3)
    UIElement.IUIElementUpdate.Update(GameTime)
    UIElement.IUIElementUpdate.UpdateWorldMatrix(Matrix, Boolean)
    UIElement.IUIElementUpdate.UpdateElementState(Int32)
    UIElement.Update(GameTime)
    UIElement.UpdateWorldMatrix(Matrix, Boolean)
    UIElement.CalculateSizeWithThickness(Vector3, Thickness)
    UIElement.CalculateSizeWithoutThickness(Vector3, Thickness)
    UIElement.CalculateAdjustmentOffsets(Thickness, Vector3, Vector3)
    UIElement.IsTouched
    UIElement.MouseOverState
    UIElement.RequiresMouseOverUpdate
    UIElement.RaiseEvent(RoutedEventArgs)
    UIElement.AddHandler<T>(RoutedEvent<T>, EventHandler<T>, Boolean)
    UIElement.RemoveHandler<T>(RoutedEvent<T>, EventHandler<T>)
    UIElement.MouseOverStateChanged
    UIElement.PreviewTouchDown
    UIElement.PreviewTouchMove
    UIElement.PreviewTouchUp
    UIElement.TouchDown
    UIElement.TouchEnter
    UIElement.TouchLeave
    UIElement.TouchMove
    UIElement.TouchUp
    UIElement.OnPreviewTouchDown(TouchEventArgs)
    UIElement.OnPreviewTouchMove(TouchEventArgs)
    UIElement.OnPreviewTouchUp(TouchEventArgs)
    UIElement.OnTouchDown(TouchEventArgs)
    UIElement.OnTouchEnter(TouchEventArgs)
    UIElement.OnTouchLeave(TouchEventArgs)
    UIElement.OnTouchMove(TouchEventArgs)
    UIElement.OnTouchUp(TouchEventArgs)

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    UIElementExtensions.SetPanelZIndex(UIElement, Int32)
    UIElementExtensions.GetPanelZIndex(UIElement)
    UIElementExtensions.SetCanvasRelativeSize(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativeSize(UIElement)
    UIElementExtensions.SetCanvasRelativePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasRelativePosition(UIElement)
    UIElementExtensions.SetCanvasAbsolutePosition(UIElement, Vector3)
    UIElementExtensions.GetCanvasAbsolutePosition(UIElement)
    UIElementExtensions.SetCanvasPinOrigin(UIElement, Vector3)
    UIElementExtensions.GetCanvasPinOrigin(UIElement)
    UIElementExtensions.SetGridColumn(UIElement, Int32)
    UIElementExtensions.GetGridColumn(UIElement)
    UIElementExtensions.SetGridRow(UIElement, Int32)
    UIElementExtensions.GetGridRow(UIElement)
    UIElementExtensions.SetGridLayer(UIElement, Int32)
    UIElementExtensions.GetGridLayer(UIElement)
    UIElementExtensions.SetGridColumnSpan(UIElement, Int32)
    UIElementExtensions.GetGridColumnSpan(UIElement)
    UIElementExtensions.SetGridRowSpan(UIElement, Int32)
    UIElementExtensions.GetGridRowSpan(UIElement)
    UIElementExtensions.SetGridLayerSpan(UIElement, Int32)
    UIElementExtensions.GetGridLayerSpan(UIElement)
    VisualTreeHelper.FindVisualChildOfType<T>(UIElement, String)
    VisualTreeHelper.FindVisualChildrenOfType<T>(UIElement)
    VisualTreeHelper.FindVisualParentOfType<T>(UIElement)
    VisualTreeHelper.FindVisualRoot(UIElement)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation