Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_objx/lv_roller.h
1476 views
1
/**
2
* @file lv_roller.h
3
*
4
*/
5
6
#ifndef LV_ROLLER_H
7
#define LV_ROLLER_H
8
9
#ifdef __cplusplus
10
extern "C" {
11
#endif
12
13
/*********************
14
* INCLUDES
15
*********************/
16
#ifdef LV_CONF_INCLUDE_SIMPLE
17
#include "lv_conf.h"
18
#else
19
#include "../../lv_conf.h"
20
#endif
21
22
#if USE_LV_ROLLER != 0
23
24
/*Testing of dependencies*/
25
#if USE_LV_DDLIST == 0
26
#error "lv_roller: lv_ddlist is required. Enable it in lv_conf.h (USE_LV_DDLIST 1) "
27
#endif
28
29
#include "../lv_core/lv_obj.h"
30
#include "lv_ddlist.h"
31
#include "lv_label.h"
32
33
/*********************
34
* DEFINES
35
*********************/
36
37
/**********************
38
* TYPEDEFS
39
**********************/
40
/*Data of roller*/
41
typedef struct {
42
lv_ddlist_ext_t ddlist; /*Ext. of ancestor*/
43
/*New data for this type */
44
} lv_roller_ext_t;
45
46
enum {
47
LV_ROLLER_STYLE_BG,
48
LV_ROLLER_STYLE_SEL,
49
};
50
typedef uint8_t lv_roller_style_t;
51
52
/**********************
53
* GLOBAL PROTOTYPES
54
**********************/
55
56
/**
57
* Create a roller object
58
* @param par pointer to an object, it will be the parent of the new roller
59
* @param copy pointer to a roller object, if not NULL then the new object will be copied from it
60
* @return pointer to the created roller
61
*/
62
lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy);
63
64
/*=====================
65
* Setter functions
66
*====================*/
67
68
/**
69
* Set the align of the roller's options (left, right or center[default])
70
* @param roller - pointer to a roller object
71
* @param align - one of lv_label_align_t values (left, right, center)
72
*/
73
void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align);
74
75
/**
76
* Set the options on a roller
77
* @param roller pointer to roller object
78
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
79
*/
80
static inline void lv_roller_set_options(lv_obj_t * roller, const char * options)
81
{
82
lv_ddlist_set_options(roller, options);
83
}
84
85
/**
86
* Set the selected option
87
* @param roller pointer to a roller object
88
* @param sel_opt id of the selected option (0 ... number of option - 1);
89
* @param anim_en true: set with animation; false set immediately
90
*/
91
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en);
92
93
/**
94
* Set a function to call when a new option is chosen
95
* @param roller pointer to a roller
96
* @param action pointer to a callback function
97
*/
98
static inline void lv_roller_set_action(lv_obj_t * roller, lv_action_t action)
99
{
100
lv_ddlist_set_action(roller, action);
101
}
102
103
/**
104
* Set the height to show the given number of rows (options)
105
* @param roller pointer to a roller object
106
* @param row_cnt number of desired visible rows
107
*/
108
void lv_roller_set_visible_row_count(lv_obj_t *roller, uint8_t row_cnt);
109
110
/**
111
* Enable or disable the horizontal fit to the content
112
* @param roller pointer to a roller
113
* @param en true: enable auto fit; false: disable auto fit
114
*/
115
static inline void lv_roller_set_hor_fit(lv_obj_t * roller, bool en)
116
{
117
lv_ddlist_set_hor_fit(roller, en);
118
}
119
120
/**
121
* Set the open/close animation time.
122
* @param roller pointer to a roller object
123
* @param anim_time: open/close animation time [ms]
124
*/
125
static inline void lv_roller_set_anim_time(lv_obj_t *roller, uint16_t anim_time)
126
{
127
lv_ddlist_set_anim_time(roller, anim_time);
128
}
129
130
/**
131
* Set a style of a roller
132
* @param roller pointer to a roller object
133
* @param type which style should be set
134
* @param style pointer to a style
135
*/
136
void lv_roller_set_style(lv_obj_t *roller, lv_roller_style_t type, lv_style_t *style);
137
138
/*=====================
139
* Getter functions
140
*====================*/
141
142
/**
143
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
144
* @param roller pointer to a roller object
145
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
146
*/
147
lv_label_align_t lv_roller_get_align(const lv_obj_t * roller);
148
149
/**
150
* Get the options of a roller
151
* @param roller pointer to roller object
152
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
153
*/
154
static inline const char * lv_roller_get_options(const lv_obj_t *roller)
155
{
156
return lv_ddlist_get_options(roller);
157
}
158
159
/**
160
* Get the id of the selected option
161
* @param roller pointer to a roller object
162
* @return id of the selected option (0 ... number of option - 1);
163
*/
164
static inline uint16_t lv_roller_get_selected(const lv_obj_t *roller)
165
{
166
return lv_ddlist_get_selected(roller);
167
}
168
169
/**
170
* Get the current selected option as a string
171
* @param roller pointer to roller object
172
* @param buf pointer to an array to store the string
173
*/
174
static inline void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf)
175
{
176
lv_ddlist_get_selected_str(roller, buf);
177
}
178
179
/**
180
* Get the "option selected" callback function
181
* @param roller pointer to a roller
182
* @return pointer to the call back function
183
*/
184
static inline lv_action_t lv_roller_get_action(const lv_obj_t * roller)
185
{
186
return lv_ddlist_get_action(roller);
187
}
188
189
/**
190
* Get the open/close animation time.
191
* @param roller pointer to a roller
192
* @return open/close animation time [ms]
193
*/
194
static inline uint16_t lv_roller_get_anim_time(const lv_obj_t * roller)
195
{
196
return lv_ddlist_get_anim_time(roller);
197
}
198
199
/**
200
* Get the auto width set attribute
201
* @param roller pointer to a roller object
202
* @return true: auto size enabled; false: manual width settings enabled
203
*/
204
bool lv_roller_get_hor_fit(const lv_obj_t *roller);
205
206
/**
207
* Get a style of a roller
208
* @param roller pointer to a roller object
209
* @param type which style should be get
210
* @return style pointer to a style
211
* */
212
lv_style_t * lv_roller_get_style(const lv_obj_t *roller, lv_roller_style_t type);
213
214
/**********************
215
* MACROS
216
**********************/
217
218
#endif /*USE_LV_ROLLER*/
219
220
#ifdef __cplusplus
221
} /* extern "C" */
222
#endif
223
224
#endif /*LV_ROLLER_H*/
225
226