guillaume 1.0.0
Guillaume is a component-based UI framework library built around a primitive rendering system. It's designed for building user interfaces across XR platforms and traditional platforms with custom rendering backends and input handling. The framework is lightweight, flexible, and easy to integrate into existing projects.
Loading...
Searching...
No Matches
Button Class Reference

Interactive button component. More...

#include <button.hpp>

Inheritance diagram for Button:
Collaboration diagram for Button:

Public Member Functions

 Button (const std::string &label)
 Constructs a Button object.
 
 Button (const std::string &label, const Properties &properties)
 Constructs a Button object with properties.
 
 ~Button (void) override=default
 Destroys the Button object.
 
void setOnClick (std::function< void()> callback)
 Sets the onClick callback function.
 
const std::string & getLabel (void) const
 Gets the button's label.
 
void setLabel (const std::string &label)
 Sets the button's label.
 
std::shared_ptr< Componentrender (void) override
 Renders the button.
 
void onEvent (const Event &event) override
 Handles events for the button.
 
- Public Member Functions inherited from Component
 Component (void)
 Constructs a Component object.
 
 Component (const Properties &properties)
 Constructs a Component object with properties.
 
virtual ~Component (void)=default
 Destroy the Component object.
 
ComponentID getID (void) const
 Get the ID object.
 
virtual void addChild (const std::shared_ptr< Component > &child)
 Add a child component.
 
virtual void addPrimitive (const std::shared_ptr< Primitive > &primitive)
 Add a primitive for rendering.
 
StategetState (void)
 Gets the component's state.
 
const PropertiesgetProperties (void) const
 Gets the component's properties.
 
const std::vector< std::shared_ptr< Component > > & getChildren (void) const
 Gets the component's children.
 
std::shared_ptr< ComponentgetParent (void) const
 Gets the component's parent.
 
const std::vector< std::shared_ptr< Primitive > > & getPrimitives (void) const
 Gets the component's primitives.
 

Additional Inherited Members

- Protected Member Functions inherited from Component
void setParent (const std::shared_ptr< Component > &parent)
 Set the Parent object.
 
- Protected Attributes inherited from Component
State _state
 The component's state.
 
Properties _properties
 The component's properties.
 
std::shared_ptr< Component_parent
 Pointer to the parent component.
 
std::vector< std::shared_ptr< Component > > _children
 Vector of child components.
 
std::vector< std::shared_ptr< Primitive > > _primitives
 Vector of primitives for rendering.
 

Detailed Description

Interactive button component.

The Button class represents a clickable button with a label and onClick handler.

Definition at line 38 of file button.hpp.

Constructor & Destructor Documentation

◆ Button() [1/2]

Button::Button ( const std::string &  label)
inline

Constructs a Button object.

Parameters
labelThe button's label text

Definition at line 49 of file button.hpp.

Here is the call graph for this function:

◆ Button() [2/2]

Button::Button ( const std::string &  label,
const Properties properties 
)
inline

Constructs a Button object with properties.

Parameters
labelThe button's label text
propertiesThe properties for the button

Definition at line 61 of file button.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ getLabel()

const std::string & Button::getLabel ( void  ) const
inline

Gets the button's label.

Returns
const std::string& The button's label text

Definition at line 85 of file button.hpp.

◆ onEvent()

void Button::onEvent ( const Event event)
inlineoverridevirtual

Handles events for the button.

If the event is a click event, the onClick callback is called.

Parameters
eventThe event to handle

Reimplemented from Component.

Definition at line 130 of file button.hpp.

Here is the call graph for this function:

◆ render()

std::shared_ptr< Component > Button::render ( void  )
inlineoverridevirtual

Renders the button.

Returns
std::shared_ptr<Component> Pointer to the rendered component

Reimplemented from Component.

Definition at line 102 of file button.hpp.

Here is the call graph for this function:

◆ setLabel()

void Button::setLabel ( const std::string &  label)
inline

Sets the button's label.

Parameters
labelThe new label text

Definition at line 92 of file button.hpp.

Here is the call graph for this function:

◆ setOnClick()

void Button::setOnClick ( std::function< void()>  callback)
inline

Sets the onClick callback function.

Parameters
callbackThe callback function to be called when the button is clicked

Definition at line 78 of file button.hpp.


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