R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GUI::ECS::Components::TextComponent Class Reference

A class that represents a text component in the GUI system. It manages font, size, color, and position of text entities in a graphical application. More...

#include <TextComponent.hpp>

Inheritance diagram for GUI::ECS::Components::TextComponent:
Inheritance graph
Collaboration diagram for GUI::ECS::Components::TextComponent:
Collaboration graph

Public Member Functions

 TextComponent ()
 Default constructor. Initializes the text component with default values.
 
 TextComponent (const std::uint32_t entityId)
 Constructor with an entity ID.
 
 TextComponent (const std::uint32_t entityId, const std::string &fontPath)
 Constructor with an entity ID and a font path.
 
 TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text)
 Constructor with an entity ID, a font path, and text content.
 
 TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text, const unsigned int &size)
 Constructor with an entity ID, font path, text content, and font size.
 
 TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor)
 Constructor with detailed parameters.
 
 TextComponent (const std::uint32_t entityId, const std::string &fontPath, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor, const std::pair< float, float > &position)
 Constructor with full parameter specification.
 
 TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance)
 Constructor with a font instance.
 
 TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text)
 Constructor with a font instance and text content.
 
 TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text, const unsigned int &size)
 Constructor with a font instance, text content, and font size.
 
 TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor)
 Constructor with detailed parameters and a font instance.
 
 TextComponent (const std::uint32_t entityId, const GUI::ECS::Systems::Font &fontInstance, const std::string &text, const unsigned int &size, const GUI::ECS::Systems::Colour &normalColor, const GUI::ECS::Systems::Colour &hoverColor, const GUI::ECS::Systems::Colour &clickedColor, const std::pair< float, float > &position)
 Constructor with detailed parameters and a font instance, including position.
 
 ~TextComponent ()
 Destructor for TextComponent.
 
void setFont (const GUI::ECS::Systems::Font &font)
 Set the Font of the text using a loaded Font instance from GUI::ECS::Systems::Font.
 
void setNormalColor (const GUI::ECS::Systems::Colour &color)
 Set the default colour of the text object.
 
void setHoverColor (const GUI::ECS::Systems::Colour &color)
 Set the Hover Color of the text object.
 
void setClickedColor (const GUI::ECS::Systems::Colour &color)
 Set the Clicked Color of the text object.
 
void setText (const std::string &text)
 Set the Text.
 
void setSize (const std::uint32_t &size)
 Set the Size of the text.
 
void setFontPath (const std::string &fontPath, const std::string &name="")
 Set the font from a path (this will attempt to load the font internally)
 
void setPosition (const std::pair< float, float > &position)
 Set the Position of the text.
 
void setVisible (const bool visible)
 Set the visibility of the object using a boolean.
 
void setName (const std::string &name)
 Set the Name of the component.
 
void setApplication (const std::string &application)
 Set the application context of the component.
 
void toggleVisibility ()
 Toggle the visibility of the object. hidden.
 
const bool isVisible () const
 Check if the text is set to be rendered or not.
 
const GUI::ECS::Systems::Font getFont () const
 Get the Font object contained in the class.
 
const std::string getFontPath () const
 Get the Font Path object.
 
const GUI::ECS::Systems::Colour getNormalColor () const
 Get the Normal Color of the text.
 
const GUI::ECS::Systems::Colour getHoverColor () const
 Get the Hover Color of the text.
 
const GUI::ECS::Systems::Colour getClickedColor () const
 Get the Clicked Color of the text.
 
const std::string getText () const
 Get the Text that was set in the class.
 
const std::uint32_t getSize () const
 Get the Size of the text.
 
const std::pair< float, float > getPosition () const
 Get the Position of the text.
 
const bool getVisible () const
 Get the Visibility of the text.
 
const std::string getInfo (const unsigned int indent=0) const
 This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.
 
const GUI::ECS::Systems::Collision getCollision () const
 Function in charge of returning the collision instance of the text component.
 
const std::string getName () const
 Get the Name text component.
 
const std::string getApplication () const
 Get the Application context of the component.
 
std::any render () const
 Function in charge of rendering the text if it is set to visible, otherwise, does nothing.
 
void update (const GUI::ECS::Systems::MouseInfo &mouse)
 The function in charge of updating the stored mouse information.
 
void update (const GUI::ECS::Components::TextComponent &copy)
 The function in charge of updating the current text component using another text component instance.
 
GUI::ECS::Components::TextComponentoperator= (const GUI::ECS::Components::TextComponent &copy)
 The overload in charge of allowing a TextComponent update using the '=' sign.
 
