|
TinyMaterialDesign
|
Popover list of items (typically ListItem), anchored near whatever opened it - e.g. a dropdown from a Button, or a context menu from a long-press. Scrolls automatically once the items overflow the panel's height - the item area is a Container (Core/Container.h) under the hood. More...
#include <Menu.h>


Public Member Functions | |
| Menu ()=default | |
| Menu (Bounds bounds) | |
| void | addItem (Widget< RGB_T > &item) |
| void | clearItems () |
| Removes all items (they are not deleted) - e.g. to fill the menu anew. | |
| void | setItemProvider (typename Container< RGB_T >::ChildCountFn count, typename Container< RGB_T >::ChildAtFn at) |
| void | setTheme (const MaterialTheme< RGB_T > &theme) override |
| Bounds | itemRect (int index, int32_t height=40) 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 |
| Handles one gesture event. Returns true if this widget consumed it. | |
| 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()> | onOutsideTap |
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 |
Popover list of items (typically ListItem), anchored near whatever opened it - e.g. a dropdown from a Button, or a context menu from a long-press. Scrolls automatically once the items overflow the panel's height - the item area is a Container (Core/Container.h) under the hood.
Same modal-presentation shape as Dialog/Drawer: show with Screen::presentDialog(menu) and dismiss from an item's onClick or onOutsideTap. Unlike Dialog/Drawer it does not dim the rest of the screen (a menu is a lightweight popover, not a heavyweight interruption)
it just draws its own panel and swallows every gesture outside it.
Menu<RGB565> menu(Bounds(140, 60, 160, 3 * 40)); ListItem<RGB565> item(menu.itemRect(0), "Rename"); item.onClick = []() { doRename(); screen.dismissDialog(); }; menu.addItem(item); menu.onOutsideTap = []() { screen.dismissDialog(); }; screen.presentDialog(menu);
Items are not owned by Menu - same non-owning addItem() convention as Drawer::addItem()/Dialog::addAction().
Known limitation: same as Drawer's - Screen::drawDirect()'s per-widget- buffer rendering path draws items at their unscrolled position; only the regular draw() path scrolls correctly. See Drawer.h's class comment.
|
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 >.
|
inline |
Removes all items (they are not deleted) - e.g. to fill the menu anew.
|
inlineoverridevirtual |
Renders the widget into target using colors/fonts/tokens from its own theme (see theme()/setTheme()).
Implements Widget< RGB_T >.
|
inlineoverridevirtual |
Panel fill only, no items - see Widget::drawBackground() and childCount()/child() below (same rationale as Drawer's).
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 |
Handles one gesture event. Returns true if this widget consumed it.
Reimplemented from Widget< RGB_T >.
|
inline |
Switches to callback-driven items - see Container.h's class comment and Drawer.h's own setItemProvider() for the same pattern.
|
inlineoverridevirtual |
Sets the theme this widget draws itself with - see theme(). Screen pushes its own theme into a widget at registration time (addWidget()/addFixedWidget()/presentDialog()) and again whenever Screen::setTheme() is called; container widgets (Dialog, Drawer) cascade this down to whatever children they already hold.
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()> onOutsideTap |
Fired when a tap lands outside the panel - wire to Screen::dismissDialog() for tap-outside-to-close.