Open 3D Engine LyShine Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
UiTextInterface Class Referenceabstract

Inherits AZ::ComponentBus.

Public Types

enum class  OverflowMode { OverflowText , ClipText , Ellipsis }
 Determines how text overflow should behave. More...
 
enum class  WrapTextSetting { NoWrap , Wrap }
 Provides values for determining whether text is wrapped or not.
 
enum class  ShrinkToFit { None , Uniform , WidthOnly }
 
enum  GetTextFlags { GetAsIs = 0 , GetLocalized = 1 << 0 }
 Determines what processing should be performed on text before returning.
 
enum  SetTextFlags { SetAsIs = 0 , SetEscapeMarkup = 1 << 0 , SetLocalized = 1 << 1 }
 Determines how text should be assigned.
 
typedef AZStd::function< AZStd::string(const AZStd::string &)> DisplayedTextFunction
 Callback type for retrieving displayed text.
 

Public Member Functions

virtual AZStd::string GetText ()=0
 
virtual void SetText (const AZStd::string &text)=0
 
virtual AZStd::string GetTextWithFlags (GetTextFlags flags=GetAsIs)=0
 
virtual void SetTextWithFlags (const AZStd::string &text, SetTextFlags flags=SetAsIs)=0
 
virtual AZ::Color GetColor ()=0
 
virtual void SetColor (const AZ::Color &color)=0
 
virtual LyShine::PathnameType GetFont ()=0
 Returns font object used by the displayed text.
 
virtual void SetFont (const LyShine::PathnameType &fontPath)=0
 
virtual int GetFontEffect ()=0
 
virtual void SetFontEffect (int effectIndex)=0
 
virtual AZStd::string GetFontEffectName (int effectIndex)=0
 
virtual void SetFontEffectByName (const AZStd::string &effectName)=0
 
virtual float GetFontSize ()=0
 
virtual void SetFontSize (float size)=0
 
virtual void GetTextAlignment (IDraw2d::HAlign &horizontalAlignment, IDraw2d::VAlign &verticalAlignment)=0
 
virtual void SetTextAlignment (IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment)=0
 
virtual IDraw2d::HAlign GetHorizontalTextAlignment ()=0
 
virtual void SetHorizontalTextAlignment (IDraw2d::HAlign alignment)=0
 
virtual IDraw2d::VAlign GetVerticalTextAlignment ()=0
 
virtual void SetVerticalTextAlignment (IDraw2d::VAlign alignment)=0
 
virtual float GetCharacterSpacing ()=0
 
virtual void SetCharacterSpacing (float characterSpacing)=0
 
virtual float GetLineSpacing ()=0
 
virtual void SetLineSpacing (float lineSpacing)=0
 
virtual int GetCharIndexFromPoint (AZ::Vector2 point, bool mustBeInBoundingBox)=0
 
virtual int GetCharIndexFromCanvasSpacePoint (AZ::Vector2 point, bool mustBeInBoundingBox)=0
 
virtual AZ::Vector2 GetPointFromCharIndex (int index)=0
 
virtual AZ::Color GetSelectionColor ()=0
 
virtual void GetSelectionRange (int &startIndex, int &endIndex)=0
 
virtual void SetSelectionRange (int startIndex, int endIndex, const AZ::Color &selectionColor)=0
 
virtual void ClearSelectionRange ()=0
 Clear any text selection range that has been applied to this text.
 
virtual AZ::Vector2 GetTextSize ()=0
 Get the width and height of the text.
 
virtual float GetTextWidth ()=0
 Get the width of the text.
 
virtual float GetTextHeight ()=0
 Get the height of the text.
 
virtual void GetTextBoundingBox (int startIndex, int endIndex, UiTransformInterface::RectPointsArray &rectPoints)=0
 
virtual DisplayedTextFunction GetDisplayedTextFunction () const =0
 
virtual void SetDisplayedTextFunction (const DisplayedTextFunction &displayedTextFunction)=0
 
virtual OverflowMode GetOverflowMode ()=0
 Gets the overflow behavior of this component.
 
virtual void SetOverflowMode (OverflowMode overflowMode)=0
 Sets the overflow setting of this component.
 
virtual WrapTextSetting GetWrapText ()=0
 Gets the text wrapping setting of this component.
 
virtual void SetWrapText (WrapTextSetting wrapSetting)=0
 Sets the text wrapping setting of this component.
 
virtual ShrinkToFit GetShrinkToFit ()=0
 Gets the "shrink-to-fit" value of this component.
 
virtual void SetShrinkToFit (ShrinkToFit shrinkToFit)=0
 Sets the "shrink-to-fit" value of this component.
 
virtual void ResetCursorLineHint ()=0
 Typically triggered when input mechanism (keyboard vs. mouse) changes/alternates.
 
virtual bool GetIsMarkupEnabled ()=0
 Get whether markup is enabled. If true then the text string is parsed for XML markup.
 