- Public Member Functions inherited from GUI::ECS::EntityNode
 EntityNode (const size_t entityId=0)
 
virtual ~EntityNode ()=default
 
virtual size_t getEntityNodeId () const
 

Additional Inherited Members

- Protected Attributes inherited from GUI::ECS::EntityNode
size_t _entityID
 

Detailed Description

A class that represents a text component in the GUI system. It manages font, size, color, and position of text entities in a graphical application.

This class is derived from the EntityNode class and is a part of the ECS system. It includes various constructors for initializing a text component with different configurations.

Constructor & Destructor Documentation

◆ TextComponent() [1/12]

GUI::ECS::Components::TextComponent::TextComponent ( )

Default constructor. Initializes the text component with default values.

Definition at line 16 of file TextComponent.cpp.

◆ TextComponent() [2/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId)

Constructor with an entity ID.

Parameters
entityIdThe ID of the entity this component is associated with.

Definition at line 26 of file TextComponent.cpp.

◆ TextComponent() [3/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const std::string & fontPath )

Constructor with an entity ID and a font path.

Parameters
entityIdThe ID of the entity this component is associated with.
fontPathPath to the font file.

Definition at line 36 of file TextComponent.cpp.

◆ TextComponent() [4/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const std::string & fontPath,
const std::string & text )

Constructor with an entity ID, a font path, and text content.

Parameters
entityIdThe ID of the entity this component is associated with.
fontPathPath to the font file.
textThe text to be displayed.

Definition at line 50 of file TextComponent.cpp.

◆ TextComponent() [5/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const std::string & fontPath,
const std::string & text,
const unsigned int & size )

Constructor with an entity ID, font path, text content, and font size.

Parameters
entityIdThe ID of the entity this component is associated with.
fontPathPath to the font file.
textThe text to be displayed.
sizeThe size of the font.

Definition at line 65 of file TextComponent.cpp.

◆ TextComponent() [6/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const std::string & fontPath,
const std::string & text,
const unsigned int & size,
const GUI::ECS::Systems::Colour & normalColor,
const GUI::ECS::Systems::Colour & hoverColor,
const GUI::ECS::Systems::Colour & clickedColor )

Constructor with detailed parameters.

Parameters
entityIdThe ID of the entity this component is associated with.
fontPathPath to the font file.
textThe text to be displayed.
sizeThe size of the font.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.

Definition at line 81 of file TextComponent.cpp.

◆ TextComponent() [7/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const std::string & fontPath,
const std::string & text,
const unsigned int & size,
const GUI::ECS::Systems::Colour & normalColor,
const GUI::ECS::Systems::Colour & hoverColor,
const GUI::ECS::Systems::Colour & clickedColor,
const std::pair< float, float > & position )

Constructor with full parameter specification.

Parameters
entityIdThe ID of the entity this component is associated with.
fontPathPath to the font file.
textThe text to be displayed.
sizeThe size of the font.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.
positionThe position of the text in 2D space.

Definition at line 100 of file TextComponent.cpp.

◆ TextComponent() [8/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const GUI::ECS::Systems::Font & fontInstance )

Constructor with a font instance.

Parameters
entityIdThe ID of the entity this component is associated with.
fontInstanceAn instance of the font.

Definition at line 120 of file TextComponent.cpp.

◆ TextComponent() [9/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const GUI::ECS::Systems::Font & fontInstance,
const std::string & text )

Constructor with a font instance and text content.

Parameters
entityIdThe ID of the entity this component is associated with.
fontInstanceAn instance of the font.
textThe text to be displayed.

Definition at line 134 of file TextComponent.cpp.

◆ TextComponent() [10/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const GUI::ECS::Systems::Font & fontInstance,
const std::string & text,
const unsigned int & size )

Constructor with a font instance, text content, and font size.

Parameters
entityIdThe ID of the entity this component is associated with.
fontInstanceAn instance of the font.
textThe text to be displayed.
sizeThe size of the font.

Definition at line 149 of file TextComponent.cpp.

◆ TextComponent() [11/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const GUI::ECS::Systems::Font & fontInstance,
const std::string & text,
const unsigned int & size,
const GUI::ECS::Systems::Colour & normalColor,
const GUI::ECS::Systems::Colour & hoverColor,
const GUI::ECS::Systems::Colour & clickedColor )

Constructor with detailed parameters and a font instance.

