|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
A draggable value with presets: the throttle, and any other control that needs coarse reach and fine adjustment in one place. More...
Go to the source code of this file.
Data Structures | |
| struct | ui_slider_t |
Macros | |
| #define | UI_SLIDER_MAX_PRESETS 8 |
| #define | UI_SLIDER_OVERHANG 5 |
Functions | |
| void | ui_slider_init (ui_slider_t *s, gfx_rect_t track, float min, float max, gfx_color_t color) |
| void | ui_slider_set_ticks (ui_slider_t *s, int n) |
| void | ui_slider_set_presets (ui_slider_t *s, const float *values, const char *const *labels, int count, gfx_rect_t row) |
Sets the presets, laid out in a row inside row with 4px gaps. | |
| void | ui_slider_set (ui_slider_t *s, float value) |
| void | ui_slider_set_tap_to_set (ui_slider_t *s, bool on) |
| void | ui_slider_release (ui_slider_t *s) |
| bool | ui_slider_event (ui_slider_t *s, const touch_event_t *evt) |
| void | ui_slider_render (const ui_slider_t *s, gfx_canvas_t *c) |
| gfx_rect_t | ui_slider_painted_rect (const ui_slider_t *s) |
A draggable value with presets: the throttle, and any other control that needs coarse reach and fine adjustment in one place.
Two contracts about presses that do not end where they began, because those are the presses that command a motor by accident:
a press that starts on the track owns the value until it is released, wherever it moves, so a finger sliding off the track does not hand the value to whatever is underneath;
a press that starts anywhere else never becomes a drag, however far it travels across the track.
SPDX-License-Identifier: MIT
| bool ui_slider_event | ( | ui_slider_t * | s, |
| const touch_event_t * | evt ) |
Returns true when the value changed as a result of this event.
| gfx_rect_t ui_slider_painted_rect | ( | const ui_slider_t * | s | ) |
Every pixel ui_slider_render may touch, the thumb's overhang and its shadow included. A caller that repaints the slider without repainting everything around it clears this and not the track, or the thumb's old positions stay on the screen.
| void ui_slider_release | ( | ui_slider_t * | s | ) |
Abandon a drag that will get no release, on leaving a screen.
| void ui_slider_set_presets | ( | ui_slider_t * | s, |
| const float * | values, | ||
| const char *const * | labels, | ||
| int | count, | ||
| gfx_rect_t | row ) |
Sets the presets, laid out in a row inside row with 4px gaps.
| s | the slider |
| values | the presets' values |
| labels | their labels |
| count | how many |
| row | the row they take |
| void ui_slider_set_tap_to_set | ( | ui_slider_t * | s, |
| bool | on ) |
Let a press set the value under it. Off by default; a throttle must not take a value from one contact.
| void ui_slider_set_ticks | ( | ui_slider_t * | s, |
| int | n ) |
Draw n scale divisions across the track. 0 turns them off.