gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
multi_child_widget.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include <vector>
5
6#include "../core/widget.hpp"
7
8namespace ui {
9
13class MultiChildWidget : public Widget {
14protected:
16 std::vector<Widget *> children;
17
18public:
25 MultiChildWidget(const Position &pos = {0, 0}, const Alignment &align = {ALIGN_LEFT, ALIGN_TOP}, const Padding &padding = {0});
26
33
34 void update(time_t time_ms) override;
35 void render(bool force) const override;
36 void drawDone() override;
37 void draw() const override;
38
43 virtual void push(Widget *const child);
44
45 bool handleEvent(Event &event) override;
46
47#ifdef DEBUG
48 virtual void drawBoundingBox(time_t time) const override;
49#endif
50
51 Widget *getWidgetById(id_t id) noexcept override;
52
53 DERIVE_EVENT_HANDLERS(MultiChildWidget)
54};
55
56} // namespace ui
The common interface for a widget that contains multiple children.
Definition multi_child_widget.hpp:13
void draw() const override
Render the widget to the screen.
void update(time_t time_ms) override
Update any internal state of the widget, and check if it needs to be re-rendered.
void render(bool force) const override
Recursively render this widget and any child widgets that need it.
std::vector< Widget * > children
The child widgets.
Definition multi_child_widget.hpp:16
virtual void push(Widget *const child)
Append a child widget to the end of the list.
void drawDone() override
Reset any state variables after rendering has finished.
bool handleEvent(Event &event) override
Handle events from the touchscreen.
virtual void drawBoundingBox(time_t time) const override
Render the bounding box of this and any child widgets.
~MultiChildWidget() override
Destructor.
MultiChildWidget(const Position &pos={0, 0}, const Alignment &align={ALIGN_LEFT, ALIGN_TOP}, const Padding &padding={0})
Constructor.
Widget * getWidgetById(id_t id) noexcept override
Get the first widget (this or any children) that has the given ID.
The common interface for all UI objects.
Definition widget.hpp:27
Padding padding
The padding that will be applied to any child widgets.
Definition widget.hpp:51
uint32_t id_t
A (typically unique) identifier for widgets.
Definition id.hpp:13
A struct that holds a widget's vertical and horizontal alignment.
Definition alignment.hpp:22
A touchscreen event.
Definition event.hpp:26
A struct that holds the normalized position of a widget.
Definition position.hpp:15