mikroSDK Reference Manual
lv_obj.h
Go to the documentation of this file.
1
6#ifndef LV_OBJ_H
7#define LV_OBJ_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#include <stddef.h>
19#include <stdbool.h>
20#include "../misc/lv_style.h"
21#include "../misc/lv_types.h"
22#include "../misc/lv_area.h"
23#include "../misc/lv_color.h"
24#include "../misc/lv_assert.h"
25#include "../hal/lv_hal.h"
26
27/*********************
28 * DEFINES
29 *********************/
30
31/**********************
32 * TYPEDEFS
33 **********************/
34
35struct _lv_obj_t;
36
41enum {
42 LV_STATE_DEFAULT = 0x0000,
43 LV_STATE_CHECKED = 0x0001,
44 LV_STATE_FOCUSED = 0x0002,
45 LV_STATE_FOCUS_KEY = 0x0004,
46 LV_STATE_EDITED = 0x0008,
47 LV_STATE_HOVERED = 0x0010,
48 LV_STATE_PRESSED = 0x0020,
49 LV_STATE_SCROLLED = 0x0040,
50 LV_STATE_DISABLED = 0x0080,
51
52 LV_STATE_USER_1 = 0x1000,
53 LV_STATE_USER_2 = 0x2000,
54 LV_STATE_USER_3 = 0x4000,
55 LV_STATE_USER_4 = 0x8000,
56
57 LV_STATE_ANY = 0xFFFF,
58};
59
60typedef uint16_t lv_state_t;
61
68enum {
69 LV_PART_MAIN = 0x000000,
70 LV_PART_SCROLLBAR = 0x010000,
71 LV_PART_INDICATOR = 0x020000,
72 LV_PART_KNOB = 0x030000,
73 LV_PART_SELECTED = 0x040000,
74 LV_PART_ITEMS = 0x050000,
75 LV_PART_TICKS = 0x060000,
76 LV_PART_CURSOR = 0x070000,
80 LV_PART_ANY = 0x0F0000,
81};
82
83typedef uint32_t lv_part_t;
84
89enum {
90 LV_OBJ_FLAG_HIDDEN = (1L << 0),
100 LV_OBJ_FLAG_SCROLL_CHAIN = (LV_OBJ_FLAG_SCROLL_CHAIN_HOR | LV_OBJ_FLAG_SCROLL_CHAIN_VER),
109 LV_OBJ_FLAG_FLOATING = (1L << 18),
112 LV_OBJ_FLAG_LAYOUT_1 = (1L << 23),
113 LV_OBJ_FLAG_LAYOUT_2 = (1L << 24),
115 LV_OBJ_FLAG_WIDGET_1 = (1L << 25),
116 LV_OBJ_FLAG_WIDGET_2 = (1L << 26),
117 LV_OBJ_FLAG_USER_1 = (1L << 27),
118 LV_OBJ_FLAG_USER_2 = (1L << 28),
119 LV_OBJ_FLAG_USER_3 = (1L << 29),
120 LV_OBJ_FLAG_USER_4 = (1L << 30),
122};
123
124
125typedef uint32_t lv_obj_flag_t;
126
136
137#include "lv_obj_tree.h"
138#include "lv_obj_pos.h"
139#include "lv_obj_scroll.h"
140#include "lv_obj_style.h"
141#include "lv_obj_draw.h"
142#include "lv_obj_class.h"
143#include "lv_event.h"
144#include "lv_group.h"
145
149extern const lv_obj_class_t lv_obj_class;
150
155typedef struct {
156 struct _lv_obj_t ** children;
157 uint32_t child_cnt;
158 lv_group_t * group_p;
159
160 struct _lv_event_dsc_t * event_dsc;
163 lv_coord_t ext_click_pad;
164 lv_coord_t ext_draw_size;
166 lv_scrollbar_mode_t scrollbar_mode : 2;
167 lv_scroll_snap_t scroll_snap_x : 2;
168 lv_scroll_snap_t scroll_snap_y : 2;
169 lv_dir_t scroll_dir : 4;
170 uint8_t event_dsc_cnt : 6;
171 uint8_t layer_type : 2;
173
174typedef struct _lv_obj_t {
175 const lv_obj_class_t * class_p;
176 struct _lv_obj_t * parent;
177 _lv_obj_spec_attr_t * spec_attr;
178 _lv_obj_style_t * styles;
179#if LV_USE_USER_DATA
180 void * user_data;
181#endif
182 lv_area_t coords;
183 lv_obj_flag_t flags;
184 lv_state_t state;
185 uint16_t layout_inv : 1;
186 uint16_t scr_layout_inv : 1;
187 uint16_t skip_trans : 1;
188 uint16_t style_cnt : 6;
189 uint16_t h_layout : 1;
190 uint16_t w_layout : 1;
191} lv_obj_t;
192
193
194/**********************
195 * GLOBAL PROTOTYPES
196 **********************/
197
202void lv_init(void);
203
204#if LV_ENABLE_GC || !LV_MEM_CUSTOM
205
210void lv_deinit(void);
211
212#endif
213
218
225
226
227/*=====================
228 * Setter functions
229 *====================*/
230
236void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f);
237
243void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f);
244
245
252void lv_obj_add_state(lv_obj_t * obj, lv_state_t state);
253
260void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state);
261
267#if LV_USE_USER_DATA
268static inline void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
269{
270 obj->user_data = user_data;
271}
272#endif
273
274/*=======================
275 * Getter functions
276 *======================*/
277
284bool lv_obj_has_flag(const lv_obj_t * obj, lv_obj_flag_t f);
285
292bool lv_obj_has_flag_any(const lv_obj_t * obj, lv_obj_flag_t f);
293
299lv_state_t lv_obj_get_state(const lv_obj_t * obj);
300
307bool lv_obj_has_state(const lv_obj_t * obj, lv_state_t state);
308
314void * lv_obj_get_group(const lv_obj_t * obj);
315
321#if LV_USE_USER_DATA
322static inline void * lv_obj_get_user_data(lv_obj_t * obj)
323{
324 return obj->user_data;
325}
326#endif
327
328/*=======================
329 * Other functions
330 *======================*/
331
337
344bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
345
353bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p);
354
361
367bool lv_obj_is_valid(const lv_obj_t * obj);
368
378static inline lv_coord_t lv_obj_dpx(const lv_obj_t * obj, lv_coord_t n)
379{
380 return _LV_DPX_CALC(lv_disp_get_dpi(lv_obj_get_disp(obj)), n);
381}
382
383/**********************
384 * MACROS
385 **********************/
386
387#if LV_USE_ASSERT_OBJ
388# define LV_ASSERT_OBJ(obj_p, obj_class) \
389 do { \
390 LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \
391 LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, "Incompatible object type."); \
392 LV_ASSERT_MSG(lv_obj_is_valid(obj_p) == true, "The object is invalid, deleted or corrupted?"); \
393 } while(0)
394# else
395# define LV_ASSERT_OBJ(obj_p, obj_class) do{}while(0)
396#endif
397
398#if LV_USE_LOG && LV_LOG_TRACE_OBJ_CREATE
399# define LV_TRACE_OBJ_CREATE(...) LV_LOG_TRACE(__VA_ARGS__)
400#else
401# define LV_TRACE_OBJ_CREATE(...)
402#endif
403
404
405#ifdef __cplusplus
406} /*extern "C"*/
407#endif
408
409#endif /*LV_OBJ_H*/
#define _LV_DPX_CALC(dpi, n)
Definition lv_hal.h:29
lv_coord_t lv_disp_get_dpi(const lv_disp_t *disp)
void lv_obj_allocate_spec_attr(lv_obj_t *obj)
@ LV_STATE_ANY
Definition lv_obj.h:57
bool lv_obj_has_class(const lv_obj_t *obj, const lv_obj_class_t *class_p)
bool lv_obj_has_flag_any(const lv_obj_t *obj, lv_obj_flag_t f)
void lv_deinit(void)
const lv_obj_class_t * lv_obj_get_class(const lv_obj_t *obj)
bool lv_obj_has_flag(const lv_obj_t *obj, lv_obj_flag_t f)
bool lv_obj_check_type(const lv_obj_t *obj, const lv_obj_class_t *class_p)
const lv_obj_class_t lv_obj_class
lv_obj_draw_part_type_t
Definition lv_obj.h:131
@ LV_OBJ_DRAW_PART_BORDER_POST
Definition lv_obj.h:133
@ LV_OBJ_DRAW_PART_SCROLLBAR
Definition lv_obj.h:134
@ LV_OBJ_DRAW_PART_RECTANGLE
Definition lv_obj.h:132
bool lv_obj_is_valid(const lv_obj_t *obj)
lv_state_t lv_obj_get_state(const lv_obj_t *obj)
bool lv_is_initialized(void)
void lv_init(void)
void lv_obj_add_flag(lv_obj_t *obj, lv_obj_flag_t f)
void lv_obj_clear_flag(lv_obj_t *obj, lv_obj_flag_t f)
void lv_obj_clear_state(lv_obj_t *obj, lv_state_t state)
@ LV_OBJ_FLAG_WIDGET_2
Definition lv_obj.h:116
@ LV_OBJ_FLAG_USER_3
Definition lv_obj.h:119
@ LV_OBJ_FLAG_LAYOUT_1
Definition lv_obj.h:112
@ LV_OBJ_FLAG_LAYOUT_2
Definition lv_obj.h:113
@ LV_OBJ_FLAG_USER_4
Definition lv_obj.h:120
@ LV_OBJ_FLAG_GESTURE_BUBBLE
Definition lv_obj.h:106
@ LV_OBJ_FLAG_CHECKABLE
Definition lv_obj.h:93
@ LV_OBJ_FLAG_USER_2
Definition lv_obj.h:118
@ LV_OBJ_FLAG_SNAPPABLE
Definition lv_obj.h:103
@ LV_OBJ_FLAG_SCROLL_MOMENTUM
Definition lv_obj.h:96
@ LV_OBJ_FLAG_IGNORE_LAYOUT
Definition lv_obj.h:108
@ LV_OBJ_FLAG_WIDGET_1
Definition lv_obj.h:115
@ LV_OBJ_FLAG_SCROLL_CHAIN_HOR
Definition lv_obj.h:98
@ LV_OBJ_FLAG_PRESS_LOCK
Definition lv_obj.h:104
@ LV_OBJ_FLAG_HIDDEN
Definition lv_obj.h:90
@ LV_OBJ_FLAG_OVERFLOW_VISIBLE
Definition lv_obj.h:110
@ LV_OBJ_FLAG_ADV_HITTEST
Definition lv_obj.h:107
@ LV_OBJ_FLAG_SCROLL_ON_FOCUS
Definition lv_obj.h:101
@ LV_OBJ_FLAG_CLICKABLE
Definition lv_obj.h:91
@ LV_OBJ_FLAG_SCROLL_WITH_ARROW
Definition lv_obj.h:102
@ LV_OBJ_FLAG_CLICK_FOCUSABLE
Definition lv_obj.h:92
@ LV_OBJ_FLAG_SCROLL_ONE
Definition lv_obj.h:97
@ LV_OBJ_FLAG_SCROLLABLE
Definition lv_obj.h:94
@ LV_OBJ_FLAG_SCROLL_CHAIN_VER
Definition lv_obj.h:99
@ LV_OBJ_FLAG_FLOATING
Definition lv_obj.h:109
@ LV_OBJ_FLAG_USER_1
Definition lv_obj.h:117
@ LV_OBJ_FLAG_EVENT_BUBBLE
Definition lv_obj.h:105
@ LV_OBJ_FLAG_SCROLL_ELASTIC
Definition lv_obj.h:95
lv_obj_t * lv_obj_create(lv_obj_t *parent)
void lv_obj_add_state(lv_obj_t *obj, lv_state_t state)
@ LV_PART_MAIN
Definition lv_obj.h:69
@ LV_PART_ANY
Definition lv_obj.h:80
@ LV_PART_CUSTOM_FIRST
Definition lv_obj.h:78
@ LV_PART_SCROLLBAR
Definition lv_obj.h:70
@ LV_PART_CURSOR
Definition lv_obj.h:76
@ LV_PART_ITEMS
Definition lv_obj.h:74
@ LV_PART_SELECTED
Definition lv_obj.h:73
@ LV_PART_KNOB
Definition lv_obj.h:72
@ LV_PART_TICKS
Definition lv_obj.h:75
@ LV_PART_INDICATOR
Definition lv_obj.h:71
bool lv_obj_has_state(const lv_obj_t *obj, lv_state_t state)
void * lv_obj_get_group(const lv_obj_t *obj)
Definition lv_group.h:59
Definition lv_obj_class.h:49
Definition lv_obj.h:155
lv_scroll_snap_t scroll_snap_y
Definition lv_obj.h:168
uint8_t layer_type
Definition lv_obj.h:171
lv_scrollbar_mode_t scrollbar_mode
Definition lv_obj.h:166
struct _lv_obj_t ** children
Definition lv_obj.h:156
lv_scroll_snap_t scroll_snap_x
Definition lv_obj.h:167
lv_coord_t ext_click_pad
Definition lv_obj.h:163
struct _lv_event_dsc_t * event_dsc
Definition lv_obj.h:160
uint32_t child_cnt
Definition lv_obj.h:157
lv_coord_t ext_draw_size
Definition lv_obj.h:164
lv_point_t scroll
Definition lv_obj.h:161
lv_dir_t scroll_dir
Definition lv_obj.h:169
uint8_t event_dsc_cnt
Definition lv_obj.h:170
Definition lv_obj_style.h:39
Definition lv_obj.h:174
Definition lv_area.h:43
Definition lv_area.h:37