UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
button.h
Go to the documentation of this file.
1 #ifndef PYRAMIDWORKS_UI_BUTTON_H_
2 #define PYRAMIDWORKS_UI_BUTTON_H_
3 
4 #include <ugdk/ui/uielement.h>
5 #include <ugdk/math/vector2D.h>
6 
7 #include <functional>
8 #include <memory>
9 
10 namespace ugdk {
11 namespace ui {
12 
13 typedef std::function<void (const Button *)> ButtonCallback;
14 class Button : public UIElement {
15  public:
16  Button(const math::Vector2D& top_left, std::unique_ptr<Drawable>&& drawable, const ButtonCallback& function);
17  ~Button();
18 
19  void Interact() const { if(function_) function_(this); }
21 
22  private:
23  ButtonCallback function_;
24  math::Vector2D top_left_;
25 };
26 
27 } // namespace ui
28 } // namespace ugdk
29 
30 #endif // PYRAMIDWORKS_UI_BUTTON_H_
Definition: vector2D.h:18
std::function< void(const Button *)> ButtonCallback
Definition: button.h:13
Definition: button.h:14
Button(const math::Vector2D &top_left, std::unique_ptr< Drawable > &&drawable, const ButtonCallback &function)
Definition: animation.h:11
void Interact() const
Definition: button.h:19
structure::Box< 2 > GetBoundingBox() const
Definition: uielement.h:12