Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::TextElement Class Reference

UI element for rendering text. More...

#include <TextElement.h>

Inheritance diagram for clt::TextElement:
clt::WidgetElement

Public Member Functions

 TextElement (std::string text="Hello World !", std::string font="BebasNeue", Color color=Color::White, float textSize=1, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a TextElement with specified text, font name, color, size, position, and Z order.
 
 TextElement (std::string text, Color color, float textSize=1, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a TextElement with specified text, color, size, position, and Z order.
 
 TextElement (std::string text, Font *font, Color color=Color::White, float textSize=1, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a TextElement with specified text, font pointer, color, size, position, and Z order.
 
 ~TextElement ()
 Destructor for TextElement.
 
void SetText (std::string text)
 Sets the text to display.
 
void SetText (int text)
 Sets the text to display using an integer value.
 
void SetSize (float size)
 Sets the size of the text.
 
void SetColor (Color color)
 Sets the color of the text.
 
void SetAlignment (TextAlignment alignment)
 Sets the alignment of the text.
 
float GetTextWidth () const
 Gets the width of the rendered text.
 
virtual void Draw (RendererGL *renderer) override
 Draws the text element using the specified renderer.
 
- Public Member Functions inherited from clt::WidgetElement
 WidgetElement (Vector2 size={ 1, 1 }, Vector2 position={ 0, 0 }, int ZOrder=0)
 Constructs a WidgetElement with given size, position, and Z-order.
 
 ~WidgetElement ()=default
 Default destructor.
 
virtual void Update ()
 Updates the widget element. Override in derived classes.
 
int GetZOrder () const
 Gets the Z-order of the widget.
 
void SetZOrder (int ZOrder)
 Sets the Z-order and updates the widget order in the owner panel.
 
virtual Vector2 GetSize () const
 Gets the size of the widget.
 
Vector2 GetPosition () const
 Gets the position of the widget.
 
float GetRotation () const
 Gets the rotation of the widget.
 
virtual Transform2D GetTransform () const
 Gets the transform of the widget.
 
void SetSize (Vector2 size)
 Sets the size of the widget.
 
void SetSize (float size)
 Sets the size of the widget (uniform scale).
 
void SetAnchor (Anchor anchor)
 Sets the anchor type for the widget.
 
void SetPosition (Vector2 position)
 Sets the position of the widget.
 
void SetRotation (float rotation)
 Sets the rotation of the widget.
 
void ToggleVisibility ()
 Toggles the visibility of the widget.
 

Additional Inherited Members

- Public Attributes inherited from clt::WidgetElement
bool mVisibility
 
- Protected Member Functions inherited from clt::WidgetElement
void SetOwner (UIPanel *pOwner)
 Sets the owner UIPanel of this widget.
 
- Protected Attributes inherited from clt::WidgetElement
Transform2D mTransform
 
friend UIPanel
 

Detailed Description

UI element for rendering text.

TextElement allows displaying and customizing text in the UI, including font, color, size, and alignment.

Constructor & Destructor Documentation

◆ TextElement() [1/3]

TextElement::TextElement ( std::string text = "Hello World !",
std::string font = "BebasNeue",
Color color = Color::White,
float textSize = 1,
Vector2 position = { 0, 0 },
int ZOrder = 0 )

Constructs a TextElement with specified text, font name, color, size, position, and Z order.

Parameters
textThe text to display.
fontThe font name to use.
colorThe color of the text.
textSizeThe size of the text.
positionThe position of the text element.
ZOrderThe Z order for rendering.

◆ TextElement() [2/3]

TextElement::TextElement ( std::string text,
Color color,
float textSize = 1,
Vector2 position = { 0, 0 },
int ZOrder = 0 )

Constructs a TextElement with specified text, color, size, position, and Z order.

Parameters
textThe text to display.
colorThe color of the text.
textSizeThe size of the text.
positionThe position of the text element.
ZOrderThe Z order for rendering.

◆ TextElement() [3/3]

TextElement::TextElement ( std::string text,
Font * font,
Color color = Color::White,
float textSize = 1,
Vector2 position = { 0, 0 },
int ZOrder = 0 )

Constructs a TextElement with specified text, font pointer, color, size, position, and Z order.

Parameters
textThe text to display.
fontPointer to the font to use.
colorThe color of the text.
textSizeThe size of the text.
positionThe position of the text element.
ZOrderThe Z order for rendering.

Member Function Documentation

◆ Draw()

void TextElement::Draw ( RendererGL * renderer)
overridevirtual

Draws the text element using the specified renderer.

Parameters
rendererThe renderer to use for drawing.

Implements clt::WidgetElement.

◆ GetTextWidth()

float clt::TextElement::GetTextWidth ( ) const
inline

Gets the width of the rendered text.

Returns
The width of the text.

◆ SetAlignment()

void TextElement::SetAlignment ( TextAlignment alignment)

Sets the alignment of the text.

Parameters
alignmentThe new text alignment.

◆ SetColor()

void TextElement::SetColor ( Color color)

Sets the color of the text.

Parameters
colorThe new color.

◆ SetSize()

void TextElement::SetSize ( float size)

Sets the size of the text.

Parameters
sizeThe new text size.

◆ SetText() [1/2]

void TextElement::SetText ( int text)

Sets the text to display using an integer value.

Parameters
textThe integer to convert and display as text.

◆ SetText() [2/2]

void TextElement::SetText ( std::string text)

Sets the text to display.

Parameters
textThe new text string.

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