Parameters
entityIdThe ID of the entity this component is associated with.
fontInstanceAn instance of the font.
textThe text to be displayed.
sizeThe size of the font.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.

Definition at line 165 of file TextComponent.cpp.

◆ TextComponent() [12/12]

GUI::ECS::Components::TextComponent::TextComponent ( const std::uint32_t entityId,
const GUI::ECS::Systems::Font & fontInstance,
const std::string & text,
const unsigned int & size,
const GUI::ECS::Systems::Colour & normalColor,
const GUI::ECS::Systems::Colour & hoverColor,
const GUI::ECS::Systems::Colour & clickedColor,
const std::pair< float, float > & position )

Constructor with detailed parameters and a font instance, including position.

Parameters
entityIdThe ID of the entity this component is associated with.
fontInstanceAn instance of the font.
textThe text to be displayed.
sizeThe size of the font.
normalColorThe normal color of the text.
hoverColorThe color of the text when hovered.
clickedColorThe color of the text when clicked.
positionThe position of the text in 2D space.

Definition at line 184 of file TextComponent.cpp.

◆ ~TextComponent()

GUI::ECS::Components::TextComponent::~TextComponent ( )

Destructor for TextComponent.

Definition at line 205 of file TextComponent.cpp.

Member Function Documentation

◆ getApplication()

const std::string GUI::ECS::Components::TextComponent::getApplication ( ) const

Get the Application context of the component.

Returns
const std::string

Definition at line 419 of file TextComponent.cpp.

◆ getClickedColor()

const GUI::ECS::Systems::Colour GUI::ECS::Components::TextComponent::getClickedColor ( ) const

Get the Clicked Color of the text.

Returns
const GUI::ECS::Systems::Colour

Definition at line 347 of file TextComponent.cpp.

◆ getCollision()

const GUI::ECS::Systems::Collision GUI::ECS::Components::TextComponent::getCollision ( ) const

Function in charge of returning the collision instance of the text component.

Returns
const GUI::ECS::Systems::Collision

Definition at line 409 of file TextComponent.cpp.

◆ getFont()

const GUI::ECS::Systems::Font GUI::ECS::Components::TextComponent::getFont ( ) const

Get the Font object contained in the class.

Returns
const GUI::ECS::Systems::Font

Definition at line 327 of file TextComponent.cpp.

◆ getFontPath()

const std::string GUI::ECS::Components::TextComponent::getFontPath ( ) const

Get the Font Path object.

Returns
const std::string

Definition at line 332 of file TextComponent.cpp.

◆ getHoverColor()

const GUI::ECS::Systems::Colour GUI::ECS::Components::TextComponent::getHoverColor ( ) const

Get the Hover Color of the text.

Returns
const GUI::ECS::Systems::Colour

Definition at line 342 of file TextComponent.cpp.

◆ getInfo()

const std::string GUI::ECS::Components::TextComponent::getInfo ( const unsigned int indent = 0) const

This is a function meant for debugging purposes It will dump the current state of the variables upon call. It will dump them for itself and any of it's underlying classes.

Parameters
indentThe level to which the class should be indented in the dump.
Returns
const std::string The formatted output.

Definition at line 373 of file TextComponent.cpp.

◆ getName()

const std::string GUI::ECS::Components::TextComponent::getName ( ) const

Get the Name text component.

Returns
const std::string

Definition at line 414 of file TextComponent.cpp.

◆ getNormalColor()

const GUI::ECS::Systems::Colour GUI::ECS::Components::TextComponent::getNormalColor ( ) const

Get the Normal Color of the text.

Returns
const GUI::ECS::Systems::Colour

Definition at line 337 of file TextComponent.cpp.

◆ getPosition()

const std::pair< float, float > GUI::ECS::Components::TextComponent::getPosition ( ) const

Get the Position of the text.

Returns
const std::pair<float, float>

Definition at line 362 of file TextComponent.cpp.

◆ getSize()

const std::uint32_t GUI::ECS::Components::TextComponent::getSize ( ) const

Get the Size of the text.

Returns
const std::uint32_t

Definition at line 357 of file TextComponent.cpp.

◆ getText()

const std::string GUI::ECS::Components::TextComponent::getText ( ) const

Get the Text that was set in the class.

Returns
const std::string

Definition at line 352 of file TextComponent.cpp.

◆ getVisible()

const bool GUI::ECS::Components::TextComponent::getVisible ( ) const

Get the Visibility of the text.

Returns
true if visible
false if hidden

Definition at line 367 of file TextComponent.cpp.

◆ isVisible()

