|
TinyMaterialDesign
|
Modal side navigation panel, holding a list of items (typically ListItem) that scrolls automatically once they overflow the panel's height - the item area is a Container (Core/Container.h) under the hood. More...
#include <Drawer.h>


Public Member Functions | |
| Drawer ()=default | |
| Drawer (Bounds bounds) | |
| void | addItem (Widget< RGB_T > &item) |
| void | setItemProvider (typename Container< RGB_T >::ChildCountFn count, typename Container< RGB_T >::ChildAtFn at) |
| Switches to callback-driven items - see the class comment. | |
| void | setTheme (const MaterialTheme< RGB_T > &theme) override |
| Cascades the theme down to every item already added - see addItem(). | |
| Bounds | itemRect (int index, int32_t height=48) const |
Suggested rect for the index-th item, stacked from the panel's top. | |
| void | draw (tinygpu::ISurface< RGB_T > &target) override |
| void | drawBackground (tinygpu::ISurface< RGB_T > &target) override |
| int | childCount () const override |
| Widget< RGB_T > * | child (int index) override |
| bool | onGesture (const tinygpu::GestureEvent &event) override |
| bool | update (uint32_t nowMs) override |
| bool | isDraggableAt (int32_t x, int32_t y) const override |
Public Member Functions inherited from Widget< RGB_T > | |
| virtual | ~Widget ()=default |
| virtual void | setTheme (const MaterialTheme< RGB_T > &theme) |
| virtual void | draw (tinygpu::ISurface< RGB_T > &target)=0 |
| virtual bool | onGesture (const tinygpu::GestureEvent &event) |
| Handles one gesture event. Returns true if this widget consumed it. | |
| virtual bool | update (uint32_t nowMs) |
| virtual bool | isDraggable () const |
| virtual bool | isDraggableAt (int32_t x, int32_t y) const |
| virtual int | childCount () const |
| virtual Widget< RGB_T > * | child (int index) |
| virtual void | drawBackground (tinygpu::ISurface< RGB_T > &target) |
| virtual void | setThemeTint (RGB_T background, RGB_T foreground) |
| virtual bool | isContainer () const |
| Provides true if the widget is a container. | |
Public Attributes | |
| std::function< void()> | onScrimTap |
Public Attributes inherited from Widget< RGB_T > | |
| Bounds | bounds |
| bool | visible = true |
| bool | enabled = true |
Additional Inherited Members | |
Protected Member Functions inherited from Widget< RGB_T > | |
| const MaterialTheme< RGB_T > & | theme () const |
| Convenience accessor for draw() overrides - see theme_. | |
Protected Attributes inherited from Widget< RGB_T > | |
| const MaterialTheme< RGB_T > * | theme_ = nullptr |
Modal side navigation panel, holding a list of items (typically ListItem) that scrolls automatically once they overflow the panel's height - the item area is a Container (Core/Container.h) under the hood.
bounds is the panel's own rect - typically the left portion of the screen, e.g. Bounds(0, 0, 220, kHeight) - not the full screen; like Dialog, the scrim is drawn separately covering the whole target surface. Show it with Screen::presentDialog(drawer) (Screen's modal-presentation mechanism isn't specific to alert dialogs - any Widget works, including this one) and dismiss it from an item's onClick or from onScrimTap.
Drawer<RGB565> drawer(Bounds(0, 0, 220, kHeight)); ListItem<RGB565> radios(drawer.itemRect(0), "Radios", drawIcon); radios.onClick = []() { showRadios(); screen.dismissDialog(); }; drawer.addItem(radios); drawer.onScrimTap = []() { screen.dismissDialog(); };
Items (like Dialog's actions) are not owned by Drawer - position each one's bounds (itemRect() suggests a spot) and add it with addItem().
Alternative to addItem(): setItemProvider(count, at) switches to callback-driven items - see Container.h's class comment for the pattern (useful for a long settings-style list too large to keep every ListItem resident at once).
Known limitation: Screen::drawDirect()'s per-widget-buffer rendering path (see childCount()/child() and Screen.h's own class comment) draws each item at its authored, unscrolled position regardless of the current scroll offset - correct only while the drawer isn't scrolled. The regular draw() path (used by the common draw()+writeData(surface) loop) scrolls correctly in both cases; only the rare low-RAM direct-render path has this gap.
|
default |
|
inline |
|
inlineoverridevirtual |
The index-th child (see childCount()); never called with an out-of-range index. Not owned by this widget any more than by whatever added it (addItem()/addAction()/...).
Reimplemented from Widget< RGB_T >.
|
inlineoverridevirtual |
Number of child widgets this one draws as part of itself, if any (0 by default) - a composite widget like Drawer overrides this + child() to expose its items (Dialog its actions, etc.), so Screen::drawDirect() can draw a presented modal's children individually, each into its own small right-sized buffer, instead of needing one buffer big enough for the whole modal - see drawBackground().
Reimplemented from Widget< RGB_T >.
|
inlineoverridevirtual |
Renders the widget into target using colors/fonts/tokens from its own theme (see theme()/setTheme()).
Implements Widget< RGB_T >.
|
inlineoverridevirtual |
Scrim + panel fill only, no items - see Widget::drawBackground() and childCount()/child() below, which together let Screen::drawDirect() draw this (on a board without enough RAM for a full-screen buffer) as this small background plus each item individually, rather than needing one buffer sized to the whole drawer (its own bounds are often nearly full-screen).
Reimplemented from Widget< RGB_T >.
|
inlineoverridevirtual |
True if there's an item at (x, y) that's draggable, recursing through the item Container - see Widget::isDraggableAt().
Reimplemented from Widget< RGB_T >.
|
inline |
Suggested rect for the index-th item, stacked from the panel's top.
|
inlineoverridevirtual |
Screen routes every gesture here while the drawer is presented: a continuous drag starting over the item list scrolls it (see Container::onGesture()); a tap on an item is forwarded to it; a tap outside the panel fires onScrimTap; everything else is swallowed rather than leaking through to whatever is behind the drawer.
Reimplemented from Widget< RGB_T >.
|
inline |
Switches to callback-driven items - see the class comment.
|
inlineoverridevirtual |
Cascades the theme down to every item already added - see addItem().
Reimplemented from Widget< RGB_T >.
|
inlineoverridevirtual |
Called once per frame, before draw(), to advance any time-based animation (ripple fade, indeterminate progress sweep, ...). Returns true if that advance changed anything this widget will draw differently, so Screen can decide whether a redraw is actually needed - see Screen::isDirty(). Default: no-op, not dirty, so widgets that don't animate cost nothing extra.
Reimplemented from Widget< RGB_T >.
| std::function<void()> onScrimTap |
Fired when a tap lands outside the panel (i.e. on the scrim) - wire this to Screen::dismissDialog() for tap-outside-to-close.