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

Caption and formatted value on one line, a Slider below. The value is quantized to step: More...

#include <SettingRows.h>

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

Public Types

using Formatter = std::function< void(float value, char *buf, size_t len)>
 

Public Member Functions

 SliderRow ()=default
 
 SliderRow (const char *caption, float minValue, float maxValue, float step, Formatter format=nullptr)
 
float value () const
 
void setValue (float value)
 
void setTheme (const MaterialTheme< RGB_T > &theme) 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 isDraggableAt (int32_t x, int32_t y) const override
 
- Public Member Functions inherited from SettingRow< RGB_T >
void setCaption (const char *caption)
 
const std::string & caption () const
 
void setOnSurface (bool onSurface)
 Draw on a surface (e.g. inside a Card) instead of the page background.
 
- 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(float)> onChange
 
- Public Attributes inherited from Widget< RGB_T >
Bounds bounds
 
bool visible = true
 
bool enabled = true
 

Static Public Attributes

static constexpr int32_t kHeight = 40
 

Additional Inherited Members

- Protected Member Functions inherited from SettingRow< RGB_T >
RGB_T background () const
 
void text (tinygpu::ISurface< RGB_T > &target, tinygpu::IFont< RGB_T > &font, int32_t x, int32_t y, const char *s, RGB_T color)
 
RGB_T dimmed (RGB_T color) const
 
- 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 SettingRow< RGB_T >
std::string caption_
 
bool onSurface_ = false
 
- 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::SliderRow< RGB_T >

Caption and formatted value on one line, a Slider below. The value is quantized to step:

SliderRow<RGB565> gain("Gain", 0, 40, 1, [](float v, char* b, size_t n) { snprintf(b, n, "%+.0f dB", v); }); gain.onChange = [](float v) { ... };

Member Typedef Documentation

◆ Formatter

using Formatter = std::function<void(float value, char* buf, size_t len)>

Constructor & Destructor Documentation

◆ SliderRow() [1/2]

SliderRow ( )
default

◆ SliderRow() [2/2]

SliderRow ( const char *  caption,
float  minValue,
float  maxValue,
float  step,
Formatter  format = nullptr 
)
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 >.

◆ isDraggableAt()

bool isDraggableAt ( int32_t  x,
int32_t  y 
) const
inlineoverridevirtual

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

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

◆ setValue()

void setValue ( float  value)
inline

◆ value()

float value ( ) const
inline

Member Data Documentation

◆ kHeight

constexpr int32_t kHeight = 40
staticconstexpr

◆ onChange

std::function<void(float)> onChange

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