Base class every TinyMaterialDesign widget derives from.
More...
#include <Widget.h>
Inherited by Button< TINYMD_DEFAULT_RGB_T >, Container< TINYMD_DEFAULT_RGB_T >, IconButton< TINYMD_DEFAULT_RGB_T >, Keyboard< TINYMD_DEFAULT_RGB_T >, Label< TINYMD_DEFAULT_RGB_T >, ListItem< TINYMD_DEFAULT_RGB_T >, Menu< TINYMD_DEFAULT_RGB_T >, NavigationBar< TINYMD_DEFAULT_RGB_T >, RadioButton< TINYMD_DEFAULT_RGB_T >, SettingRow< TINYMD_DEFAULT_RGB_T >, Slider< TINYMD_DEFAULT_RGB_T >, Switch< TINYMD_DEFAULT_RGB_T >, TextField< TINYMD_DEFAULT_RGB_T >, WifiNetworkRow< TINYMD_DEFAULT_RGB_T >, AppBar< RGB_T >, Badge< RGB_T >, Banner< RGB_T >, BottomSheet< RGB_T >, Button< RGB_T >, Card< RGB_T >, Carousel< RGB_T >, Checkbox< RGB_T >, Chip< RGB_T >, CircularProgressIndicator< RGB_T >, Container< RGB_T >, Dialog< RGB_T >, Divider< RGB_T >, Drawer< RGB_T >, FloatingActionButton< RGB_T >, IconButton< RGB_T >, Keyboard< RGB_T >, Label< RGB_T >, LineChart< RGB_T >, LinearProgressIndicator< RGB_T >, ListItem< RGB_T >, MediaCard< RGB_T >, Menu< RGB_T >, NavigationBar< RGB_T >, NavigationRail< RGB_T >, RadioButton< RGB_T >, SearchBar< RGB_T >, SegmentedButton< RGB_T >, SettingRow< RGB_T >, Slider< RGB_T >, Snackbar< RGB_T >, StatTile< RGB_T >, Switch< RGB_T >, TabBar< RGB_T >, TextArea< RGB_T >, TextBlock< RGB_T >, TextField< RGB_T >, Tooltip< RGB_T >, and WifiNetworkRow< 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.
|
| |
template<typename RGB_T = TINYMD_DEFAULT_RGB_T>
class tinymd::Widget< RGB_T >
Base class every TinyMaterialDesign widget derives from.
Widgets are plain templated objects the sketch owns (as globals or members, same non-owning-reference style TinyGPU itself uses) and registers with a Screen via Screen::addWidget(). Screen calls draw()/ update()/onGesture() on the sketch's behalf each loop() iteration.
◆ ~Widget()
◆ child()
| virtual Widget< RGB_T > * child |
( |
int |
index | ) |
|
|
inlinevirtual |
◆ childCount()
| virtual int childCount |
( |
| ) |
const |
|
inlinevirtual |
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 in Container< RGB_T >, Container< TINYMD_DEFAULT_RGB_T >, BottomSheet< RGB_T >, Drawer< RGB_T >, Menu< RGB_T >, and Menu< TINYMD_DEFAULT_RGB_T >.
◆ draw()
| virtual void draw |
( |
tinygpu::ISurface< RGB_T > & |
target | ) |
|
|
pure virtual |
Renders the widget into target using colors/fonts/tokens from its own theme (see theme()/setTheme()).
Implemented in Container< RGB_T >, Screen< RGB_T >, AppBar< RGB_T >, Badge< RGB_T >, Banner< RGB_T >, BottomSheet< RGB_T >, Button< RGB_T >, Card< RGB_T >, Carousel< RGB_T >, Checkbox< RGB_T >, Chip< RGB_T >, Dialog< RGB_T >, Divider< RGB_T >, Drawer< RGB_T >, FloatingActionButton< RGB_T >, IconButton< RGB_T >, Keyboard< RGB_T >, Label< RGB_T >, LineChart< RGB_T >, ListItem< RGB_T >, MediaCard< RGB_T >, Menu< RGB_T >, NavigationBar< RGB_T >, NavigationRail< RGB_T >, LinearProgressIndicator< RGB_T >, CircularProgressIndicator< RGB_T >, RadioButton< RGB_T >, SearchBar< RGB_T >, SegmentedButton< RGB_T >, SliderRow< RGB_T >, SwitchRow< RGB_T >, RadioRow< RGB_T >, KeyValueRow< RGB_T >, Slider< RGB_T >, Snackbar< RGB_T >, StatTile< RGB_T >, Switch< RGB_T >, TabBar< RGB_T >, TextArea< RGB_T >, TextBlock< RGB_T >, TextField< RGB_T >, Tooltip< RGB_T >, and WifiNetworkRow< RGB_T >.
◆ drawBackground()
| virtual void drawBackground |
( |
tinygpu::ISurface< RGB_T > & |
target | ) |
|
|
inlinevirtual |
◆ isContainer()
| virtual bool isContainer |
( |
| ) |
const |
|
inlinevirtual |
◆ isDraggable()
| virtual bool isDraggable |
( |
| ) |
const |
|
inlinevirtual |
◆ isDraggableAt()
| virtual bool isDraggableAt |
( |
int32_t |
x, |
|
|
int32_t |
y |
|
) |
| const |
|
inlinevirtual |
Whether a drag starting at (x, y) - this widget's own coordinate space - should be classified as GestureType::kDrag. Default: just isDraggable(), ignoring the point - correct for any leaf widget. A composite (Container, Dialog, Drawer, Menu, BottomSheet) overrides this to recurse into whichever child sits at that point instead, so e.g. a Slider nested inside one of them is still recognized correctly by Screen::isDraggableAt().
Reimplemented in Screen< RGB_T >, Screen< TINYMD_DEFAULT_RGB_T >, Container< RGB_T >, Container< TINYMD_DEFAULT_RGB_T >, Banner< RGB_T >, BottomSheet< RGB_T >, Dialog< RGB_T >, Drawer< RGB_T >, Menu< RGB_T >, Menu< TINYMD_DEFAULT_RGB_T >, and SliderRow< RGB_T >.
◆ onGesture()
| virtual bool onGesture |
( |
const tinygpu::GestureEvent & |
event | ) |
|
|
inlinevirtual |
Handles one gesture event. Returns true if this widget consumed it.
Reimplemented in Container< RGB_T >, Container< TINYMD_DEFAULT_RGB_T >, Screen< RGB_T >, Screen< TINYMD_DEFAULT_RGB_T >, AppBar< RGB_T >, Banner< RGB_T >, BottomSheet< RGB_T >, Button< RGB_T >, Button< TINYMD_DEFAULT_RGB_T >, Carousel< RGB_T >, Checkbox< RGB_T >, Chip< RGB_T >, Dialog< RGB_T >, Drawer< RGB_T >, FloatingActionButton< RGB_T >, IconButton< RGB_T >, IconButton< TINYMD_DEFAULT_RGB_T >, Keyboard< RGB_T >, Keyboard< TINYMD_DEFAULT_RGB_T >, ListItem< RGB_T >, ListItem< TINYMD_DEFAULT_RGB_T >, MediaCard< RGB_T >, Menu< RGB_T >, Menu< TINYMD_DEFAULT_RGB_T >, NavigationBar< RGB_T >, NavigationBar< TINYMD_DEFAULT_RGB_T >, NavigationRail< RGB_T >, RadioButton< RGB_T >, RadioButton< TINYMD_DEFAULT_RGB_T >, SearchBar< RGB_T >, SegmentedButton< RGB_T >, SliderRow< RGB_T >, SwitchRow< RGB_T >, SwitchRow< TINYMD_DEFAULT_RGB_T >, RadioRow< RGB_T >, Slider< RGB_T >, Slider< TINYMD_DEFAULT_RGB_T >, Snackbar< RGB_T >, Switch< RGB_T >, Switch< TINYMD_DEFAULT_RGB_T >, TabBar< RGB_T >, TextArea< RGB_T >, TextField< RGB_T >, TextField< TINYMD_DEFAULT_RGB_T >, WifiNetworkRow< RGB_T >, and WifiNetworkRow< TINYMD_DEFAULT_RGB_T >.
◆ setTheme()
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 in Container< RGB_T >, Screen< RGB_T >, Banner< RGB_T >, BottomSheet< RGB_T >, Carousel< RGB_T >, Dialog< RGB_T >, Drawer< RGB_T >, Menu< RGB_T >, SliderRow< RGB_T >, SwitchRow< RGB_T >, and RadioRow< RGB_T >.
◆ setThemeTint()
| virtual void setThemeTint |
( |
RGB_T |
background, |
|
|
RGB_T |
foreground |
|
) |
| |
|
inlinevirtual |
Lets a container (AppBar, chiefly) push its own background/foreground color pair down onto a child it draws itself (leading/trailing), so e.g. an IconButton in an app bar with a color override reads clearly against it by default instead of staying on its own theme-wide default (which is tuned to sit on theme.colors.surface, not whatever color the app bar happens to be). Default: no-op, correct for any widget with no notion of "ambient" vs. its own explicit styling. IconButton overrides this as a fallback only used when it has no explicit setColorOverride() of its own, so e.g. a record button's active-red override still wins over the app bar's ambient tint.
Reimplemented in IconButton< RGB_T >.
◆ theme()
Convenience accessor for draw() overrides - see theme_.
◆ update()
| virtual bool update |
( |
uint32_t |
nowMs | ) |
|
|
inlinevirtual |
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 in Container< RGB_T >, Container< TINYMD_DEFAULT_RGB_T >, Screen< RGB_T >, Screen< TINYMD_DEFAULT_RGB_T >, AppBar< RGB_T >, Banner< RGB_T >, BottomSheet< RGB_T >, Button< RGB_T >, Button< TINYMD_DEFAULT_RGB_T >, Carousel< RGB_T >, Dialog< RGB_T >, Drawer< RGB_T >, FloatingActionButton< RGB_T >, IconButton< RGB_T >, IconButton< TINYMD_DEFAULT_RGB_T >, Menu< RGB_T >, Menu< TINYMD_DEFAULT_RGB_T >, LinearProgressIndicator< RGB_T >, CircularProgressIndicator< RGB_T >, SearchBar< RGB_T >, Snackbar< RGB_T >, TextArea< RGB_T >, TextField< RGB_T >, TextField< TINYMD_DEFAULT_RGB_T >, and Tooltip< RGB_T >.
◆ bounds
◆ enabled
◆ theme_
The theme this widget draws itself with - set via setTheme(), pushed in by Screen at registration time. Never dereferenced before that - every widget is registered with a Screen (which always has a theme, default-constructed if nothing else) before its first draw().
◆ visible
The documentation for this class was generated from the following file: