Slider
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.
Functions
Slider* | slider_create (void) |
Slider* | slider_vertical (void) |
void | slider_OnMoved (...) |
void | slider_tooltip (...) |
void | slider_steps (...) |
void | slider_value (...) |
real32_t | slider_get_value (...) |
Sliders are normally used to edit continuous and bounded numerical values (Figure 1). As the control moves, OnMoved events occur that return a value between 0 and 1. In Hello Slider and Progress! you have an example of use.
- Use slider_create to create a horizontal slider.
- Use slider_vertical to create a vertical slider.
- Use slider_OnMoved to respond to scrolling.
slider_create ()
Create a new slider control.
Slider* slider_create(void);
Return
Slider.
slider_vertical ()
Create a new vertical slider.
Slider* slider_vertical(void);
Return
Slider.
slider_OnMoved ()
Set an event handler for slider movement.
void slider_OnMoved(Slider *slider, Listener *listener);
1 2 3 4 5 6 7 |
static void i_OnMoved(App *app, Event *e) { const EvSlider *p = event_params(e, EvSlider); do_something_onmoved(app, p->pos); } ... slider_OnMoved(slider, listener(app, i_OnMoved, App)); |
slider | Slider. |
listener | Callback function that will be called continuously while the user moves a slider. |
Remarks
EvSlider contains the event parameters, see GUI Events.
slider_tooltip ()
Set a tooltip for the slider. It is a small explanatory text that will appear when the mouse is over the control.
void slider_tooltip(Slider *slider, const char_t *text);
slider | Slider. |
text | UTF8 C-string terminated in null character |
slider_steps ()
Changes the slider from continuous range to discrete intervals.
void slider_steps(Slider *slider, const uint32_t steps);
slider | Slider. |
steps | Number of intervals. Use UINT32_MAX to return to continuous range. |
slider_value ()
Set the slider position.
void slider_value(Slider *slider, const real32_t value);
slider | Slider. |
value | The position between 0.0 and 1.0. |
slider_get_value ()
Get the slider position.
real32_t slider_get_value(const Slider *slider);
slider | Slider. |
Return
The normalized position between 0.0 and 1.0.