![]() |
R-Type
2
Doom but in better
|
Manages button functionalities, including appearance, position, and callbacks. More...
#include <ButtonComponent.hpp>
Public Member Functions | |
ButtonComponent (const std::uint32_t entityId=0) | |
Default constructor for ButtonComponent. | |
ButtonComponent (const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem) | |
Constructor initializing with shape and text components. | |
ButtonComponent (const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem, std::function< void()> callback) | |
Constructor initializing with shape, text components, and a callback function. | |
ButtonComponent (const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem, const GUI::ECS::Systems::Collision &collisionItem, const std::uint32_t textSize=40) | |
Constructor initializing with shape, text, collision components, and text size. | |
ButtonComponent (const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem, std::function< void()> callback, const GUI::ECS::Systems::Collision &collisionItem, const std::uint32_t textSize=40) | |
Constructor initializing with all button components. | |
ButtonComponent (const std::uint32_t entityId, const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem) | |
Constructor initializing with shape and text components. | |
ButtonComponent (const std::uint32_t entityId, const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem, std::function< void()> callback) | |
Constructor initializing with shape, text components, and a callback function. | |
ButtonComponent (const std::uint32_t entityId, const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem, const GUI::ECS::Systems::Collision &collisionItem, const std::uint32_t textSize=40) | |
Constructor initializing with shape, text, collision components, and text size. | |
ButtonComponent (const std::uint32_t entityId, const GUI::ECS::Components::ShapeComponent &shapeItem, const GUI::ECS::Components::TextComponent &textItem, std::function< void()> callback, const GUI::ECS::Systems::Collision &collisionItem, const std::uint32_t textSize=40) | |
Constructor initializing with all button components. | |
~ButtonComponent () | |
Destructor for ButtonComponent. | |
void | setHoverColor (const GUI::ECS::Systems::Colour &hoverColor) |
Set the Hover Color of the button for the child components. | |
void | setNormalColor (const GUI::ECS::Systems::Colour &normalColor) |
Set the Normal Color of the button for the child objects. | |
void | setClickedColor (const GUI::ECS::Systems::Colour &clickedColor) |
Set the Clicked Color of the button for the child objects. | |
void | setTextHoverColor (const GUI::ECS::Systems::Colour &hoverColor) |
Set the Text Hover Color. | |
void | setTextNormalColor (const GUI::ECS::Systems::Colour &normalColor) |
Set the Text Normal Color. | |
void | setTextClickedColor (const GUI::ECS::Systems::Colour &clickedColor) |
Set the Text Clicked Color. | |
void | setTextString (const std::string &text) |
Set the text contained in the Text component. | |
void | setPosition (const std::pair< float, float > &position) |
Set the Position of all objects contained in the button. | |
void | setDimension (const std::pair< float, float > &dimension, const std::uint32_t textSize=40) |
Set the Dimension of all objects contained in the button. | |
void | setTextPosition (const std::pair< float, float > &position) |
Set the Text Position. | |
void | setTextSize (const std::uint32_t textSize) |
Set the Text Size. | |
void | setShapePosition (const std::pair< float, float > &position) |
Set the Shape Position. | |
void | setShapeDimension (const std::pair< float, float > &dimension) |
Set the Shape Dimensions. | |
void | setCollision (const GUI::ECS::Systems::Collision &collision, const std::uint32_t textSize=40) |
Set the Collision for all objects of the Button class. | |
void | setCallback (std::function< void()> callback, const std::string &callbackName="Callback Function") |
Set the Callback function for the the button is clicked. | |
void | setVisible (const bool visible) |
Set the visibility of the element. | |
void | setName (const std::string &name) |
Set the Name of the button. | |
void | setApplication (const std::string &application) |
Set the Application context of the button. | |
std::function< void()> | callback () |
Get the callback function. | |
const bool | isVisible () const |
Get the information about if the element is visible. | |
void | toggleVisibility () |
Toggle the visibility of the component. | |
const GUI::ECS::Systems::Colour | getClickedColor () const |
Get the Clicked Color. | |
const GUI::ECS::Systems::Colour | getNormalColor () const |
Get the Normal Color. | |
const GUI::ECS::Systems::Colour | getHoverColor () const |
Get the Hover Color. | |
const GUI::ECS::Systems::Colour | getTextClickedColor () const |
Get the Text Clicked Color. | |
const GUI::ECS::Systems::Colour | getTextNormalColor () const |
Get the Text Normal Color. | |
const GUI::ECS::Systems::Colour | getTextHoverColor () const |
Get the Text Hover Color. | |
const std::uint32_t | getTextSize () const |
Get the Text Size. | |
const std::pair< float, float > | getPosition () const |
Get the Position of the button. | |
const std::pair< float, float > | getDimension () const |
Get the Dimensions of the button. | |
const std::pair< float, float > | getTextPosition () const |
Get the Text Position. | |
const std::pair< float, float > | getShapePosition () const |
Get the Shape Position. | |
const std::pair< float, float > | getShapeDimension () const |
Get the Shape's Dimensions. | |
const GUI::ECS::Systems::Collision | getCollision () const |
Get the button collision object. | |
const std::string | getCallbackName () const |
Get the Callback Name of the callback function. | |
const std::function< void()> | getCallback () const |
Get the Callback object. | |
const bool | getVisible () const |
Get the information about if the Button is visible or hidden. | |
const std::string | getName () const |
Get the Name button component. | |
const std::string | getApplication () const |
Get the Application of the button component. | |
const GUI::ECS::Components::TextComponent | getTextComponent () const |
Get the Text Component. | |
const GUI::ECS::Components::ShapeComponent & | getShapeComponent () const |
Get the Shape Component. | |
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. | |
void | update (const GUI::ECS::Systems::MouseInfo &mouse) |
Update the mouse position information for all the entities in the button. | |
void | update (const GUI::ECS::Components::TextComponent ©) |
Update the textComponent instance located in the button. | |
void | update (const GUI::ECS::Components::ShapeComponent ©) |
Update the ShapeComponent instance located in the button. | |
void | update (const GUI::ECS::Components::ButtonComponent ©) |
Update the Button component using another Button Component. | |
std::unordered_map< std::type_index, std::any > | render () const |
Get the components that need rendering. | |
ButtonComponent & | operator= (const GUI::ECS::Components::ButtonComponent ©) |
A operator to allow seemless updating/asining from one button class to another. | |
![]() | |
EntityNode (const size_t entityId=0) | |
virtual | ~EntityNode ()=default |
virtual size_t | getEntityNodeId () const |
Additional Inherited Members | |
![]() | |
size_t | _entityID |
Manages button functionalities, including appearance, position, and callbacks.
Definition at line 41 of file ButtonComponent.hpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const std::uint32_t | entityId = 0 | ) |
Default constructor for ButtonComponent.
entityId | The unique ID of the entity. Default is 0. |
Definition at line 16 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const GUI::ECS::Components::ShapeComponent & | shapeItem, |
const GUI::ECS::Components::TextComponent & | textItem ) |
Constructor initializing with shape and text components.
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
Definition at line 23 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const GUI::ECS::Components::ShapeComponent & | shapeItem, |
const GUI::ECS::Components::TextComponent & | textItem, | ||
std::function< void()> | callback ) |
Constructor initializing with shape, text components, and a callback function.
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
callback | The function to be called when the button is triggered. |
Definition at line 32 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const GUI::ECS::Components::ShapeComponent & | shapeItem, |
const GUI::ECS::Components::TextComponent & | textItem, | ||
const GUI::ECS::Systems::Collision & | collisionItem, | ||
const std::uint32_t | textSize = 40 ) |
Constructor initializing with shape, text, collision components, and text size.
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
collisionItem | The collision component of the button. |
textSize | The size of the text. Default is 40. |
Definition at line 41 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const GUI::ECS::Components::ShapeComponent & | shapeItem, |
const GUI::ECS::Components::TextComponent & | textItem, | ||
std::function< void()> | callback, | ||
const GUI::ECS::Systems::Collision & | collisionItem, | ||
const std::uint32_t | textSize = 40 ) |
Constructor initializing with all button components.
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
callback | The function to be called when the button is triggered. |
collisionItem | The collision component of the button. |
textSize | The size of the text. Default is 40. |
Definition at line 49 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Components::ShapeComponent & | shapeItem, | ||
const GUI::ECS::Components::TextComponent & | textItem ) |
Constructor initializing with shape and text components.
entityId | The entity identification for the class |
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
Definition at line 58 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Components::ShapeComponent & | shapeItem, | ||
const GUI::ECS::Components::TextComponent & | textItem, | ||
std::function< void()> | callback ) |
Constructor initializing with shape, text components, and a callback function.
entityId | The entity identification for the class |
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
callback | The function to be called when the button is triggered. |
Definition at line 67 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Components::ShapeComponent & | shapeItem, | ||
const GUI::ECS::Components::TextComponent & | textItem, | ||
const GUI::ECS::Systems::Collision & | collisionItem, | ||
const std::uint32_t | textSize = 40 ) |
Constructor initializing with shape, text, collision components, and text size.
entityId | The entity identification for the class |
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
collisionItem | The collision component of the button. |
textSize | The size of the text. Default is 40. |
Definition at line 76 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::ButtonComponent | ( | const std::uint32_t | entityId, |
const GUI::ECS::Components::ShapeComponent & | shapeItem, | ||
const GUI::ECS::Components::TextComponent & | textItem, | ||
std::function< void()> | callback, | ||
const GUI::ECS::Systems::Collision & | collisionItem, | ||
const std::uint32_t | textSize = 40 ) |
Constructor initializing with all button components.
entityId | The entity identification for the class |
shapeItem | The shape component of the button. |
textItem | The text component of the button. |
callback | The function to be called when the button is triggered. |
collisionItem | The collision component of the button. |
textSize | The size of the text. Default is 40. |
Definition at line 84 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent::~ButtonComponent | ( | ) |
Destructor for ButtonComponent.
Definition at line 92 of file ButtonComponent.cpp.
std::function< void()> GUI::ECS::Components::ButtonComponent::callback | ( | ) |
Get the callback function.
Definition at line 198 of file ButtonComponent.cpp.
const std::string GUI::ECS::Components::ButtonComponent::getApplication | ( | ) | const |
Get the Application of the button component.
Definition at line 305 of file ButtonComponent.cpp.
const std::function< void()> GUI::ECS::Components::ButtonComponent::getCallback | ( | ) | const |
Get the Callback object.
Definition at line 290 of file ButtonComponent.cpp.
const std::string GUI::ECS::Components::ButtonComponent::getCallbackName | ( | ) | const |
Get the Callback Name of the callback function.
Definition at line 285 of file ButtonComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::ButtonComponent::getClickedColor | ( | ) | const |
Get the Clicked Color.
Definition at line 221 of file ButtonComponent.cpp.
const GUI::ECS::Systems::Collision GUI::ECS::Components::ButtonComponent::getCollision | ( | ) | const |
Get the button collision object.
Definition at line 280 of file ButtonComponent.cpp.
const std::pair< float, float > GUI::ECS::Components::ButtonComponent::getDimension | ( | ) | const |
Get the Dimensions of the button.
Definition at line 260 of file ButtonComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::ButtonComponent::getHoverColor | ( | ) | const |
Get the Hover Color.
Definition at line 231 of file ButtonComponent.cpp.
const std::string GUI::ECS::Components::ButtonComponent::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.
indent | The level to which the class should be indented in the dump. |
Definition at line 321 of file ButtonComponent.cpp.
const std::string GUI::ECS::Components::ButtonComponent::getName | ( | ) | const |
Get the Name button component.
Definition at line 300 of file ButtonComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::ButtonComponent::getNormalColor | ( | ) | const |
Get the Normal Color.
Definition at line 226 of file ButtonComponent.cpp.
const std::pair< float, float > GUI::ECS::Components::ButtonComponent::getPosition | ( | ) | const |
Get the Position of the button.
Definition at line 255 of file ButtonComponent.cpp.
const GUI::ECS::Components::ShapeComponent & GUI::ECS::Components::ButtonComponent::getShapeComponent | ( | ) | const |
Get the Shape Component.
Definition at line 315 of file ButtonComponent.cpp.
const std::pair< float, float > GUI::ECS::Components::ButtonComponent::getShapeDimension | ( | ) | const |
Get the Shape's Dimensions.
Definition at line 275 of file ButtonComponent.cpp.
const std::pair< float, float > GUI::ECS::Components::ButtonComponent::getShapePosition | ( | ) | const |
Get the Shape Position.
Definition at line 270 of file ButtonComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::ButtonComponent::getTextClickedColor | ( | ) | const |
Get the Text Clicked Color.
Definition at line 235 of file ButtonComponent.cpp.
const GUI::ECS::Components::TextComponent GUI::ECS::Components::ButtonComponent::getTextComponent | ( | ) | const |
Get the Text Component.
Definition at line 310 of file ButtonComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::ButtonComponent::getTextHoverColor | ( | ) | const |
Get the Text Hover Color.
Definition at line 245 of file ButtonComponent.cpp.
const GUI::ECS::Systems::Colour GUI::ECS::Components::ButtonComponent::getTextNormalColor | ( | ) | const |
Get the Text Normal Color.
Definition at line 240 of file ButtonComponent.cpp.
const std::pair< float, float > GUI::ECS::Components::ButtonComponent::getTextPosition | ( | ) | const |
Get the Text Position.
Definition at line 265 of file ButtonComponent.cpp.
const std::uint32_t GUI::ECS::Components::ButtonComponent::getTextSize | ( | ) | const |
const bool GUI::ECS::Components::ButtonComponent::getVisible | ( | ) | const |
Get the information about if the Button is visible or hidden.
isVisible
function. Definition at line 295 of file ButtonComponent.cpp.
const bool GUI::ECS::Components::ButtonComponent::isVisible | ( | ) | const |
Get the information about if the element is visible.
Definition at line 203 of file ButtonComponent.cpp.
GUI::ECS::Components::ButtonComponent & GUI::ECS::Components::ButtonComponent::operator= | ( | const GUI::ECS::Components::ButtonComponent & | copy | ) |
A operator to allow seemless updating/asining from one button class to another.
copy |
Definition at line 380 of file ButtonComponent.cpp.
std::unordered_map< std::type_index, std::any > GUI::ECS::Components::ButtonComponent::render | ( | ) | const |
Get the components that need rendering.
draw
function, you do not need to call it. Definition at line 372 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setApplication | ( | const std::string & | application | ) |
Set the Application context of the button.
application | A string instance representing the context of the application. |
Definition at line 193 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setCallback | ( | std::function< void()> | callback, |
const std::string & | callbackName = "Callback Function" ) |
Set the Callback function for the the button is clicked.
callback | The function |
callbackName | The name of the function (for debugging purposes) |
Definition at line 175 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setClickedColor | ( | const GUI::ECS::Systems::Colour & | clickedColor | ) |
Set the Clicked Color of the button for the child objects.
clickedColor |
Definition at line 104 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setCollision | ( | const GUI::ECS::Systems::Collision & | collision, |
const std::uint32_t | textSize = 40 ) |
Set the Collision for all objects of the Button class.
collision | The collision information |
textSize | The size of the text |
Definition at line 166 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setDimension | ( | const std::pair< float, float > & | dimension, |
const std::uint32_t | textSize = 40 ) |
Set the Dimension of all objects contained in the button.
dimension | The dimension of the button |
textSize | The size of the text |
Definition at line 135 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setHoverColor | ( | const GUI::ECS::Systems::Colour & | hoverColor | ) |
Set the Hover Color of the button for the child components.
hoverColor |
Definition at line 94 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setName | ( | const std::string & | name | ) |
Set the Name of the button.
name | A string instance representing the name of the button. |
Definition at line 188 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setNormalColor | ( | const GUI::ECS::Systems::Colour & | normalColor | ) |
Set the Normal Color of the button for the child objects.
normalColor |
Definition at line 99 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setPosition | ( | const std::pair< float, float > & | position | ) |
Set the Position of all objects contained in the button.
position |
Definition at line 128 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setShapeDimension | ( | const std::pair< float, float > & | dimension | ) |
void GUI::ECS::Components::ButtonComponent::setShapePosition | ( | const std::pair< float, float > & | position | ) |
void GUI::ECS::Components::ButtonComponent::setTextClickedColor | ( | const GUI::ECS::Systems::Colour & | clickedColor | ) |
Set the Text Clicked Color.
clickedColor |
Definition at line 118 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setTextHoverColor | ( | const GUI::ECS::Systems::Colour & | hoverColor | ) |
void GUI::ECS::Components::ButtonComponent::setTextNormalColor | ( | const GUI::ECS::Systems::Colour & | normalColor | ) |
Set the Text Normal Color.
normalColor |
Definition at line 113 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setTextPosition | ( | const std::pair< float, float > & | position | ) |
void GUI::ECS::Components::ButtonComponent::setTextSize | ( | const std::uint32_t | textSize | ) |
void GUI::ECS::Components::ButtonComponent::setTextString | ( | const std::string & | text | ) |
Set the text contained in the Text component.
text |
Definition at line 123 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::setVisible | ( | const bool | visible | ) |
Set the visibility of the element.
visible | A boolean instance informing if (true) to be visible, (false) hidden. |
Definition at line 181 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::toggleVisibility | ( | ) |
Toggle the visibility of the component.
Definition at line 208 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::update | ( | const GUI::ECS::Components::ButtonComponent & | copy | ) |
Update the Button component using another Button Component.
copy |
Definition at line 361 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::update | ( | const GUI::ECS::Components::ShapeComponent & | copy | ) |
Update the ShapeComponent instance located in the button.
copy |
Definition at line 356 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::update | ( | const GUI::ECS::Components::TextComponent & | copy | ) |
Update the textComponent instance located in the button.
copy |
Definition at line 351 of file ButtonComponent.cpp.
void GUI::ECS::Components::ButtonComponent::update | ( | const GUI::ECS::Systems::MouseInfo & | mouse | ) |
Update the mouse position information for all the entities in the button.
mouse |
Definition at line 341 of file ButtonComponent.cpp.