TermOx
cursor.hpp
1 #ifndef TERMOX_WIDGET_CURSOR_DATA_HPP
2 #define TERMOX_WIDGET_CURSOR_DATA_HPP
3 #include <signals_light/signal.hpp>
4 
5 #include <termox/widget/point.hpp>
6 
7 namespace ox {
8 
10 class Cursor {
11  public:
13  sl::Signal<void(Point)> moved;
14 
15  public:
17  [[nodiscard]] auto position() const -> Point;
18 
20  [[nodiscard]] auto is_enabled() const -> bool;
21 
23  void enable(bool enable = true);
24 
26  void disable(bool disable = true);
27 
29  void toggle();
30 
32  void set_position(Point p);
33 
34  private:
35  Point position_ = {0, 0};
36  bool enabled_ = false;
37 };
38 
39 } // namespace ox
40 #endif // TERMOX_WIDGET_CURSOR_DATA_HPP
Holds and provides access to all data relevant to a Widget's cursor.
Definition: cursor.hpp:10
auto position() const -> Point
Get the local position of the cursor.
Definition: cursor.cpp:7
void disable(bool disable=true)
Disable the cursor(do not show on screen).
Definition: cursor.cpp:13
void set_position(Point p)
Set the local position of the cursor.
Definition: cursor.cpp:17
auto is_enabled() const -> bool
Query if the cursor is enabled.
Definition: cursor.cpp:9
void toggle()
Enable the cursor if disabled, or disable it if enabled.
Definition: cursor.cpp:15
sl::Signal< void(Point)> moved
Signal called when the cursor is moved, passing along the new position.
Definition: cursor.hpp:13
void enable(bool enable=true)
Enable the cursor(show on screen).
Definition: cursor.cpp:11