mikroSDK Reference Manual
lv_slider.h
Go to the documentation of this file.
1
6#ifndef LV_SLIDER_H
7#define LV_SLIDER_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#if LV_USE_SLIDER != 0
19
20/*Testing of dependencies*/
21#if LV_USE_BAR == 0
22#error "lv_slider: lv_bar is required. Enable it in lv_conf.h (LV_USE_BAR 1)"
23#endif
24
25#include "../core/lv_obj.h"
26#include "lv_bar.h"
27
28/*********************
29 * DEFINES
30 *********************/
31
32/**********************
33 * TYPEDEFS
34 **********************/
35
36enum {
37 LV_SLIDER_MODE_NORMAL = LV_BAR_MODE_NORMAL,
38 LV_SLIDER_MODE_SYMMETRICAL = LV_BAR_MODE_SYMMETRICAL,
39 LV_SLIDER_MODE_RANGE = LV_BAR_MODE_RANGE
40};
41typedef uint8_t lv_slider_mode_t;
42
43typedef struct {
44 lv_bar_t bar; /*Add the ancestor's type first*/
45 lv_area_t left_knob_area;
46 lv_area_t right_knob_area;
47 int32_t * value_to_set; /*Which bar value to set*/
48 uint8_t dragging : 1; /*1: the slider is being dragged*/
49 uint8_t left_knob_focus : 1; /*1: with encoder now the right knob can be adjusted*/
50} lv_slider_t;
51
52extern const lv_obj_class_t lv_slider_class;
53
58typedef enum {
59 LV_SLIDER_DRAW_PART_KNOB,
60 LV_SLIDER_DRAW_PART_KNOB_LEFT,
61} lv_slider_draw_part_type_t;
62
63/**********************
64 * GLOBAL PROTOTYPES
65 **********************/
66
72lv_obj_t * lv_slider_create(lv_obj_t * parent);
73
74/*=====================
75 * Setter functions
76 *====================*/
77
84static inline void lv_slider_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim)
85{
86 lv_bar_set_value(obj, value, anim);
87}
88
95static inline void lv_slider_set_left_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim)
96{
97 lv_bar_set_start_value(obj, value, anim);
98}
99
106static inline void lv_slider_set_range(lv_obj_t * obj, int32_t min, int32_t max)
107{
108 lv_bar_set_range(obj, min, max);
109}
110
116static inline void lv_slider_set_mode(lv_obj_t * obj, lv_slider_mode_t mode)
117{
118 lv_bar_set_mode(obj, (lv_bar_mode_t)mode);
119}
120
121/*=====================
122 * Getter functions
123 *====================*/
124
130static inline int32_t lv_slider_get_value(const lv_obj_t * obj)
131{
132 return lv_bar_get_value(obj);
133}
134
140static inline int32_t lv_slider_get_left_value(const lv_obj_t * obj)
141{
142 return lv_bar_get_start_value(obj);
143}
144
150static inline int32_t lv_slider_get_min_value(const lv_obj_t * obj)
151{
152 return lv_bar_get_min_value(obj);
153}
154
160static inline int32_t lv_slider_get_max_value(const lv_obj_t * obj)
161{
162 return lv_bar_get_max_value(obj);
163}
164
170bool lv_slider_is_dragged(const lv_obj_t * obj);
171
177static inline lv_slider_mode_t lv_slider_get_mode(lv_obj_t * slider)
178{
179 lv_bar_mode_t mode = lv_bar_get_mode(slider);
180 if(mode == LV_BAR_MODE_SYMMETRICAL) return LV_SLIDER_MODE_SYMMETRICAL;
181 else if(mode == LV_BAR_MODE_RANGE) return LV_SLIDER_MODE_RANGE;
182 else return LV_SLIDER_MODE_NORMAL;
183}
184
185/**********************
186 * MACROS
187 **********************/
188
189#endif /*LV_USE_SLIDER*/
190
191#ifdef __cplusplus
192} /*extern "C"*/
193#endif
194
195#endif /*LV_SLIDER_H*/
lv_anim_enable_t
Definition lv_anim.h:37
Definition lv_obj_class.h:49
Definition lv_obj.h:174
Definition lv_area.h:43