aab4791fd7512c84d255cd3637a8abc6fb3c7423
[platform/core/uifw/rive-tizen.git] / submodule / include / component.hpp
1 #ifndef _RIVE_COMPONENT_HPP_
2 #define _RIVE_COMPONENT_HPP_
3 #include "component_dirt.hpp"
4 #include "generated/component_base.hpp"
5
6 #include <vector>
7
8 namespace rive
9 {
10         class ContainerComponent;
11         class Artboard;
12
13         class Component : public ComponentBase
14         {
15                 friend class Artboard;
16
17         private:
18                 ContainerComponent* m_Parent = nullptr;
19                 std::vector<Component*> m_Dependents;
20
21                 unsigned int m_GraphOrder;
22                 Artboard* m_Artboard = nullptr;
23
24         protected:
25                 ComponentDirt m_Dirt = ComponentDirt::Filthy;
26
27         public:
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
32                 {
33                         return m_Dependents;
34                 }
35                 void addDependent(Component* component);
36
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) {}
44
45                 unsigned int graphOrder() const { return m_GraphOrder; }
46                 bool addDirt(ComponentDirt value, bool recurse = false);
47                 inline bool hasDirt(ComponentDirt flag) const
48                 {
49                         return (m_Dirt & flag) == flag;
50                 }
51                 static inline bool hasDirt(ComponentDirt value, ComponentDirt flag)
52                 {
53                         return (value & flag) != ComponentDirt::None;
54                 }
55         };
56 } // namespace rive
57
58 #endif