TinyMaterialDesign
Loading...
Searching...
No Matches
Screen.h
Go to the documentation of this file.
1#pragma once
2#include <algorithm>
3#include <utility>
4#include <vector>
5
6#include "TinyGPU/Drivers/DisplayDriver.h"
7#include "TinyGPU/Input/GestureDetector.h"
8#include "TinyGPU/Surface/WindowedSurface.h"
10#include "TinyMaterialDesign/Core/Container.h"
11
12namespace tinymd {
13
14/**
15 * @brief Owns a set of widgets, draws them, and routes gesture events to
16 * whichever one should handle each event - the one root Container every
17 * sketch has, plus what only a root needs: a second non-scrolling widget
18 * layer, modal dialog presentation, and actually writing to a display.
19 *
20 * Screen does not own the widgets (the sketch does, typically as globals -
21 * the same non-owning-reference composition TinyGPU itself uses everywhere,
22 * e.g. DeviceOutput(driver&)). Usage, mirroring TinyGPU's own examples:
23 *
24 * Screen<RGB565> screen(theme);
25 * Button<RGB565> okButton(...);
26 * screen.addWidget(okButton);
27 *
28 * GestureDetector gestures;
29 * gestures.onGesture = [](GestureEvent& e) { screen.handleGesture(e); };
30 * gestures.isDraggable = [](int16_t x, int16_t y) {
31 * return screen.isDraggableAt(x, y);
32 * };
33 *
34 * void loop() {
35 * gestures.update(touchDriver);
36 * screen.update(millis());
37 * if (screen.isDirty()) { // see isDirty() - skips the (slow)
38 * screen.draw(surface); // redraw + display write when
39 * display.writeData(surface); // nothing changed this frame
40 * }
41 * }
42 *
43 * Vertical scrolling: widgets added via addWidget() are Container's own
44 * children (see Container.h) - laid out in one "content" coordinate space
45 * that can be taller than the surface passed to draw() - if it is, dragging
46 * up/down over any non-interactive spot (an empty gap, a Label, a Card, ...)
47 * scrolls that content, the same gesture TouchDriver/GestureDetector already
48 * classify as kScroll/kPan. Widgets that should stay put while the content
49 * behind them scrolls - a top AppBar, a bottom Keyboard - go through
50 * addFixedWidget() instead; they're always drawn and hit-tested on top of
51 * the scrollable content, at their own authored (screen-space) bounds. If
52 * everything already fits within the drawn surface, scrolling never
53 * engages (offset stays 0), no scrollbar is drawn, and existing sketches
54 * that only call addWidget() are unaffected. A thin scrollbar on the right
55 * edge appears automatically whenever there's something to scroll - see
56 * Container::draw().
57 *
58 * Since Screen *is* a Container (its scrollable content is just
59 * Container's own child list), an addWidget()'d widget can itself be a
60 * Container - nesting a smaller scrollable panel inside the one root
61 * scrollable area. See Container.h for that case's own scroll/gesture
62 * behavior and limitations (which Screen shares for its own content, listed
63 * below).
64 *
65 * A widget that straddles the viewport's top/bottom edge while scrolled
66 * partway off it is cropped to the viewport (see ISurface::pushClipRect(),
67 * used the same way Container.h uses it for its own children) rather than
68 * rendered pinned to y=0 at full size or skipped outright.
69 */
70template <typename RGB_T = TINYMD_DEFAULT_RGB_T>
71class Screen : public Container<RGB_T> {
72 public:
73 using Container<RGB_T>::bounds;
74
75 Screen() { this->setTheme(ownedTheme_); }
76
77 /// Constructs a Screen that starts with `theme` already set - pushed into
78 /// every widget registered afterward (see setTheme()).
79 explicit Screen(const MaterialTheme<RGB_T>& theme) : ownedTheme_(theme) { this->setTheme(ownedTheme_); }
80
81 /// Registers `widget` as scrollable content (see the class comment) -
82 /// Screen's own name for Container::addChild().
83 void addWidget(Widget<RGB_T>& widget) {
84 this->addChild(widget);
85 dirty_ = true;
86 }
87
88 /// Switches the scrollable content to callback-driven mode - Screen's own
89 /// name for Container::setChildProvider(), for lists too large to keep
90 /// every item's Widget resident at once. See Container.h's class comment.
91 void setContentProvider(typename Container<RGB_T>::ChildCountFn count,
92 typename Container<RGB_T>::ChildAtFn at) {
93 this->setChildProvider(std::move(count), std::move(at));
94 dirty_ = true;
95 }
96
97 /// Registers `widget` pinned to its authored bounds regardless of
98 /// scrolling - e.g. a top AppBar or bottom Keyboard. Always drawn and
99 /// hit-tested on top of every scrollable widget.
100 void addFixedWidget(Widget<RGB_T>& widget) {
101 fixedWidgets_.push_back(&widget);
102 widget.setTheme(ownedTheme_);
103 dirty_ = true;
104 }
105
106 /// Replaces the screen's theme and pushes it into every widget already
107 /// registered (scrollable, fixed, and a presented dialog if any).
108 /// Widgets registered later (addWidget()/addFixedWidget()/
109 /// presentDialog()) pick up whatever theme is current at that time.
110 void setTheme(const MaterialTheme<RGB_T>& theme) override {
111 ownedTheme_ = theme;
112 Container<RGB_T>::setTheme(ownedTheme_);
113 for (Widget<RGB_T>* w : fixedWidgets_) {
114 if (w != nullptr) w->setTheme(ownedTheme_);
115 }
116 if (dialog_ != nullptr) dialog_->setTheme(ownedTheme_);
117 dirty_ = true;
118 }
119
120 /// The theme currently in effect - see setTheme(). Public (unlike
121 /// Widget's own protected theme()) since a sketch often wants to read a
122 /// color role directly (e.g. to pass to a widget's own
123 /// setColorOverride()) without keeping a second copy of the theme
124 /// alongside the Screen.
125 const MaterialTheme<RGB_T>& theme() const { return ownedTheme_; }
126
127 /// Overrides the theme's background color for this screen. Not required -
128 /// draw() falls back to theme_.colors.background.
129 void setBackgroundColor(RGB_T color) {
130 backgroundColor_ = color;
131 hasBackgroundColor_ = true;
132 dirty_ = true;
133 }
134
135 /// True if draw() would paint something different than last time - see
136 /// invalidate(). A typical loop() should skip draw()/writeData() while
137 /// this is false:
138 ///
139 /// screen.update(millis());
140 /// if (screen.isDirty()) {
141 /// screen.draw(surface);
142 /// display.writeData(surface);
143 /// }
144 ///
145 /// Starts true so the first frame always draws. Set whenever a gesture
146 /// reaches handleGesture() (tap/drag/scroll - covers ripple starts,
147 /// toggles, slider drags, and anything a click/change callback does to
148 /// this or any other widget, since those callbacks run synchronously
149 /// during dispatch) or when update() advances a time-based animation
150 /// (ripple fade, indeterminate progress sweep, cursor blink). Cleared
151 /// once draw() has run.
152 ///
153 /// This is a coarse, screen-wide flag, not per-widget dirty rects - one
154 /// changed widget still repaints the whole screen. It also can't see
155 /// state a sketch mutates directly on a widget from outside a gesture/
156 /// update callback (e.g. a Label updated from a sensor reading in
157 /// loop()) - call invalidate() explicitly after changes like that.
158 bool isDirty() const { return dirty_; }
159
160 /// Forces the next isDirty() to be true / the next draw() to run, for
161 /// widget state changed from outside a gesture or update() callback -
162 /// see isDirty().
163 void invalidate() { dirty_ = true; }
164
165 void draw(tinygpu::ISurface<RGB_T>& target) override {
166 bounds.w = static_cast<int32_t>(target.width());
167 bounds.h = static_cast<int32_t>(target.height());
168
169 target.clear(hasBackgroundColor_ ? backgroundColor_ : ownedTheme_.colors.background);
170 Container<RGB_T>::draw(target); // clamps scroll, draws scrollable content + scrollbar
171 for (Widget<RGB_T>* widget : fixedWidgets_) {
172 if (widget->visible) widget->draw(target);
173 }
174 if (dialog_ != nullptr && dialog_->visible) {
175 dialog_->draw(target);
176 }
177 dirty_ = false;
178 }
179
180 /// Renders the full layout straight to `driver` without ever needing a
181 /// full-screen framebuffer - for boards that can't spare a single
182 /// contiguous allocation the size of the whole screen (e.g. classic
183 /// ESP32 without PSRAM: a 240x320 RGB565 buffer is 153,600 bytes, which
184 /// can exceed the largest free block even with plenty of *total* free
185 /// heap, since the heap ends up split into multiple smaller regions).
186 ///
187 /// Each visible widget - scrollable or fixed, skipping anything
188 /// invisible or entirely outside the viewport (including scrolled off
189 /// it), same idea as content that's never drawn today - gets `scratch`
190 /// resized to exactly its own bounds, is drawn into it once, and is
191 /// blitted directly to the panel at its own position: genuinely one
192 /// small buffer and one write per control, not a shared full-screen (or
193 /// full-band) one. `scratch` is one small, reused, real
194 /// (non-owning, already-begin()'d) surface - since Surface::resize()
195 /// only reallocates when growing past its current capacity, repeatedly
196 /// resizing it this way settles down to zero reallocation once it's
197 /// been sized to the largest single widget this layout ever draws.
198 ///
199 /// The one case that can't work this way is a presented modal
200 /// (Dialog/Drawer): its scrim always covers the *full* viewport
201 /// regardless of the modal's own bounds (see Dialog.h/Drawer.h), and it
202 /// can itself span most of the screen (a full-height Drawer) - both too
203 /// much for one small per-widget buffer. So while a modal is presented,
204 /// everything else is skipped outright (it would just be fully
205 /// occluded) and only the modal is drawn: its drawBackground() (see
206 /// Widget.h) - scrim plus whatever chrome isn't one of its children -
207 /// one short horizontal strip at a time via a WindowedSurface (see that
208 /// class) that reports the full viewport size for the scrim's own math
209 /// but clips actual pixel writes to the current strip, followed by each
210 /// of its children (see childCount()/child()) individually via the same
211 /// per-widget path as everything else - e.g. Drawer's own list items,
212 /// each drawn once rather than redrawn on every strip. A modal type
213 /// that doesn't override drawBackground()/childCount() (Dialog, as yet)
214 /// falls back to the default drawBackground() = draw() and childCount()
215 /// = 0, i.e. its *entire* contents (chrome + actions) drawn banded, same
216 /// as before.
217 ///
218 /// This is an alternative to draw()+writeData(surface) (unaffected by
219 /// this method's existence) - pick whichever fits your board.
220 void drawDirect(tinygpu::DisplayDriver<RGB_T>& driver, tinygpu::ISurface<RGB_T>& scratch,
221 int32_t viewportWidth, int32_t viewportHeight) {
222 bounds.w = viewportWidth;
223 bounds.h = viewportHeight;
224 this->clampScroll();
225
226 if (dialog_ != nullptr && dialog_->visible) {
227 drawModalDirect(driver, scratch, viewportWidth, viewportHeight);
228 dirty_ = false;
229 return;
230 }
231
232 const RGB_T background = hasBackgroundColor_ ? backgroundColor_ : ownedTheme_.colors.background;
233
234 // Unlike draw() (which clears the whole target surface up front - see
235 // its target.clear() call above), per-widget rendering only ever
236 // touches each widget's own small bounds - nothing paints the gaps
237 // between/around them otherwise, which would just show whatever was
238 // on the panel before (stale content, or black on first boot).
239 // writeColor() is DisplayDriver's own cheap one-row-buffer solid
240 // fill (see its doc comment) - no full-viewport buffer needed here
241 // either.
242 driver.writeColor(static_cast<size_t>(viewportWidth), static_cast<size_t>(viewportHeight),
243 background);
244
245 const int scrollCount = this->effectiveCount();
246 for (int i = 0; i < scrollCount; ++i) {
247 Widget<RGB_T>* widget = this->effectiveChild(i);
248 if (!widget->visible) continue;
249 Bounds screenBounds = widget->bounds;
250 screenBounds.y -= this->scrollOffset_;
251 if (!intersectsViewport(screenBounds, viewportWidth, viewportHeight)) continue;
252 widget->bounds.y -= this->scrollOffset_;
253 drawWidgetDirect(driver, scratch, *widget, background);
254 widget->bounds.y += this->scrollOffset_;
255 }
256 drawScrollbarDirect(driver, scratch, viewportWidth, viewportHeight);
257 for (Widget<RGB_T>* widget : fixedWidgets_) {
258 if (!widget->visible) continue;
259 if (!intersectsViewport(widget->bounds, viewportWidth, viewportHeight)) continue;
260 drawWidgetDirect(driver, scratch, *widget, background);
261 }
262 dirty_ = false;
263 }
264
265 /// Advances any time-based widget animation. Call once per loop(), before
266 /// checking isDirty().
267 bool update(uint32_t nowMs) override {
268 bool changed = Container<RGB_T>::update(nowMs);
269 for (Widget<RGB_T>* widget : fixedWidgets_) changed |= widget->update(nowMs);
270 if (dialog_ != nullptr) changed |= dialog_->update(nowMs);
271 if (changed) dirty_ = true;
272 return changed;
273 }
274
275 /// Wire this to GestureDetector::isDraggable so a drag starting on a
276 /// draggable widget (currently only Slider) is classified as kDrag
277 /// instead of kPan/kScroll - recurses into nested composites (Container,
278 /// Dialog, Drawer, Menu, BottomSheet) via their own isDraggableAt(), so a
279 /// Slider at any nesting depth is still recognized correctly.
280 bool isDraggableAt(int32_t x, int32_t y) const {
281 if (dialog_ != nullptr) return false;
282 Widget<RGB_T>* fixed = hitTestFixed(x, y);
283 if (fixed != nullptr) return fixed->isDraggableAt(x, y);
284 return Container<RGB_T>::isDraggableAt(x, y);
285 }
286
287 /// Wire this to GestureDetector::onGesture.
288 void handleGesture(const tinygpu::GestureEvent& event) { onGesture(event); }
289
290 bool onGesture(const tinygpu::GestureEvent& event) override {
291 using tinygpu::GesturePhase;
292 using tinygpu::GestureType;
293
294 // Any gesture reaching here might change something on screen (a ripple
295 // starting, a drag position, a scroll offset, or anything a click/
296 // change callback touches) - see isDirty(). Coarse but cheap, and only
297 // as frequent as actual input, not the loop() rate.
298 dirty_ = true;
299
300 if (dialog_ != nullptr) {
301 // Modal: every gesture goes to the presented dialog while it's shown.
302 // Dialog bounds are always screen-space, so no offset applies.
303 const bool handled = dialog_->enabled ? dialog_->onGesture(event) : false;
304 if (Container<RGB_T>::isContinuousType(event.type) && event.phase == GesturePhase::kEnded) {
305 activeFixedWidget_ = nullptr;
306 usingFixedWidget_ = false;
307 this->activeChild_ = nullptr;
308 this->scrollDragActive_ = false;
309 }
310 return handled;
311 }
312
313 if (Container<RGB_T>::isContinuousType(event.type)) {
314 // Drag-like gestures: latch what kBegan hit and keep routing to it
315 // for kChanged/kEnded even if the pointer leaves its bounds -
316 // otherwise dragging a Slider thumb past its own bounds would stop
317 // updating it. kPan/kScroll only ever fire over a non-draggable
318 // start point (see GestureDetector::classifyDragType), so they
319 // always mean "scroll the content" and are always left to
320 // Container::onGesture() below rather than the fixed layer. Fixed
321 // widgets - always screen-space, never scrollable - take priority
322 // over Container's own (scrollable) children, same order as
323 // hitTestFixed()-then-Container in the discrete branch below.
324 if (event.phase == GesturePhase::kBegan) {
325 usingFixedWidget_ = false;
326 activeFixedWidget_ = nullptr;
327 if (event.type != GestureType::kPan && event.type != GestureType::kScroll) {
328 Widget<RGB_T>* hit = hitTestFixed(event.startPoint.x, event.startPoint.y);
329 if (hit != nullptr) {
330 usingFixedWidget_ = true;
331 activeFixedWidget_ = hit;
332 }
333 }
334 }
335
336 bool handled = false;
337 if (usingFixedWidget_) {
338 if (activeFixedWidget_ != nullptr && activeFixedWidget_->enabled) {
339 handled = activeFixedWidget_->onGesture(event);
340 }
341 } else {
342 handled = Container<RGB_T>::onGesture(event);
343 }
344
345 if (event.phase == GesturePhase::kEnded) {
346 activeFixedWidget_ = nullptr;
347 usingFixedWidget_ = false;
348 }
349 return handled;
350 }
351
352 // Discrete gestures (tap/double-tap/long-press/swipe-*) always report
353 // phase kEnded with no preceding kBegan, so they're hit-tested fresh
354 // at the event's own point. Fixed widgets are checked first since
355 // they're always drawn over scrollable ones (matches draw()); falling
356 // through to Container::onGesture() covers this screen's own scrollable
357 // content, including translating the point into content space.
358 Widget<RGB_T>* hit = hitTestFixed(event.point.x, event.point.y);
359 if (hit != nullptr && hit->enabled) return hit->onGesture(event);
360 return Container<RGB_T>::onGesture(event);
361 }
362
363 /// Shows `dialog` modally: it receives every gesture and is drawn on top
364 /// until dismissDialog() is called (typically from one of the dialog's
365 /// own action-button callbacks).
366 void presentDialog(Widget<RGB_T>& dialog) {
367 dialog_ = &dialog;
368 dialog.setTheme(ownedTheme_);
369 dirty_ = true;
370 }
372 dialog_ = nullptr;
373 dirty_ = true;
374 }
375
376 /// True while a dialog (or menu, ...) is presented.
377 bool hasDialog() const { return dialog_ != nullptr; }
378 bool isDialogPresented() const { return dialog_ != nullptr; }
379
380 private:
381 /// True if screen-space `bounds` overlaps the viewport at all - see
382 /// drawDirect().
383 static bool intersectsViewport(const Bounds& bounds, int32_t viewportWidth, int32_t viewportHeight) {
384 return bounds.bottom() > 0 && bounds.y < viewportHeight && bounds.right() > 0 &&
385 bounds.x < viewportWidth;
386 }
387
388 /// Last-added widget wins ties, i.e. later addFixedWidget() calls are
389 /// treated as drawn on top (matches draw()). (x, y) is screen-space,
390 /// same as every fixed widget's own bounds.
391 Widget<RGB_T>* hitTestFixed(int32_t x, int32_t y) const {
392 for (auto it = fixedWidgets_.rbegin(); it != fixedWidgets_.rend(); ++it) {
393 Widget<RGB_T>* widget = *it;
394 if (widget->visible && widget->enabled && widget->bounds.contains(x, y)) return widget;
395 }
396 return nullptr;
397 }
398
399 /// Draws one widget into `scratch` (resized to exactly its own bounds)
400 /// and blits it to `driver` at its own position - see drawDirect().
401 /// No-ops (leaving the display unwritten) if `widget`'s bounds are
402 /// empty or scratch.resize() fails.
403 void drawWidgetDirect(tinygpu::DisplayDriver<RGB_T>& driver, tinygpu::ISurface<RGB_T>& scratch,
404 Widget<RGB_T>& widget, RGB_T background) {
405 const int32_t x = widget.bounds.x;
406 const int32_t y = widget.bounds.y;
407 const int32_t w = widget.bounds.w;
408 const int32_t h = widget.bounds.h;
409 if (w <= 0 || h <= 0) return;
410 if (!scratch.resize(static_cast<size_t>(w), static_cast<size_t>(h))) return;
411
412 tinygpu::WindowedSurface<RGB_T> window(scratch, x, y, static_cast<size_t>(w),
413 static_cast<size_t>(h), scratch.font());
414 window.clear(background);
415 widget.draw(window);
416 driver.writeData(scratch, x, y);
417 }
418
419 /// Draws the right-edge scroll position indicator directly - mirrors
420 /// Container::drawScrollbar(), just resized/blitted instead of drawn
421 /// into the shared full-size target. Only kBarWidth px wide regardless
422 /// of viewport height, so - unlike a modal - this always fits in one
423 /// shot.
424 void drawScrollbarDirect(tinygpu::DisplayDriver<RGB_T>& driver, tinygpu::ISurface<RGB_T>& scratch,
425 int32_t viewportWidth, int32_t viewportHeight) {
426 const int32_t content = this->contentHeight();
427 if (content <= viewportHeight) return;
428
429 constexpr int32_t kBarWidth = 4;
430 const int32_t trackX = viewportWidth - kBarWidth;
431 if (!scratch.resize(static_cast<size_t>(kBarWidth), static_cast<size_t>(viewportHeight))) return;
432
433 tinygpu::WindowedSurface<RGB_T> window(scratch, trackX, 0, static_cast<size_t>(kBarWidth),
434 static_cast<size_t>(viewportHeight), scratch.font());
435 window.fillRect(trackX, 0, kBarWidth, viewportHeight,
436 blend(ownedTheme_.colors.surface, ownedTheme_.colors.outline, 0.25f));
437
438 const int32_t maxScroll = content - viewportHeight;
439 // drawDirect() has set bounds.h = viewportHeight, so this matches the
440 // thumb that touch handling (Container::scrollToTrackY()) assumes
441 const int32_t thumbHeight = this->scrollThumbHeight(content);
442 const int32_t thumbY = maxScroll > 0
443 ? (this->scrollOffset_ * (viewportHeight - thumbHeight)) / maxScroll
444 : 0;
445 window.fillRoundRect(trackX, thumbY, kBarWidth, thumbHeight, kBarWidth / 2, ownedTheme_.colors.primary);
446 driver.writeData(scratch, trackX, 0);
447 }
448
449 /// Draws the presented modal - its drawBackground() banded (see
450 /// drawDirect() for why), then each of its children (if any)
451 /// individually via drawWidgetDirect(). `scratch` ends this method
452 /// resized to `viewportWidth x kModalBandHeight`.
453 void drawModalDirect(tinygpu::DisplayDriver<RGB_T>& driver, tinygpu::ISurface<RGB_T>& scratch,
454 int32_t viewportWidth, int32_t viewportHeight) {
455 const RGB_T background = hasBackgroundColor_ ? backgroundColor_ : ownedTheme_.colors.background;
456
457 constexpr int32_t kModalBandHeight = 40;
458 if (scratch.resize(static_cast<size_t>(viewportWidth), static_cast<size_t>(kModalBandHeight))) {
459 for (int32_t bandY = 0; bandY < viewportHeight; bandY += kModalBandHeight) {
460 tinygpu::WindowedSurface<RGB_T> window(scratch, 0, bandY,
461 static_cast<size_t>(viewportWidth),
462 static_cast<size_t>(viewportHeight),
463 scratch.font());
464 // drawBackground() darkens whatever's already in `window` (see
465 // Widget::drawScrim()) rather than painting a flat scrim color -
466 // deliberately just a clean background here, not the real
467 // regular content, on this memory/CPU-constrained rendering
468 // path (see drawDirect()'s doc comment) - without this clear()
469 // it would darken whatever stale pixels `scratch` happened to
470 // still hold from the last (differently-sized) widget drawn
471 // into it.
472 window.clear(background);
473 dialog_->drawBackground(window);
474 driver.writeData(scratch, 0, bandY);
475 }
476 }
477
478 const int childCount = dialog_->childCount();
479 for (int i = 0; i < childCount; ++i) {
480 Widget<RGB_T>* child = dialog_->child(i);
481 if (child != nullptr && child->visible) {
482 drawWidgetDirect(driver, scratch, *child, background);
483 }
484 }
485 }
486
487 std::vector<Widget<RGB_T>*> fixedWidgets_;
488 Widget<RGB_T>* activeFixedWidget_ = nullptr;
489 bool usingFixedWidget_ = false;
490 bool dirty_ = true;
491 Widget<RGB_T>* dialog_ = nullptr;
492 RGB_T backgroundColor_{};
493 bool hasBackgroundColor_ = false;
494 MaterialTheme<RGB_T> ownedTheme_{};
495};
496
497} // namespace tinymd
A widget that holds child widgets, draws/dispatches gestures to them, and scrolls its content vertica...
Definition: Container.h:56
Owns a set of widgets, draws them, and routes gesture events to whichever one should handle each even...
Definition: Screen.h:71
bool isDirty() const
Definition: Screen.h:158
void addFixedWidget(Widget< RGB_T > &widget)
Definition: Screen.h:100
void setBackgroundColor(RGB_T color)
Definition: Screen.h:129
Screen()
Definition: Screen.h:75
bool onGesture(const tinygpu::GestureEvent &event) override
Handles one gesture event. Returns true if this widget consumed it.
Definition: Screen.h:290
void dismissDialog()
Definition: Screen.h:371
bool hasDialog() const
True while a dialog (or menu, ...) is presented.
Definition: Screen.h:377
void drawDirect(tinygpu::DisplayDriver< RGB_T > &driver, tinygpu::ISurface< RGB_T > &scratch, int32_t viewportWidth, int32_t viewportHeight)
Definition: Screen.h:220
void invalidate()
Definition: Screen.h:163
void presentDialog(Widget< RGB_T > &dialog)
Definition: Screen.h:366
bool isDraggableAt(int32_t x, int32_t y) const
Definition: Screen.h:280
void draw(tinygpu::ISurface< RGB_T > &target) override
Definition: Screen.h:165
void setContentProvider(typename Container< RGB_T >::ChildCountFn count, typename Container< RGB_T >::ChildAtFn at)
Definition: Screen.h:91
Screen(const MaterialTheme< RGB_T > &theme)
Definition: Screen.h:79
void addWidget(Widget< RGB_T > &widget)
Definition: Screen.h:83
bool update(uint32_t nowMs) override
Definition: Screen.h:267
const MaterialTheme< RGB_T > & theme() const
Definition: Screen.h:125
bool isDialogPresented() const
Definition: Screen.h:378
void setTheme(const MaterialTheme< RGB_T > &theme) override
Definition: Screen.h:110
void handleGesture(const tinygpu::GestureEvent &event)
Wire this to GestureDetector::onGesture.
Definition: Screen.h:288
Base class every TinyMaterialDesign widget derives from.
Definition: Widget.h:58
Definition: AnchorLayout.h:4
Axis-aligned pixel rectangle used for widget bounds and hit-testing.
Definition: Bounds.h:21
int32_t right() const
Definition: Bounds.h:30
int32_t bottom() const
Definition: Bounds.h:31
int32_t y
Definition: Bounds.h:23
int32_t x
Definition: Bounds.h:22
Bundles a color scheme, shape tokens, typography, and spacing into one theme, passed to widgets so th...
Definition: MaterialTheme.h:50