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

A small tile with one value: a caption at the top, the value in an accent color and an optional unit / sub text - for dashboards and KPIs. More...

#include <StatTile.h>

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

Public Member Functions

 StatTile ()=default
 
 StatTile (const char *caption, const char *sub="")
 
 StatTile (Bounds bounds, const char *caption, const char *sub="")
 
void setCaption (const char *caption)
 
void setValue (const char *value)
 
const std::string & value () const
 
void setSub (const char *sub)
 
void setAccent (RGB_T color)
 
void draw (tinygpu::ISurface< RGB_T > &target) 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

bool tonal = false
 Filled with surfaceVariant instead of outlined.
 
TypographyRole valueRole = TypographyRole::kTitle
 Font of the value (default: title, which falls back to smaller fonts).
 
- 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::StatTile< RGB_T >

A small tile with one value: a caption at the top, the value in an accent color and an optional unit / sub text - for dashboards and KPIs.

StatTile<RGB565> rate(Bounds(8, 40, 72, 46), "RATE", "s/day"); rate.setValue("+4.2"); rate.setAccent(colorFromHex<RGB565>(0x10B981));

The value is drawn in the title font and falls back to the body and label fonts if it does not fit. Outlined (default, on the page) or tonal (filled with surfaceVariant, e.g. inside a Card).

Constructor & Destructor Documentation

◆ StatTile() [1/3]

StatTile ( )
default

◆ StatTile() [2/3]

StatTile ( const char *  caption,
const char *  sub = "" 
)
inlineexplicit

◆ StatTile() [3/3]

StatTile ( Bounds  bounds,
const char *  caption,
const char *  sub = "" 
)
inline

Member Function Documentation

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

◆ setAccent()

void setAccent ( RGB_T  color)
inline

◆ setCaption()

void setCaption ( const char *  caption)
inline

◆ setSub()

void setSub ( const char *  sub)
inline

◆ setValue()

void setValue ( const char *  value)
inline

◆ value()

const std::string & value ( ) const
inline

Member Data Documentation

◆ tonal

bool tonal = false

Filled with surfaceVariant instead of outlined.

◆ valueRole

Font of the value (default: title, which falls back to smaller fonts).


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