Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Engine::UI::UIButton Class Reference

A Button associated with a scene. More...

#include <UIButton.hpp>

Inheritance diagram for Engine::UI::UIButton:
Engine::UI::UILabel Engine::UI::UIElement Engine::Node

Public Member Functions

 UIButton (std::string name, std::string text, void(&callback)())
 The default constructor.
 
void Init () override
 
- Public Member Functions inherited from Engine::UI::UILabel
 UILabel (std::string name, std::string text)
 Default Constructor.
 
void Init () override
 Override of UIElement::Init(). Nothing important.
 
void SetText (std::string text)
 Updates the text of the label.
 
- Public Member Functions inherited from Engine::UI::UIElement
 UIElement (std::string name)
 Default Constructor.
 
 ~UIElement () override
 
void AddTheme (const char *theme)
 Sets the theme of the UI element.
 
void SetAnchor (const char *anchor)
 Sets the anchor of the UI element.
 
void SetDimensions (Vec2f dimensions)
 Sets the dimensions of the UI element.
 
void SetOffset (Vec2f offset)
 Sets the offset of the UI element.
 
void OnEnable () override
 Shows the UI element when enabled.
 
void OnDisable () override
 Hides the UI element when disabled.
 
- Public Member Functions inherited from Engine::Node
 Node (std::string name)
 Default constructor.
 
virtual ~Node ()
 Default destructor.
 
size_t AddChild (Node *child)
 Adds a child to the node and assigns itself as the parent of the new node.
 
NodeGetChild (size_t index)
 Returns a reference to the child at the specified index.
 
Success RemoveChild (size_t index)
 Removes the child at the specified index.
 
Success SetEnabled (bool enabled=true)
 Toggles the state of the node.
 
virtual void Draw ()
 Overridable draw method for the node.
 
virtual void Update (float dt)
 Overridable update method for the node.
 

Public Attributes

void(&) OnClick ()
 reference to the function to be called when the button is clicked
 
- Public Attributes inherited from Engine::Node
const char * m_nodeType
 
std::string m_name
 

Additional Inherited Members

- Protected Attributes inherited from Engine::UI::UILabel
std::string m_text
 
- Protected Attributes inherited from Engine::UI::UIElement
const char * m_uiTag
 
const char * m_uiClass
 
- Protected Attributes inherited from Engine::Node
Nodem_parent
 

Detailed Description

A Button associated with a scene.

Allows a function to be called when the button is clicked

See also
UIElement
Author
Roberto Selles

Constructor & Destructor Documentation

◆ UIButton()

Engine::UI::UIButton::UIButton ( std::string  name,
std::string  text,
void(&)()  callback 
)

The default constructor.

Creates a button with the given name and text. The callback is assigned to OnClick

Parameters
nameThe name of the button
textThe text of the button
callbackThe function to be called when the button is clicked

Member Function Documentation

◆ Init()

void Engine::UI::UIButton::Init ( )
overridevirtual

Besides all the functionality of UILabel, UIButton also sets the OnClick callback to the given function

Reimplemented from Engine::Node.


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