UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
node.h
Go to the documentation of this file.
1 #ifndef UGDK_GRAPHIC_NODE_H_
2 #define UGDK_GRAPHIC_NODE_H_
3 
4 #include <ugdk/graphic.h>
5 #include <ugdk/math/geometry.h>
7 #include <ugdk/ui.h>
8 
9 #include <vector>
10 #include <memory>
11 
12 namespace ugdk {
13 namespace ui {
14 
16 class Node {
17  public:
18  explicit Node();
19  Node(std::unique_ptr<Drawable>&& _drawable);
20  ~Node();
21 
23  void Render(graphic::Canvas&) const;
24 
25  void set_drawable(std::unique_ptr<Drawable>&& _drawable);
26  void set_active(const bool _active) { active_ = _active; }
27  void set_ignores_effect(const bool _on) { ignores_effect_ = _on; }
28  void set_zindex(const double zindex);
29 
30  Node* parent() { return parent_; }
31  math::Geometry& geometry() { return geometry_; }
32  const math::Geometry& geometry() const { return geometry_; }
33  structure::VisualEffect& effect() { return effect_; }
34  const structure::VisualEffect& effect() const { return effect_; }
35  Drawable* drawable() { return drawable_.get(); }
36  const Drawable* drawable() const { return drawable_.get(); }
37  bool active() const { return active_; }
38  bool ignores_effect() const { return ignores_effect_; }
39  double zindex() const { return zindex_; }
40 
41  void AddChild(const std::shared_ptr<Node>& new_child);
42  void RemoveChild(Node *child);
43 
44  static bool CompareByZIndex(const std::shared_ptr<Node>& a, const std::shared_ptr<Node>& b);
45  void SortChildren();
46 
47  private:
48  math::Geometry geometry_;
50  std::unique_ptr<Drawable> drawable_;
51  bool active_;
52  bool ignores_effect_;
53  double zindex_;
54 
55  std::vector<std::shared_ptr<Node>> childs_;
56  Node* parent_;
57  bool must_sort_;
58 };
59 
60 } // namespace ui
61 } // namespace ugdk
62 
63 #endif // UGDK_GRAPHIC_NODE_H_
Definition: canvas.h:28
double zindex() const
Definition: node.h:39
const math::Geometry & geometry() const
Definition: node.h:32
Definition: animation.h:11
Definition: visualeffect.h:9
structure::VisualEffect & effect()
Definition: node.h:33
Drawable * drawable()
Definition: node.h:35
void RemoveChild(Node *child)
const Drawable * drawable() const
Definition: node.h:36
const structure::VisualEffect & effect() const
Definition: node.h:34
void set_active(const bool _active)
Definition: node.h:26
Definition: drawable.h:13
void Render(graphic::Canvas &) const
Pushes the modifier to the Manager, renders.
bool active() const
Definition: node.h:37
void AddChild(const std::shared_ptr< Node > &new_child)
void set_drawable(std::unique_ptr< Drawable > &&_drawable)
void SortChildren()
bool ignores_effect() const
Definition: node.h:38
void set_zindex(const double zindex)
Definition: geometry.h:15
static bool CompareByZIndex(const std::shared_ptr< Node > &a, const std::shared_ptr< Node > &b)
math::Geometry & geometry()
Definition: node.h:31
Definition: node.h:16
void set_ignores_effect(const bool _on)
Definition: node.h:27
Node * parent()
Definition: node.h:30