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

Draggable track-and-thumb slider over [minValue, maxValue]. More...

#include <Slider.h>

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

Public Member Functions

 Slider ()=default
 
 Slider (Bounds bounds, float minValue=0.0f, float maxValue=1.0f, float value=0.0f)
 
float value () const
 
void setValue (float value)
 
bool isDraggable () const 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.
 
- 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
 

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::Slider< RGB_T >

Draggable track-and-thumb slider over [minValue, maxValue].

Reports isDraggable() == true so Screen::isDraggableAt() (wired to GestureDetector::isDraggable) classifies a press-and-move starting on the slider as GestureType::kDrag rather than kPan/kScroll - and Screen latches the drag to this widget for its whole lifetime, so the thumb keeps tracking the finger even past the slider's own bounds. Tapping anywhere on the track also jumps the thumb there.

Constructor & Destructor Documentation

◆ Slider() [1/2]

Slider ( )
default

◆ Slider() [2/2]

Slider ( Bounds  bounds,
float  minValue = 0.0f,
float  maxValue = 1.0f,
float  value = 0.0f 
)
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 >.

◆ isDraggable()

bool isDraggable ( ) const
inlineoverridevirtual

Whether a continuous drag starting inside this widget's bounds should be classified as GestureType::kDrag (see GestureDetector::isDraggable and Screen::isDraggableAt). Only Slider (and Carousel, for its own horizontal swipe) needs true.

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

◆ setValue()

void setValue ( float  value)
inline

◆ value()

float value ( ) const
inline

Member Data Documentation

◆ onChange

std::function<void(float)> onChange

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