26#include "primitive.hpp"
27#include "properties.hpp"
38class Component :
public std::enable_shared_from_this<Component> {
40 typedef unsigned int ComponentID;
44 ComponentID generateID(
void)
const {
45 static ComponentID currentID = 0;
53 std::vector<std::shared_ptr<Component>>
55 std::vector<std::shared_ptr<Primitive>>
98 ComponentID
getID(
void)
const {
return _id; }
105 virtual void addChild(
const std::shared_ptr<Component> &child) {
106 child->setParent(shared_from_this());
115 virtual void addPrimitive(
const std::shared_ptr<Primitive> &primitive) {
127 virtual std::shared_ptr<Component>
render(
void) {
129 return shared_from_this();
165 const std::vector<std::shared_ptr<Component>> &
getChildren(
void)
const {
Base class for all UI components.
Properties _properties
The component's properties.
std::vector< std::shared_ptr< Primitive > > _primitives
Vector of primitives for rendering.
std::shared_ptr< Component > _parent
Pointer to the parent component.
virtual void addChild(const std::shared_ptr< Component > &child)
Add a child component.
State _state
The component's state.
ComponentID getID(void) const
Get the ID object.
virtual void addPrimitive(const std::shared_ptr< Primitive > &primitive)
Add a primitive for rendering.
virtual void onEvent(const Event &event)
Handles events.
void setParent(const std::shared_ptr< Component > &parent)
Set the Parent object.
const std::vector< std::shared_ptr< Primitive > > & getPrimitives(void) const
Gets the component's primitives.
std::shared_ptr< Component > getParent(void) const
Gets the component's parent.
const Properties & getProperties(void) const
Gets the component's properties.
virtual ~Component(void)=default
Destroy the Component object.
State & getState(void)
Gets the component's state.
Component(const Properties &properties)
Constructs a Component object with properties.
const std::vector< std::shared_ptr< Component > > & getChildren(void) const
Gets the component's children.
virtual std::shared_ptr< Component > render(void)
Renders the component.
Component(void)
Constructs a Component object.
std::vector< std::shared_ptr< Component > > _children
Vector of child components.
Represents a UI event with type, target, and optional data.
Manages immutable component properties.
Manages dynamic component state with type-safe storage.