5#include "TinyGPU/Color/RGB565.h"
6#include "TinyGPU/Color/RGB666.h"
7#include "TinyGPU/Color/RGB888.h"
8#include "TinyMaterialDesign/Core/Container.h"
9#include "TinyMaterialDesign/Core/Widget.h"
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
52 this->bounds = bounds;
53 items_.bounds = bounds;
64 typename Container<RGB_T>::ChildAtFn at) {
65 items_.setChildProvider(std::move(count), std::move(at));
70 Widget<RGB_T>::setTheme(theme);
71 items_.setTheme(theme);
76 return Bounds(
this->bounds.x,
this->bounds.y + index * height,
this->bounds.w, height);
79 void draw(tinygpu::ISurface<RGB_T>& target)
override {
80 drawBackground(target);
81 items_.bounds =
this->bounds;
94 target.fillRect(toPx(
this->bounds.x), toPx(
this->bounds.y), toPx(
this->bounds.w),
95 toPx(
this->bounds.h),
this->theme().colors.surface);
98 int childCount()
const override {
return items_.childCount(); }
99 Widget<RGB_T>*
child(
int index)
override {
return items_.child(index); }
106 bool onGesture(
const tinygpu::GestureEvent& event)
override {
107 items_.bounds =
this->bounds;
109 if (Container<RGB_T>::isContinuousType(event.type)) {
110 if (event.phase == tinygpu::GesturePhase::kBegan) {
111 routingToItems_ = items_.bounds.contains(event.startPoint.x, event.startPoint.y);
113 return routingToItems_ ? items_.onGesture(event) :
true;
116 if (items_.bounds.contains(event.point.x, event.point.y) && items_.onGesture(event)) {
119 if (isTapGesture(event.type) && !
this->bounds.contains(event.point.x, event.point.y)) {
120 if (onScrimTap) onScrimTap();
125 bool update(uint32_t nowMs)
override {
return items_.update(nowMs); }
130 return items_.bounds.contains(x, y) && items_.isDraggableAt(x, y);
135 bool routingToItems_ =
false;
A widget that holds child widgets, draws/dispatches gestures to them, and scrolls its content vertica...
Definition: Container.h:56
Modal side navigation panel, holding a list of items (typically ListItem) that scrolls automatically ...
Definition: Drawer.h:48
bool isDraggableAt(int32_t x, int32_t y) const override
Definition: Drawer.h:129
bool onGesture(const tinygpu::GestureEvent &event) override
Definition: Drawer.h:106
void setItemProvider(typename Container< RGB_T >::ChildCountFn count, typename Container< RGB_T >::ChildAtFn at)
Switches to callback-driven items - see the class comment.
Definition: Drawer.h:63
Widget< RGB_T > * child(int index) override
Definition: Drawer.h:99
void addItem(Widget< RGB_T > &item)
Definition: Drawer.h:60
Drawer(Bounds bounds)
Definition: Drawer.h:51
Bounds itemRect(int index, int32_t height=48) const
Suggested rect for the index-th item, stacked from the panel's top.
Definition: Drawer.h:75
void draw(tinygpu::ISurface< RGB_T > &target) override
Definition: Drawer.h:79
std::function< void()> onScrimTap
Definition: Drawer.h:58
bool update(uint32_t nowMs) override
Definition: Drawer.h:125
int childCount() const override
Definition: Drawer.h:98
void setTheme(const MaterialTheme< RGB_T > &theme) override
Cascades the theme down to every item already added - see addItem().
Definition: Drawer.h:69
void drawBackground(tinygpu::ISurface< RGB_T > &target) override
Definition: Drawer.h:91
Definition: AnchorLayout.h:4
Axis-aligned pixel rectangle used for widget bounds and hit-testing.
Definition: Bounds.h:21
Bundles a color scheme, shape tokens, typography, and spacing into one theme, passed to widgets so th...
Definition: MaterialTheme.h:50