Guillaume 1.0.0
Guillaume.
Loading...
Searching...
No Matches
Component Class Reference

Base class for all UI components. More...

#include <component.hpp>

Inheritance diagram for Component:
Collaboration diagram for Component:

Public Member Functions

 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.
 
virtual std::shared_ptr< Componentrender (void)
 Renders the component.
 
virtual void onEvent (const Event &event)
 Handles events.
 
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.
 

Protected Member Functions

void setParent (const std::shared_ptr< Component > &parent)
 Set the Parent object.
 

Protected Attributes

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

Base class for all UI components.

Manages local state and properties, defines rendering and event handling.

Constructor & Destructor Documentation

◆ Component()

Component::Component ( const Properties properties)
inline

Constructs a Component object with properties.

Parameters
propertiesThe properties for the component

Member Function Documentation

◆ addChild()

virtual void Component::addChild ( const std::shared_ptr< Component > &  child)
inlinevirtual

Add a child component.

Parameters
childA shared pointer to the child component

◆ addPrimitive()

virtual void Component::addPrimitive ( const std::shared_ptr< Primitive > &  primitive)
inlinevirtual

Add a primitive for rendering.

Parameters
primitiveA shared pointer to the primitive

◆ getChildren()

const std::vector< std::shared_ptr< Component > > & Component::getChildren ( void  ) const
inline

Gets the component's children.

Returns
const std::vector<std::shared_ptr<Component>>& Reference to the children vector

◆ getID()

ComponentID Component::getID ( void  ) const
inline

Get the ID object.

Returns
ComponentID

◆ getParent()

std::shared_ptr< Component > Component::getParent ( void  ) const
inline

Gets the component's parent.

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

◆ getPrimitives()

const std::vector< std::shared_ptr< Primitive > > & Component::getPrimitives ( void  ) const
inline

Gets the component's primitives.

Returns
const std::vector<std::shared_ptr<Primitive>>& Reference to the primitives vector

◆ getProperties()

const Properties & Component::getProperties ( void  ) const
inline

Gets the component's properties.

Returns
const Properties& Reference to the component's properties

◆ getState()

State & Component::getState ( void  )
inline

Gets the component's state.

Returns
State& Reference to the component's state

◆ onEvent()

virtual void Component::onEvent ( const Event event)
inlinevirtual

Handles events.

This method should be overridden by derived classes to implement their specific event handling logic.

Parameters
eventThe event to handle

Reimplemented in Button, Container, and Label.

◆ render()

virtual std::shared_ptr< Component > Component::render ( void  )
inlinevirtual

Renders the component.

This method should be overridden by derived classes to implement their specific rendering logic.

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

Reimplemented in Button, Container, and Label.

◆ setParent()

void Component::setParent ( const std::shared_ptr< Component > &  parent)
inlineprotected

Set the Parent object.

Parameters
parentA shared pointer to the parent component

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