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

Circular tap target hosting one vector glyph from Draw/Icons.h (or any function matching IconPainter). Tap feedback is a ripple, same rationale as Button (see Button.h's class comment). More...

#include <IconButton.h>

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

Public Member Functions

 IconButton ()=default
 
 IconButton (Bounds bounds, IconPainter< RGB_T > icon, IconButtonVariant variant=IconButtonVariant::kStandard)
 
void setIcon (IconPainter< RGB_T > icon)
 
void setVariant (IconButtonVariant variant)
 
void setColorOverride (RGB_T background, RGB_T foreground)
 
void clearColorOverride ()
 
void setThemeTint (RGB_T background, RGB_T foreground) override
 
void draw (tinygpu::ISurface< RGB_T > &target) 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
 
- 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()> onClick
 
- 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::IconButton< RGB_T >

Circular tap target hosting one vector glyph from Draw/Icons.h (or any function matching IconPainter). Tap feedback is a ripple, same rationale as Button (see Button.h's class comment).

Constructor & Destructor Documentation

◆ IconButton() [1/2]

IconButton ( )
default

◆ IconButton() [2/2]

IconButton ( Bounds  bounds,
IconPainter< RGB_T >  icon,
IconButtonVariant  variant = IconButtonVariant::kStandard 
)
inline

Member Function Documentation

◆ clearColorOverride()

void clearColorOverride ( )
inline

◆ 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 >.

◆ onGesture()

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

Handles one gesture event. Returns true if this widget consumed it.

Reimplemented from Widget< RGB_T >.

◆ setColorOverride()

void setColorOverride ( RGB_T  background,
RGB_T  foreground 
)
inline

Overrides the variant's theme colors - e.g. a FAB that's green when idle and red while active. Call clearColorOverride() to go back to the variant's normal theme colors.

◆ setIcon()

void setIcon ( IconPainter< RGB_T >  icon)
inline

◆ setThemeTint()

void setThemeTint ( RGB_T  background,
RGB_T  foreground 
)
inlineoverridevirtual

See Widget::setThemeTint() - used only when this button has no setColorOverride() of its own.

Reimplemented from Widget< RGB_T >.

◆ setVariant()

void setVariant ( IconButtonVariant  variant)
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

◆ onClick

std::function<void()> onClick

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