Skip to content

Commit afe29b7

Browse files
FASTSHIFTpengyiqiang
and
pengyiqiang
authored
refact(user_data): remove LV_USE_USER_DATA configuration (lvgl#4056)
Signed-off-by: pengyiqiang <[email protected]> Co-authored-by: pengyiqiang <[email protected]>
1 parent e26a46c commit afe29b7

34 files changed

+12
-113
lines changed

Kconfig

-4
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,6 @@ menu "LVGL configuration"
441441
bool "Enable float in built-in (v)snprintf functions"
442442
depends on !LV_SPRINTF_CUSTOM
443443

444-
config LV_USE_USER_DATA
445-
bool "Add a 'user_data' to drivers and objects."
446-
default y
447-
448444
config LV_ENABLE_GC
449445
bool "Enable garbage collector"
450446

demos/flex_layout/lv_demo_flex_layout_ctrl_pad.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "lv_demo_flex_layout_main.h"
1111

12-
#if LV_USE_DEMO_FLEX_LAYOUT && LV_USE_USER_DATA
12+
#if LV_USE_DEMO_FLEX_LAYOUT
1313

1414
/*********************
1515
* DEFINES

demos/flex_layout/lv_demo_flex_layout_flex_loader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "lv_demo_flex_layout_main.h"
1111

12-
#if LV_USE_DEMO_FLEX_LAYOUT && LV_USE_USER_DATA
12+
#if LV_USE_DEMO_FLEX_LAYOUT
1313

1414
/*********************
1515
* DEFINES

demos/flex_layout/lv_demo_flex_layout_main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "lv_demo_flex_layout_main.h"
1111
#include "lv_demo_flex_layout.h"
1212

13-
#if LV_USE_DEMO_FLEX_LAYOUT && LV_USE_USER_DATA
13+
#if LV_USE_DEMO_FLEX_LAYOUT
1414

1515
/*********************
1616
* DEFINES

demos/flex_layout/lv_demo_flex_layout_view.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "lv_demo_flex_layout_main.h"
1111

12-
#if LV_USE_DEMO_FLEX_LAYOUT && LV_USE_USER_DATA
12+
#if LV_USE_DEMO_FLEX_LAYOUT
1313

1414
/*********************
1515
* DEFINES

demos/flex_layout/lv_demo_flex_layout_view_child_node.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "lv_demo_flex_layout_main.h"
1111

12-
#if LV_USE_DEMO_FLEX_LAYOUT && LV_USE_USER_DATA
12+
#if LV_USE_DEMO_FLEX_LAYOUT
1313

1414
/*********************
1515
* DEFINES

demos/flex_layout/lv_demo_flex_layout_view_ctrl_pad.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "lv_demo_flex_layout_main.h"
1111

12-
#if LV_USE_DEMO_FLEX_LAYOUT && LV_USE_USER_DATA
12+
#if LV_USE_DEMO_FLEX_LAYOUT
1313

1414
/*********************
1515
* DEFINES

demos/lv_demos.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern "C" {
3535
#include "widgets/lv_demo_widgets.h"
3636
#endif
3737

38-
#if LV_USE_DEMO_FLEX_LAYOUT && LV_USE_USER_DATA
38+
#if LV_USE_DEMO_FLEX_LAYOUT
3939
#include "flex_layout/lv_demo_flex_layout.h"
4040
#endif
4141

env_support/cmsis-pack/lv_conf_cmsis.h

-2
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@
279279
*Only used if software rotation is enabled in the display driver.*/
280280
#define LV_DISP_ROT_MAX_BUF (10*1024)
281281

282-
#define LV_USE_USER_DATA 1
283-
284282
/*Garbage Collector settings
285283
*Used if lvgl is bound to higher level language and the memory is managed by that language*/
286284
#define LV_ENABLE_GC 0

examples/widgets/menu/lv_example_menu_3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "../../lv_examples.h"
2-
#if LV_USE_MENU && LV_USE_USER_DATA && LV_BUILD_EXAMPLES
2+
#if LV_USE_MENU && LV_BUILD_EXAMPLES
33

44
void lv_example_menu_3(void)
55
{

lv_conf_template.h

-2
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@
297297
*Only used if software rotation is enabled in the display driver.*/
298298
#define LV_DISP_ROT_MAX_BUF (10*1024)
299299

300-
#define LV_USE_USER_DATA 1
301-
302300
/*Garbage Collector settings
303301
*Used if lvgl is bound to higher level language and the memory is managed by that language*/
304302
#define LV_ENABLE_GC 0

src/core/lv_disp.c

-12
Original file line numberDiff line numberDiff line change
@@ -863,13 +863,7 @@ void lv_disp_set_user_data(lv_disp_t * disp, void * user_data)
863863
{
864864
if(!disp) disp = lv_disp_get_default();
865865
if(!disp) return;
866-
867-
#if LV_USE_USER_DATA
868866
disp->user_data = user_data;
869-
#else
870-
LV_UNUSED(user_data);
871-
LV_LOG_WARN("LV_USE_USER_DATA is not enabled");
872-
#endif
873867
}
874868

875869
void lv_disp_set_driver_data(lv_disp_t * disp, void * driver_data)
@@ -884,13 +878,7 @@ void * lv_disp_get_user_data(lv_disp_t * disp)
884878
{
885879
if(!disp) disp = lv_disp_get_default();
886880
if(!disp) return NULL;
887-
888-
#if LV_USE_USER_DATA
889881
return disp->user_data;
890-
#else
891-
LV_LOG_WARN("LV_USE_USER_DATA is no enabled");
892-
return NULL;
893-
#endif
894882
}
895883

896884
void * lv_disp_get_driver_data(lv_disp_t * disp)

src/core/lv_disp_private.h

-2
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ typedef struct _lv_disp_t {
125125

126126
void * driver_data; /**< Custom user data*/
127127

128-
#if LV_USE_USER_DATA
129128
void * user_data; /**< Custom user data*/
130-
#endif
131129

132130
lv_event_list_t event_list;
133131

src/core/lv_group.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ lv_group_t * lv_group_create(void)
6161
group->editing = 0;
6262
group->refocus_policy = LV_GROUP_REFOCUS_POLICY_PREV;
6363
group->wrap = 1;
64-
65-
#if LV_USE_USER_DATA
66-
group->user_data = NULL;
67-
#endif
64+
group->user_data = NULL;
6865

6966
return group;
7067
}

src/core/lv_group.h

-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ typedef struct _lv_group_t {
6565
targets are available in this direction (to allow edge feedback
6666
like a sound or a scroll bounce) */
6767

68-
#if LV_USE_USER_DATA
6968
void * user_data;
70-
#endif
7169

7270
uint8_t frozen : 1; /**< 1: can't focus to new object*/
7371
uint8_t editing : 1; /**< 1: Edit mode, 0: Navigate mode*/

src/core/lv_indev.c

-11
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,7 @@ void lv_indev_set_read_cb(lv_indev_t * indev, void (*read_cb)(struct _lv_indev_
259259
void lv_indev_set_user_data(lv_indev_t * indev, void * user_data)
260260
{
261261
if(indev == NULL) return;
262-
#if LV_USE_USER_DATA
263262
indev->user_data = user_data;
264-
#else
265-
LV_UNUSED(user_data);
266-
LV_LOG_WARN("LV_USE_USER_DATA is no enabled");
267-
#endif
268263
}
269264

270265
void lv_indev_set_driver_data(lv_indev_t * indev, void * driver_data)
@@ -312,13 +307,7 @@ void lv_indev_set_disp(lv_indev_t * indev, lv_disp_t * disp)
312307
void * lv_indev_get_user_data(const lv_indev_t * indev)
313308
{
314309
if(indev == NULL) return NULL;
315-
316-
#if LV_USE_USER_DATA
317310
return indev->user_data;
318-
#else
319-
LV_LOG_WARN("LV_USE_USER_DATA is no enabled");
320-
return NULL;
321-
#endif
322311
}
323312

324313
void * lv_indev_get_driver_data(const lv_indev_t * indev)

src/core/lv_indev_private.h

-3
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ typedef struct _lv_indev_t {
4545
uint32_t longpr_rep_timestamp; /**< Long press repeat time stamp*/
4646

4747
void * driver_data;
48-
49-
#if LV_USE_USER_DATA
5048
void * user_data;
51-
#endif
5249

5350
/**< Pointer to the assigned display*/
5451
struct _lv_disp_t * disp;

src/core/lv_obj.c

-2
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,7 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
994994
ts[tsi].delay = tr->delay;
995995
ts[tsi].path_cb = tr->path_xcb;
996996
ts[tsi].prop = tr->props[j];
997-
#if LV_USE_USER_DATA
998997
ts[tsi].user_data = tr->user_data;
999-
#endif
1000998
ts[tsi].selector = obj_style->selector;
1001999
tsi++;
10021000
}

src/core/lv_obj.h

-6
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ typedef struct _lv_obj_t {
175175
struct _lv_obj_t * parent;
176176
_lv_obj_spec_attr_t * spec_attr;
177177
_lv_obj_style_t * styles;
178-
#if LV_USE_USER_DATA
179178
void * user_data;
180-
#endif
181179
lv_area_t coords;
182180
lv_obj_flag_t flags;
183181
lv_state_t state;
@@ -262,12 +260,10 @@ void lv_obj_clear_state(lv_obj_t * obj, lv_state_t state);
262260
* @param obj pointer to an object
263261
* @param user_data pointer to the new user_data.
264262
*/
265-
#if LV_USE_USER_DATA
266263
static inline void lv_obj_set_user_data(lv_obj_t * obj, void * user_data)
267264
{
268265
obj->user_data = user_data;
269266
}
270-
#endif
271267

272268
/*=======================
273269
* Getter functions
@@ -316,12 +312,10 @@ lv_group_t * lv_obj_get_group(const lv_obj_t * obj);
316312
* @param obj pointer to an object
317313
* @return the pointer to the user_data of the object
318314
*/
319-
#if LV_USE_USER_DATA
320315
static inline void * lv_obj_get_user_data(lv_obj_t * obj)
321316
{
322317
return obj->user_data;
323318
}
324-
#endif
325319

326320
/*=======================
327321
* Other functions

src/core/lv_obj_class.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ typedef struct _lv_obj_class_t {
5656
const struct _lv_obj_class_t * base_class;
5757
void (*constructor_cb)(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * obj);
5858
void (*destructor_cb)(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * obj);
59-
#if LV_USE_USER_DATA
60-
void * user_data;
61-
#endif
6259
void (*event_cb)(const struct _lv_obj_class_t * class_p,
6360
struct _lv_event_t * e); /**< Widget type specific event function*/
61+
void * user_data;
6462
lv_coord_t width_def;
6563
lv_coord_t height_def;
6664
uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/

src/core/lv_obj_style.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,7 @@ void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t
428428
lv_anim_set_delay(&a, tr_dsc->delay);
429429
lv_anim_set_path_cb(&a, tr_dsc->path_cb);
430430
lv_anim_set_early_apply(&a, false);
431-
#if LV_USE_USER_DATA
432-
a.user_data = tr_dsc->user_data;
433-
#endif
431+
lv_anim_set_user_data(&a, tr_dsc->user_data);
434432
lv_anim_start(&a);
435433
}
436434

src/core/lv_obj_style.h

-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ typedef struct {
5555
lv_style_selector_t selector;
5656
lv_style_prop_t prop;
5757
lv_anim_path_cb_t path_cb;
58-
#if LV_USE_USER_DATA
5958
void * user_data;
60-
#endif
6159
} _lv_obj_style_transition_dsc_t;
6260

6361
/**********************

src/draw/lv_draw.h

-3
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ typedef struct _lv_draw_ctx_t {
195195
*/
196196
size_t layer_instance_size;
197197

198-
#if LV_USE_USER_DATA
199198
void * user_data;
200-
#endif
201-
202199
} lv_draw_ctx_t;
203200

204201
/**********************

src/draw/lv_img_decoder.h

-3
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ typedef struct _lv_img_decoder_t {
8888
lv_img_decoder_open_f_t open_cb;
8989
lv_img_decoder_read_line_f_t read_line_cb;
9090
lv_img_decoder_close_f_t close_cb;
91-
92-
#if LV_USE_USER_DATA
9391
void * user_data;
94-
#endif
9592
} lv_img_decoder_t;
9693

9794

src/font/lv_font.h

-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ typedef struct _lv_font_t {
7878

7979
const void * dsc; /**< Store implementation specific or run_time data or caching here*/
8080
const struct _lv_font_t * fallback; /**< Fallback font for missing glyph. Resolved recursively */
81-
#if LV_USE_USER_DATA
8281
void * user_data; /**< Custom user data for font.*/
83-
#endif
8482
} lv_font_t;
8583

8684
/**********************

src/lv_conf_internal.h

-12
Original file line numberDiff line numberDiff line change
@@ -905,18 +905,6 @@
905905
#endif
906906
#endif
907907

908-
#ifndef LV_USE_USER_DATA
909-
#ifdef _LV_KCONFIG_PRESENT
910-
#ifdef CONFIG_LV_USE_USER_DATA
911-
#define LV_USE_USER_DATA CONFIG_LV_USE_USER_DATA
912-
#else
913-
#define LV_USE_USER_DATA 0
914-
#endif
915-
#else
916-
#define LV_USE_USER_DATA 1
917-
#endif
918-
#endif
919-
920908
/*Garbage Collector settings
921909
*Used if lvgl is bound to higher level language and the memory is managed by that language*/
922910
#ifndef LV_ENABLE_GC

src/misc/lv_anim.h

+1-7
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ typedef struct _lv_anim_t {
7777
lv_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
7878
lv_anim_deleted_cb_t deleted_cb; /**< Call it when the animation is deleted*/
7979
lv_anim_get_value_cb_t get_value_cb; /**< Get the current value in relative mode*/
80-
#if LV_USE_USER_DATA
81-
void * user_data; /**< Custom user data*/
82-
#endif
80+
void * user_data; /**< Custom user data*/
8381
lv_anim_path_cb_t path_cb; /**< Describe the path (curve) of animations*/
8482
int32_t start_value; /**< Start value*/
8583
int32_t current_value; /**< Current value*/
@@ -296,12 +294,10 @@ static inline void lv_anim_set_early_apply(lv_anim_t * a, bool en)
296294
* @param a pointer to an initialized `lv_anim_t` variable
297295
* @param user_data pointer to the new user_data.
298296
*/
299-
#if LV_USE_USER_DATA
300297
static inline void lv_anim_set_user_data(lv_anim_t * a, void * user_data)
301298
{
302299
a->user_data = user_data;
303300
}
304-
#endif
305301

306302
/**
307303
* Create an animation
@@ -352,12 +348,10 @@ static inline uint16_t lv_anim_get_repeat_count(lv_anim_t * a)
352348
* @param a pointer to an initialized `lv_anim_t` variable
353349
* @return the pointer to the custom user_data of the animation
354350
*/
355-
#if LV_USE_USER_DATA
356351
static inline void * lv_anim_get_user_data(lv_anim_t * a)
357352
{
358353
return a->user_data;
359354
}
360-
#endif
361355

362356
/**
363357
* Delete an animation of a variable with a given animator function

src/misc/lv_fs.h

-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ typedef struct _lv_fs_drv_t {
8383
lv_fs_res_t (*dir_read_cb)(struct _lv_fs_drv_t * drv, void * rddir_p, char * fn);
8484
lv_fs_res_t (*dir_close_cb)(struct _lv_fs_drv_t * drv, void * rddir_p);
8585

86-
#if LV_USE_USER_DATA
8786
void * user_data; /**< Custom file user data*/
88-
#endif
8987
} lv_fs_drv_t;
9088

9189
typedef struct {

src/misc/lv_style.c

-4
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,7 @@ void lv_style_transition_dsc_init(lv_style_transition_dsc_t * tr, const lv_style
308308
tr->path_xcb = path_cb == NULL ? lv_anim_path_linear : path_cb;
309309
tr->time = time;
310310
tr->delay = delay;
311-
#if LV_USE_USER_DATA
312311
tr->user_data = user_data;
313-
#else
314-
LV_UNUSED(user_data);
315-
#endif
316312
}
317313

318314
lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)

src/misc/lv_style.h

-2
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,7 @@ typedef uint8_t lv_style_res_t;
304304
*/
305305
typedef struct {
306306
const lv_style_prop_t * props; /**< An array with the properties to animate.*/
307-
#if LV_USE_USER_DATA
308307
void * user_data; /**< A custom user data that will be passed to the animation's user_data */
309-
#endif
310308
lv_anim_path_cb_t path_xcb; /**< A path for the animation.*/
311309
uint32_t time; /**< Duration of the transition in [ms]*/
312310
uint32_t delay; /**< Delay before the transition in [ms]*/

0 commit comments

Comments
 (0)