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