const bool GUI::ECS::Components::TextComponent::isVisible ( ) const

Check if the text is set to be rendered or not.

Returns
true The text is set to be rendered
false The text is not set to be rendered

Definition at line 322 of file TextComponent.cpp.

◆ operator=()

GUI::ECS::Components::TextComponent & GUI::ECS::Components::TextComponent::operator= ( const GUI::ECS::Components::TextComponent & copy)

The overload in charge of allowing a TextComponent update using the '=' sign.

Parameters
copyThe TextComponent to copy the data from.
Returns
GUI::ECS::Components::TextComponent& An updated textComponent

Definition at line 638 of file TextComponent.cpp.

◆ render()

std::any GUI::ECS::Components::TextComponent::render ( ) const

Function in charge of rendering the text if it is set to visible, otherwise, does nothing.

Returns
std::optional<std::any>

Definition at line 400 of file TextComponent.cpp.

◆ setApplication()

void GUI::ECS::Components::TextComponent::setApplication ( const std::string & application)

Set the application context of the component.

Parameters
application

Definition at line 308 of file TextComponent.cpp.

◆ setClickedColor()

void GUI::ECS::Components::TextComponent::setClickedColor ( const GUI::ECS::Systems::Colour & color)

Set the Clicked Color of the text object.

Parameters
colorThe clicked colour of the text

Definition at line 258 of file TextComponent.cpp.

◆ setFont()

void GUI::ECS::Components::TextComponent::setFont ( const GUI::ECS::Systems::Font & font)

Set the Font of the text using a loaded Font instance from GUI::ECS::Systems::Font.

Parameters
font

Definition at line 207 of file TextComponent.cpp.

◆ setFontPath()

void GUI::ECS::Components::TextComponent::setFontPath ( const std::string & fontPath,
const std::string & name = "" )

Set the font from a path (this will attempt to load the font internally)

Parameters
fontPathThe font path to be loaded.
nameThe name of the font
Exceptions
CustomExceptions::InvalidFontPathif the font path provided is incorrect

Definition at line 268 of file TextComponent.cpp.

◆ setHoverColor()

void GUI::ECS::Components::TextComponent::setHoverColor ( const GUI::ECS::Systems::Colour & color)

Set the Hover Color of the text object.

Parameters
colorThe hover colour of the text

Definition at line 248 of file TextComponent.cpp.

◆ setName()

void GUI::ECS::Components::TextComponent::setName ( const std::string & name)

Set the Name of the component.

Parameters
name

Definition at line 303 of file TextComponent.cpp.

◆ setNormalColor()

void GUI::ECS::Components::TextComponent::setNormalColor ( const GUI::ECS::Systems::Colour & color)

Set the default colour of the text object.

Parameters
colorThe default colour for the text

Definition at line 238 of file TextComponent.cpp.

◆ setPosition()

void GUI::ECS::Components::TextComponent::setPosition ( const std::pair< float, float > & position)

Set the Position of the text.

Parameters
positionThe position to be set.

Definition at line 287 of file TextComponent.cpp.

◆ setSize()

void GUI::ECS::Components::TextComponent::setSize ( const std::uint32_t & size)

Set the Size of the text.

Parameters
sizeThe size of the text (in pixels)

Definition at line 227 of file TextComponent.cpp.

◆ setText()

void GUI::ECS::Components::TextComponent::setText ( const std::string & text)

Set the Text.

Parameters
textThe text to be displayed

Definition at line 216 of file TextComponent.cpp.

◆ setVisible()

void GUI::ECS::Components::TextComponent::setVisible ( const bool visible)

Set the visibility of the object using a boolean.

  • true : visible
  • false : hidden
Parameters
visibleThe boolean value

Definition at line 298 of file TextComponent.cpp.

◆ toggleVisibility()

void GUI::ECS::Components::TextComponent::toggleVisibility ( )

Toggle the visibility of the object. hidden.

Definition at line 313 of file TextComponent.cpp.

◆ update() [1/2]

void GUI::ECS::Components::TextComponent::update ( const GUI::ECS::Components::TextComponent & copy)

The function in charge of updating the current text component using another text component instance.

Parameters
copyA TextComponent instance

Definition at line 432 of file TextComponent.cpp.

◆ update() [2/2]

void GUI::ECS::Components::TextComponent::update ( const GUI::ECS::Systems::MouseInfo & mouse)

The function in charge of updating the stored mouse information.

Parameters
mouseA mouse instance

Definition at line 424 of file TextComponent.cpp.


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