fix(user_data): move user_data from spec_attr to lv_obj_t
It allows more straightforward access to it in case of binding generation
This commit is contained in:
@@ -1448,10 +1448,8 @@ void lv_obj_get_type(const lv_obj_t * obj, lv_obj_type_t * buf)
|
||||
*/
|
||||
lv_obj_user_data_t lv_obj_get_user_data(const lv_obj_t * obj)
|
||||
{
|
||||
static lv_obj_user_data_t empty = {0};
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
if(obj->spec_attr) return obj->spec_attr->user_data;
|
||||
else return empty;
|
||||
return obj->user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1463,8 +1461,7 @@ lv_obj_user_data_t * lv_obj_get_user_data_ptr(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(obj->spec_attr) return obj->spec_attr->user_data;
|
||||
return &obj->spec_attr->user_data;
|
||||
return &obj->user_data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1476,8 +1473,7 @@ void lv_obj_set_user_data(lv_obj_t * obj, lv_obj_user_data_t data)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||
|
||||
if(obj->spec_attr == NULL) lv_obj_allocate_spec_attr(obj);
|
||||
_lv_memcpy(&obj->spec_attr->user_data, &data, sizeof(lv_obj_user_data_t));
|
||||
_lv_memcpy(&obj->user_data, &data, sizeof(lv_obj_user_data_t));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -201,10 +201,6 @@ typedef struct {
|
||||
void * group_p;
|
||||
#endif
|
||||
|
||||
#if LV_USE_USER_DATA
|
||||
lv_obj_user_data_t user_data; /**< Custom user data for object. */
|
||||
#endif
|
||||
|
||||
const lv_grid_t * grid;
|
||||
|
||||
lv_event_cb_t event_cb; /**< Event callback function */
|
||||
@@ -237,6 +233,11 @@ struct _lv_obj_t {
|
||||
lv_design_cb_t design_cb; /**< Object type specific design function*/
|
||||
|
||||
void * ext_attr; /**< Object type specific extended data*/
|
||||
|
||||
#if LV_USE_USER_DATA
|
||||
lv_obj_user_data_t user_data; /**< Custom user data for object. */
|
||||
#endif
|
||||
|
||||
lv_style_list_t style_list;
|
||||
|
||||
/*Attributes and states*/
|
||||
|
||||
Reference in New Issue
Block a user