ShishGL  1.0
A simple modular cross-platform graphics library
Clickable.hpp
Go to the documentation of this file.
1 /*============================================================================*/
2 #ifndef SHISHGL_UI_BUTTON_HPP
3 #define SHISHGL_UI_BUTTON_HPP
4 /*============================================================================*/
5 #include <cstdint>
6 
7 #include "DefaultBehavior.hpp"
8 /*============================================================================*/
9 namespace Sh {
10 
11  class Clickable : public DefaultBehavior {
12  public:
13 
14  explicit Clickable(UIWindow* target);
15 
16  virtual void reactOnPress(MouseButtonEvent& event);
17 
18  virtual void reactOnRelease(MouseButtonEvent& event);
19 
20  bool onMouseButton(MouseButtonEvent& event) override;
21 
22  };
23 
24  /*------------------------------------------------------------------------*/
25 
26  class Holdable : public Clickable {
27  public:
28 
29  explicit Holdable(UIWindow* target);
30 
31  [[nodiscard]]
32  bool isHeld() const;
33 
34  [[nodiscard]]
35  uint8_t numHeld() const;
36 
37  virtual void reactOnHold(TimerEvent& event);
38 
39  bool onTimer(TimerEvent& event) override;
40 
41  bool onMouseButton(MouseButtonEvent& event) override;
42 
43  protected:
44 
45  uint8_t n_held;
46 
47  };
48 
49 }
50 /*============================================================================*/
51 #endif //SHISHGL_UI_BUTTON_HPP
52 /*============================================================================*/
Sh::Clickable::reactOnRelease
virtual void reactOnRelease(MouseButtonEvent &event)
Definition: Clickable.cpp:18
Sh::DefaultBehavior
Definition: DefaultBehavior.hpp:14
Sh::Holdable::isHeld
bool isHeld() const
Definition: Clickable.cpp:57
Sh::Clickable::reactOnPress
virtual void reactOnPress(MouseButtonEvent &event)
Definition: Clickable.cpp:17
Sh::Behavior::target
SomeWindow * target() const
Definition: Behavior.hpp:17
Sh::Holdable::onTimer
bool onTimer(TimerEvent &event) override
Definition: Clickable.cpp:85
Sh::Holdable::reactOnHold
virtual void reactOnHold(TimerEvent &event)
Definition: Clickable.cpp:83
Sh::UIWindow
Definition: UIWindow.hpp:16
Sh::Holdable::numHeld
uint8_t numHeld() const
Definition: Clickable.cpp:61
DefaultBehavior.hpp
Sh::TimerEvent
Definition: TimerEvent.hpp:11
Sh
Definition: CoreApplication.hpp:10
Sh::Clickable::onMouseButton
bool onMouseButton(MouseButtonEvent &event) override
Definition: Clickable.cpp:22
Sh::Holdable::Holdable
Holdable(UIWindow *target)
Definition: Clickable.cpp:51
Sh::Holdable
Definition: Clickable.hpp:26
Sh::Holdable::n_held
uint8_t n_held
Definition: Clickable.hpp:45
Sh::Clickable::Clickable
Clickable(UIWindow *target)
Definition: Clickable.cpp:9
Sh::Clickable
Definition: Clickable.hpp:11
Sh::Holdable::onMouseButton
bool onMouseButton(MouseButtonEvent &event) override
Definition: Clickable.cpp:66
Sh::MouseButtonEvent
Definition: MouseEvent.hpp:38