TinyMaterialDesign
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
BottomSheet< RGB_T > Class Template Reference

Modal panel sliding up from the bottom edge, full width, with rounded top corners and a drag-handle bar - Material's "modal bottom sheet". Holds a list of items (typically ListItem or Button) the same non-owning way Drawer holds its items, in a Container (Core/Container.h) that scrolls automatically once they overflow the sheet's height. More...

#include <BottomSheet.h>

Inheritance diagram for BottomSheet< RGB_T >:
Inheritance graph
[legend]
Collaboration diagram for BottomSheet< RGB_T >:
Collaboration graph
[legend]

Public Member Functions

 BottomSheet ()=default
 
 BottomSheet (Bounds bounds)
 
 BottomSheet (Bounds bounds, const char *title)
 
void setTitle (const char *title)
 
void addItem (Widget< RGB_T > &item)
 
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=48) const
 
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
 Fired when a tap lands outside the panel (i.e. on the scrim).
 
- 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
 

Detailed Description

template<typename RGB_T = TINYMD_DEFAULT_RGB_T>
class tinymd::BottomSheet< RGB_T >

Modal panel sliding up from the bottom edge, full width, with rounded top corners and a drag-handle bar - Material's "modal bottom sheet". Holds a list of items (typically ListItem or Button) the same non-owning way Drawer holds its items, in a Container (Core/Container.h) that scrolls automatically once they overflow the sheet's height.

bounds is the sheet's own rect (e.g. Bounds(0, screenH - 220, screenW, 220)) - not the full screen; the scrim is drawn separately covering the whole target surface, same convention as Dialog/Drawer. Show it with Screen::presentDialog(sheet) and dismiss it from an item's onClick or from onScrimTap.

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.

Constructor & Destructor Documentation

◆ BottomSheet() [1/3]

BottomSheet ( )
default

◆ BottomSheet() [2/3]

BottomSheet ( Bounds  bounds)
inlineexplicit

◆ BottomSheet() [3/3]

BottomSheet ( Bounds  bounds,
const char *  title 
)
inline

Member Function Documentation

◆ addItem()

void addItem ( Widget< RGB_T > &  item)
inline

◆ child()

Widget< RGB_T > * child ( int  index)
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 >.

◆ childCount()

int childCount ( ) const
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 >.

◆ draw()

void draw ( tinygpu::ISurface< RGB_T > &  target)
inlineoverridevirtual

Renders the widget into target using colors/fonts/tokens from its own theme (see theme()/setTheme()).

Implements Widget< RGB_T >.

◆ drawBackground()

void drawBackground ( tinygpu::ISurface< RGB_T > &  target)
inlineoverridevirtual

Scrim + panel fill + handle + title, no items - see Widget::drawBackground() and childCount()/child() (same rationale as Drawer's own).

Reimplemented from Widget< RGB_T >.

◆ isDraggableAt()

bool isDraggableAt ( int32_t  x,
int32_t  y 
) const
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 >.

◆ itemRect()

Bounds itemRect ( int  index,
int32_t  height = 48 
) const
inline

Suggested rect for the index-th item, stacked below the handle/title. Deliberately theme-independent (fixed constants, not theme().spacing/typography) - like Drawer::itemRect()/MenuitemRect(), this is meant to be callable at global-scope construction time, before this sheet has ever been given a theme (see Drawer.h's class comment for that usage pattern).

◆ onGesture()

bool onGesture ( const tinygpu::GestureEvent &  event)
inlineoverridevirtual

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.

Reimplemented from Widget< RGB_T >.

◆ setItemProvider()

void setItemProvider ( typename Container< RGB_T >::ChildCountFn  count,
typename Container< RGB_T >::ChildAtFn  at 
)
inline

Switches to callback-driven items - see Container.h's class comment and Drawer.h's own setItemProvider() for the same pattern.

◆ setTheme()

void setTheme ( const MaterialTheme< RGB_T > &  theme)
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 >.

◆ setTitle()

void setTitle ( const char *  title)
inline

◆ update()

bool update ( uint32_t  nowMs)
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 >.

Member Data Documentation

◆ onScrimTap

std::function<void()> onScrimTap

Fired when a tap lands outside the panel (i.e. on the scrim).


The documentation for this class was generated from the following file: