gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
single_child_widget.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "../core/widget.hpp"
5
6namespace ui {
7
11class SingleChildWidget : public Widget {
12protected:
15
16public:
24 SingleChildWidget(Widget *child, const Position &pos = {0, 0}, const Alignment &align = {ALIGN_LEFT, ALIGN_TOP}, const Padding &padding = {0});
25
32
33 Size size() const override;
34 void update(time_t time_ms) override;
35 void render(bool force) const override;
36 void drawDone() override;
37
44 void setChild(Widget *const child);
45
46 bool handleEvent(Event &event) override;
47
52 Widget *getChild() const;
53
54#ifdef DEBUG
55 virtual void drawBoundingBox(time_t time) const override;
56#endif
57
58 Widget *getWidgetById(id_t id) noexcept override;
59
60 DERIVE_EVENT_HANDLERS(SingleChildWidget)
61};
62
63} // namespace ui
The common interface for a widget that contains a single child.
Definition single_child_widget.hpp:11
Widget * getWidgetById(id_t id) noexcept override
Get the first widget (this or any children) that has the given ID.
void render(bool force) const override
Recursively render this widget and any child widgets that need it.
~SingleChildWidget() override
Destructor.
Size size() const override
Get the size of the widget.
void update(time_t time_ms) override
Update any internal state of the widget, and check if it needs to be re-rendered.
bool handleEvent(Event &event) override
Handle events from the touchscreen.
SingleChildWidget(Widget *child, const Position &pos={0, 0}, const Alignment &align={ALIGN_LEFT, ALIGN_TOP}, const Padding &padding={0})
Constructor.
virtual void drawBoundingBox(time_t time) const override
Render the bounding box of this and any child widgets.
Widget * getChild() const
Get the current child widget.
void drawDone() override
Reset any state variables after rendering has finished.
Widget * child
The child widget.
Definition single_child_widget.hpp:14
void setChild(Widget *const child)
Set the child widget.
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
A struct that holds the number of pixels that a widget would take up on the screen.
Definition size.hpp:17