1 #ifndef _RIVE_COMPONENT_HPP_
2 #define _RIVE_COMPONENT_HPP_
3 #include "component_dirt.hpp"
4 #include "generated/component_base.hpp"
10 class ContainerComponent;
13 class Component : public ComponentBase
15 friend class Artboard;
18 ContainerComponent* m_Parent = nullptr;
19 std::vector<Component*> m_Dependents;
21 unsigned int m_GraphOrder;
22 Artboard* m_Artboard = nullptr;
25 ComponentDirt m_Dirt = ComponentDirt::Filthy;
28 inline Artboard* artboard() const { return m_Artboard; }
29 StatusCode onAddedDirty(CoreContext* context) override;
30 inline ContainerComponent* parent() const { return m_Parent; }
31 const std::vector<Component*>& dependents() const
35 void addDependent(Component* component);
37 // TODO: re-evaluate when more of the lib is complete...
38 // These could be pure virtual but we define them empty here to avoid
39 // having to implement them in a bunch of concrete classes that
40 // currently don't use this logic.
41 virtual void buildDependencies() {}
42 virtual void onDirty(ComponentDirt dirt) {}
43 virtual void update(ComponentDirt value) {}
45 unsigned int graphOrder() const { return m_GraphOrder; }
46 bool addDirt(ComponentDirt value, bool recurse = false);
47 inline bool hasDirt(ComponentDirt flag) const
49 return (m_Dirt & flag) == flag;
51 static inline bool hasDirt(ComponentDirt value, ComponentDirt flag)
53 return (value & flag) != ComponentDirt::None;