BuGUI
BUtton Grid User Interface
Loading...
Searching...
No Matches
base_controller.hpp
1#pragma once
2#include <bugui/widgets/base_container_widget.hpp>
3#include <bugui/hardware/hardware_factory.hpp>
4
5namespace bugui
6{
9struct base_controller : base_container_widget
10{
14
17 double get_horizontal_scale() const noexcept
18 { return horizontal_scale; }
19
22 double get_vertical_scale() const noexcept
23 { return vertical_scale; }
24
25 bool handle_Delete() override final { return false; };
26
27#define set_button(L) \
28public: \
29 void virtual set_##L(uint8_t&& r = 0 \
30 , uint8_t&& g = 0 \
31 , uint8_t&& b = 0 \
32 , uint8_t&& a = 255); \
33 \
34 bool L##_held() { return L; } \
35 void set_##L##_held(button_presser& p) { L = p.get_bool(); } \
36 \
37private: \
38 bool L{};
39
40// FIXME : find more succint macro
41#define CALL_MACRO(r, data, elem) set_button(elem)
42 FOR_EACH_LABEL(CALL_MACRO)
43#undef CALL_MACRO
44#undef set_button
45
46protected:
47 explicit base_controller(std::unique_ptr<base_hardware>&& hardware);
48
49 std::unique_ptr<base_hardware> hdw;
50 painter paint;
51
54 void increment_horizontal_scale(double scale_inc)
55 { horizontal_scale += scale_inc; }
56
59 void increment_vertical_scale(double scale_inc)
60 { vertical_scale += scale_inc; }
61
64 void set_horizontal_scale(double scale);
65
68 void set_vetical_scale(double scale);
69
70private:
71 double horizontal_scale{1.};
72 double vertical_scale{1.};
73 button_painter btn_pnt;
74
75 void recursive_ofset(base_widget* widget);
76};
77
78} // namespace bugui
void increment_vertical_scale(double scale_inc)
Increments the vertical scale value.
Definition base_controller.hpp:59
double get_horizontal_scale() const noexcept
Retrieves the horizontal scale value.
Definition base_controller.hpp:17
void local_repaint(base_widget *widget)
Triggers the painting of the widget pointed to by the parameter.
void set_vetical_scale(double scale)
Set the vertical scale value.
void increment_horizontal_scale(double scale_inc)
Increments the horizontal scale value.
Definition base_controller.hpp:54
void set_horizontal_scale(double scale)
Set the horizontal scale value.
double get_vertical_scale() const noexcept
Retrieves the vertical scale value.
Definition base_controller.hpp:22
Provides the minimum required 2D widget functionalities.
Definition base_widget.hpp:12
To be inherited for creating custom wigets. Derived classes must be passeed as the template type.
Definition widget.hpp:12