virtual void SetIsMarkupEnabled (bool isEnabled)=0
 Set whether markup is enabled. If true then the text string is parsed for XML markup.
 
virtual float GetMinimumShrinkScale ()=0
 Gets the minimum shrink scale when using ShrinkToFit.
 
virtual void SetMinimumShrinkScale (float minShrinkScale)=0
 Sets the minimum shrink scale when using ShrinkToFit.
 

Static Public Attributes

static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single
 Only one component on a entity can implement the events.
 

Member Enumeration Documentation

◆ OverflowMode

Determines how text overflow should behave.

Enumerator
OverflowText 

text contents aren't impacted by element size (and vice versa)

ClipText 

clips text contents to fit width of element

Ellipsis 

truncates displayed text to fit element and appends ellipsis to the text

◆ ShrinkToFit

Controls whether text should shrink (scale down) to prevent overflowing.

The amount of scale applied to text can be limited by minimum shrink scale.

Enumerator
None 

No shrinking is applied to text.

Uniform 

Shrink text uniformly along X/Y dimension (maintains aspect ratio)

WidthOnly 

Only scales text along X axis (width)

Member Function Documentation

◆ GetCharIndexFromCanvasSpacePoint()

virtual int UiTextInterface::GetCharIndexFromCanvasSpacePoint ( AZ::Vector2  point,
bool  mustBeInBoundingBox 
)
pure virtual

Given a point in untransformed canvas space, return the character index in the string

Parameters
pointa point in untransformed canvas space
mustBeInBoundingBoxif true the given point be be contained in the bounding box of actual text characters (not the element). If false it can be anywhere (even outside the element) and is projected onto a text position (for drag select for example).
Returns
-1 if second param is true and point is outside box 0 if to left of first char, 1 if between first and second char, length of string if to right of last char

◆ GetCharIndexFromPoint()

virtual int UiTextInterface::GetCharIndexFromPoint ( AZ::Vector2  point,
bool  mustBeInBoundingBox 
)
pure virtual

Given a point in viewport space, return the character index in the string

Parameters
pointa point in viewport space
mustBeInBoundingBoxif true the given point be be contained in the bounding box of actual text characters (not the element). If false it can be anywhere (even outside the element) and is projected onto a text position (for drag select for example).
Returns
-1 if second param is true and point is outside box 0 if to left of first char, 1 if between first and second char, length of string if to right of last char

◆ GetDisplayedTextFunction()

virtual DisplayedTextFunction UiTextInterface::GetDisplayedTextFunction ( ) const
pure virtual

Returns the function object used to manipulate a given string to condition it for rendering. The default displayed text function for a UiTextComponent is pass-through (the passed string is returned as-is).

◆ GetPointFromCharIndex()

virtual AZ::Vector2 UiTextInterface::GetPointFromCharIndex ( int  index)
pure virtual

Returns the XY coord of the rendered character position at a given index. Imagining a rect encompassing the character width and line height, the returned coordinate is the upper-left corner of the rect.

Parameters
indexIndex into displayed string.

◆ GetText()

virtual AZStd::string UiTextInterface::GetText ( )
pure virtual

Returns the unaltered contents of the string contained within the text component.

Returns
Unaltered string contents of this text component

◆ GetTextBoundingBox()

virtual void UiTextInterface::GetTextBoundingBox ( int  startIndex,
int  endIndex,
UiTransformInterface::RectPointsArray &  rectPoints 
)
pure virtual

Get the bounding box (in viewport space, so it can be rotated) of the given text range If startIndex and endIndex are the same then a rect is still returned that is one pixel wide

Parameters
startIndex0 means starting at the first character
endIndexif equal to text string length that means including the last char
rectPointsOutput parameter that gets populated with up to three RectPoints for multi-line text selection geometry.

◆ SetDisplayedTextFunction()

virtual void UiTextInterface::SetDisplayedTextFunction ( const DisplayedTextFunction displayedTextFunction)
pure virtual

Allows setting a DisplayedTextFunction object to be called prior to rendering. The string contents of a UiTextComponent can be modified for rendering without changing the actual contents of the text component (GetText()). This functionality is useful in some situations, like password hiding, where the displayed text should be different from the stored text.

◆ SetSelectionRange()

virtual void UiTextInterface::SetSelectionRange ( int  startIndex,
int  endIndex,
const AZ::Color &  selectionColor 
)
pure virtual

Set a range of the text string to be shown as selected

If startIndex and endIndex are the same then a one pixel wide vertical bar is highlighted.

The provided start and end indices are "character" indices into a UTF8 string. For example, an index of 1 could actually be mapped at buffer index 2 if the first character in the UTF8 string is a multi-byte character of size 2.

Parameters
startIndex0 means starting at the left edge first character
endIndexif equal to UTF8 text string length that means up to the right edge of the last char
selectionColorthe selection color (for box drawn behind text)

The documentation for this class was generated from the following file: