rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_slider.h
Go to the documentation of this file.
1
18
#pragma once
19
20
#include <stdbool.h>
21
22
#include "
gfx.h
"
23
#include "
touch_types.h
"
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
29
#define UI_SLIDER_MAX_PRESETS 8
30
31
/*
32
* How far ui_slider_render paints outside its track, above and below, in
33
* pixels.
34
*
35
* The thumb stands proud of the track, and a caller that clears only the
36
* track rectangle before redrawing leaves that overhang behind. The thumb's
37
* shadow is offset 2px below it, so the painted region is not symmetric and
38
* this constant alone does not describe it: use ui_slider_painted_rect().
39
*/
40
#define UI_SLIDER_OVERHANG 5
41
42
typedef
struct
{
43
gfx_rect_t
track;
44
gfx_rect_t
presets[UI_SLIDER_MAX_PRESETS];
45
float
preset_value[UI_SLIDER_MAX_PRESETS];
46
const
char
*preset_label[UI_SLIDER_MAX_PRESETS];
47
int
preset_count;
48
int
ticks
;
49
50
float
min, max, step;
51
float
value;
52
gfx_color_t color;
53
54
/*
55
* Whether a press sets the value under it. Off by default, because the
56
* control this widget was written for is a throttle: a touch at the far
57
* end of the track would command full travel in one contact. A slider
58
* that commands nothing dangerous can turn it on and keep the tap.
59
*/
60
bool
tap_to_set;
61
62
/* Drawn dimmed, as a button that takes no press is. The drawing only:
63
* the owner decides which events the slider is given. */
64
bool
dim;
65
66
bool
dragging;
67
uint8_t drag_id;
68
int16_t
drag_x
;
69
float
drag_value
;
70
int
pressed_preset
;
71
uint8_t preset_id;
72
}
ui_slider_t
;
73
74
void
ui_slider_init(
ui_slider_t
*
s
,
gfx_rect_t
track,
float
min,
float
max,
75
gfx_color_t color);
77
void
ui_slider_set_ticks
(
ui_slider_t
*
s
,
int
n);
78
87
void
ui_slider_set_presets
(
ui_slider_t
*
s
,
const
float
*values,
88
const
char
*
const
*labels,
int
count,
89
gfx_rect_t
row);
90
91
void
ui_slider_set(
ui_slider_t
*
s
,
float
value);
92
97
void
ui_slider_set_tap_to_set
(
ui_slider_t
*
s
,
bool
on);
98
100
void
ui_slider_release
(
ui_slider_t
*
s
);
101
103
bool
ui_slider_event
(
ui_slider_t
*
s
,
const
touch_event_t
*evt);
104
105
void
ui_slider_render(
const
ui_slider_t
*
s
,
gfx_canvas_t
*c);
106
113
gfx_rect_t
ui_slider_painted_rect
(
const
ui_slider_t
*
s
);
114
115
#ifdef __cplusplus
116
}
117
#endif
s
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition
esc_stick_panel_int.h:295
gfx.h
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
gfx_canvas_t
Definition
gfx.h:129
gfx_rect_t
Definition
gfx.h:81
touch_event_t
A DOWN, MOVE or UP of one contact.
Definition
touch_types.h:69
ui_slider_t
Definition
ui_slider.h:42
ui_slider_t::ticks
int ticks
Definition
ui_slider.h:48
ui_slider_t::pressed_preset
int pressed_preset
Definition
ui_slider.h:70
ui_slider_t::drag_value
float drag_value
Definition
ui_slider.h:69
ui_slider_t::drag_x
int16_t drag_x
Definition
ui_slider.h:68
touch_types.h
Plain data types shared by the touch controller driver, the coordinate mapper and the event tracker....
ui_slider_set_presets
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.
Definition
ui_slider.c:43
ui_slider_event
bool ui_slider_event(ui_slider_t *s, const touch_event_t *evt)
Definition
ui_slider.c:125
ui_slider_release
void ui_slider_release(ui_slider_t *s)
Definition
ui_slider.c:95
ui_slider_set_ticks
void ui_slider_set_ticks(ui_slider_t *s, int n)
Definition
ui_slider.c:36
ui_slider_painted_rect
gfx_rect_t ui_slider_painted_rect(const ui_slider_t *s)
Definition
ui_slider.c:214
ui_slider_set_tap_to_set
void ui_slider_set_tap_to_set(ui_slider_t *s, bool on)
Definition
ui_slider.c:88
shared
ui
include
ui_slider.h
Generated by
1.18.0