make style API C++ compatible

This commit is contained in:
Gabor Kiss-Vamosi
2020-03-05 15:39:11 +01:00
parent d79fb70aaa
commit 3dc8b9ab0d
9 changed files with 404 additions and 96 deletions

1
lvgl.h
View File

@@ -83,6 +83,7 @@ extern "C" {
#define LVGL_VERSION_PATCH 0
#define LVGL_VERSION_INFO "dev"
#define LV_BUILD_TEST 1
/**********************
* TYPEDEFS
**********************/

View File

@@ -61,13 +61,13 @@ typedef struct {
lv_color_t _color;
lv_style_int_t _int;
lv_opa_t _opa;
const void * _ptr;
lv_style_fptr_dptr_t _ptr;
} start_value;
union {
lv_color_t _color;
lv_style_int_t _int;
lv_opa_t _opa;
const void * _ptr;
lv_style_fptr_dptr_t _ptr;
} end_value;
} lv_style_trans_t;
@@ -1252,15 +1252,15 @@ void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t part, lv_style_property
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param the value to set
* @param value the value to set
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, const void * p)
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t prop, lv_style_fptr_dptr_t value)
{
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
lv_style_list_set_local_ptr(style_dsc, prop, p);
lv_style_list_set_local_ptr(style_dsc, prop, value);
#if LV_USE_ANIMATION
trans_del(obj, part, prop, NULL);
#endif
@@ -2410,14 +2410,14 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
lv_style_fptr_dptr_t _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_property_t prop_ori = prop;
lv_style_attr_t attr;
attr.full = prop_ori >> 8;
void * value_act;
lv_style_fptr_dptr_t value_act;
lv_res_t res = LV_RES_INV;
const lv_obj_t * parent = obj;
while(parent) {
@@ -2443,17 +2443,22 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_
/*Handle unset values*/
prop = prop & (~LV_STYLE_STATE_MASK);
lv_style_fptr_dptr_t fd;
fd.dptr = NULL;
fd.fptr = NULL;
switch(prop) {
case LV_STYLE_TEXT_FONT:
case LV_STYLE_VALUE_FONT:
return LV_THEME_DEFAULT_FONT_NORMAL;
fd.dptr = LV_THEME_DEFAULT_FONT_NORMAL;
return fd;
#if LV_USE_ANIMATION
case LV_STYLE_TRANSITION_PATH:
return lv_anim_path_linear;
fd.fptr = (lv_style_prop_cb_t)lv_anim_path_linear;
return fd;
#endif
}
return NULL;
return fd;
}
/**
@@ -3650,22 +3655,22 @@ static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop,
else { /*Ptr*/
obj->state = prev_state;
style_list->skip_trans = 1;
const void * p1 = _lv_obj_get_style_ptr(obj, part, prop);
lv_style_fptr_dptr_t fd1 = _lv_obj_get_style_ptr(obj, part, prop);
obj->state = new_state;
const void * p2 = _lv_obj_get_style_ptr(obj, part, prop);
lv_style_fptr_dptr_t fd2 = _lv_obj_get_style_ptr(obj, part, prop);
style_list->skip_trans = 0;
if(p1 == p2) return NULL;
if(memcmp(&fd1, &fd2, sizeof(lv_style_fptr_dptr_t)) == 0) return NULL;
obj->state = prev_state;
p1 = _lv_obj_get_style_ptr(obj, part, prop);
fd1 = _lv_obj_get_style_ptr(obj, part, prop);
obj->state = new_state;
_lv_style_set_ptr(style_trans, prop, p1); /*Be sure `trans_style` has a valid value */
_lv_style_set_ptr(style_trans, prop, fd1); /*Be sure `trans_style` has a valid value */
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return NULL;
tr->start_value._ptr = p1;
tr->end_value._ptr = p2;
tr->start_value._ptr = fd1;
tr->end_value._ptr = fd2;
}
return tr;
@@ -3727,7 +3732,7 @@ static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v)
_lv_style_set_opa(style, tr->prop, x);
}
else {
const void * x;
lv_style_fptr_dptr_t x;
if(v < 128) x = tr->start_value._ptr;
else x = tr->end_value._ptr;
_lv_style_set_ptr(style, tr->prop, x);

View File

@@ -570,7 +570,46 @@ void _lv_obj_set_style_local_opa(lv_obj_t * obj, uint8_t type, lv_style_property
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value);
void _lv_obj_set_style_local_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_fptr_dptr_t value);
/**
* Set a local style property of a part of an object in a given state.
* @param obj pointer to an object
* @param part the part of the object which style property should be set.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param the value to set
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_trasition_path()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_obj_set_style_local_func_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, lv_style_prop_cb_t value)
{
lv_style_fptr_dptr_t fd;
fd.fptr = value;
fd.dptr = NULL;
_lv_obj_set_style_local_ptr(obj, type, prop, fd);
}
/**
* Set a local style property of a part of an object in a given state.
* @param obj pointer to an object
* @param part the part of the object which style property should be set.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param the value to set
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_obj_set_style_local_data_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value)
{
lv_style_fptr_dptr_t fd;
fd.fptr = NULL;
fd.dptr = value;
_lv_obj_set_style_local_ptr(obj, type, prop, fd);
}
/**
* Remove a local style property from a part of an object with a given state.
@@ -1034,7 +1073,50 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
* For example: `lv_obj_style_get_border_opa()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
lv_style_fptr_dptr_t _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop);
/**
* Get a style property of a part of an object in the object's current state.
* If there is a running transitions it is taken into account
* @param obj pointer to an object
* @param part the part of the object which style property should be get.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop the property to get. E.g. `LV_STYLE_TEXT_FONT`.
* The state of the object will be added internally
* @return the value of the property of the given part in the current state.
* If the property is not found a default value will be returned.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_trasition_path()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline lv_style_prop_cb_t _lv_obj_get_style_func_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_fptr_dptr_t fd;
fd = _lv_obj_get_style_ptr(obj, part, prop);
return fd.fptr;
}
/**
* Get a style property of a part of an object in the object's current state.
* If there is a running transitions it is taken into account
* @param obj pointer to an object
* @param part the part of the object which style property should be get.
* E.g. `LV_OBJ_PART_MAIN`, `LV_BTN_PART_MAIN`, `LV_SLIDER_PART_KNOB`
* @param prop the property to get. E.g. `LV_STYLE_TEXT_FONT`.
* The state of the object will be added internally
* @return the value of the property of the given part in the current state.
* If the property is not found a default value will be returned.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_obj_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline const void * _lv_obj_get_style_data_ptr(const lv_obj_t * obj, uint8_t part, lv_style_property_t prop)
{
lv_style_fptr_dptr_t fd;
fd = _lv_obj_get_style_ptr(obj, part, prop);
return fd.dptr;
}
/**

View File

@@ -58,25 +58,69 @@ extern "C" {
* `lv_style_set_border_width(&style1, LV_STATE_PRESSED, 2);`
*/
#ifdef __cplusplus
#define FUNC_PTR_CAST(v) reinterpret_cast<lv_style_prop_cb_t>(v)
#else
#define FUNC_PTR_CAST(v) (lv_style_prop_cb_t)v
#endif
#define _LV_OBJ_STYLE_DECLARE_GET_scalar(prop_name, func_name, value_type, style_type) \
#define _OBJ_GET_STYLE_scalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
#define _LV_OBJ_STYLE_DECLARE_GET_nonscalar(prop_name, func_name, value_type, style_type) \
#define _OBJ_GET_STYLE_func_ptr(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return (value_type) _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
#define _OBJ_GET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \
static inline value_type lv_obj_get_style_##func_name (const lv_obj_t * obj, uint8_t part) \
{ \
return _lv_obj_get_style##style_type (obj, part, LV_STYLE_##prop_name); \
}
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
_LV_OBJ_STYLE_DECLARE_GET_##scalar(prop_name, func_name, value_type, style_type) \
#define _OBJ_SET_STYLE_LOCAL_scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_LOCAL_nonscalar(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_LOCAL_func_ptr(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_set_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, value_type value) \
{ \
_lv_obj_set_style_local##style_type (obj, part, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), FUNC_PTR_CAST(value)); \
}
#define _OBJ_SET_STYLE_scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_nonscalar(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
#define _OBJ_SET_STYLE_func_ptr(prop_name, func_name, value_type, style_type) \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), FUNC_PTR_CAST(value)); \
} \
#define _LV_OBJ_STYLE_SET_GET_DECLARE(prop_name, func_name, value_type, style_type, scalar) \
_OBJ_GET_STYLE_##scalar(prop_name, func_name, value_type, style_type) \
_OBJ_SET_STYLE_LOCAL_##scalar(prop_name, func_name, value_type, style_type) \
static inline void lv_obj_get_style_local_##func_name (lv_obj_t * obj, uint8_t part, lv_state_t state, void * res) \
{ \
_lv_style_get##style_type (lv_obj_get_local_style(obj, part), LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
@@ -89,10 +133,7 @@ extern "C" {
{ \
return _lv_style_get##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), res); \
} \
static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t state, value_type value) \
{ \
_lv_style_set##style_type (style, LV_STYLE_##prop_name | (state << LV_STYLE_STATE_POS), value); \
}
_OBJ_SET_STYLE_##scalar(prop_name, func_name, value_type, style_type)
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(CLIP_CORNER, clip_corner, bool, _int, scalar)
@@ -135,7 +176,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_BLEND_MODE, pattern_blend_mode, lv_blend_m
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR, pattern_recolor, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_OPA, pattern_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_RECOLOR_OPA, pattern_recolor_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_IMAGE, pattern_image, const void *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PATTERN_IMAGE, pattern_image, const void *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LETTER_SPACE, value_letter_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_LINE_SPACE, value_line_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_BLEND_MODE, value_blend_mode, lv_blend_mode_t, _int, scalar)
@@ -144,8 +185,8 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OFS_Y, value_ofs_y, lv_style_int_t, _int, sc
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_ALIGN, value_align, lv_align_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_COLOR, value_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_OPA, value_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_FONT, value_font, const lv_font_t *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(VALUE_STR, value_str, const char *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LETTER_SPACE, text_letter_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_LINE_SPACE, text_line_space, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_DECOR, text_decor, lv_text_decor_t, _int, scalar)
@@ -153,7 +194,7 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_BLEND_MODE, text_blend_mode, lv_blend_mode_t,
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_COLOR, text_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_SEL_COLOR, text_sel_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_OPA, text_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TEXT_FONT, text_font, const lv_font_t *, _data_ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_WIDTH, line_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_BLEND_MODE, line_blend_mode, lv_blend_mode_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(LINE_DASH_WIDTH, line_dash_width, lv_style_int_t, _int, scalar)
@@ -174,9 +215,9 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_4, transition_prop_4, lv_style_int
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_5, transition_prop_5, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PROP_6, transition_prop_6, lv_style_int_t, _int, scalar)
#if LV_USE_ANIMATION
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t, _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, lv_anim_path_cb_t, _func_ptr, func_ptr)
#else
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path, void *, _ptr, scalar) /*For compatibility*/
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_PATH, transition_path,lv_style_prop_cb_t, _func_ptr, func_ptr) /*For compatibility*/
#endif
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar)

View File

@@ -112,7 +112,7 @@ bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
if((prop & 0xF) < LV_STYLE_ID_COLOR) prop_size += sizeof(lv_style_int_t);
else if((prop & 0xF) < LV_STYLE_ID_OPA) prop_size += sizeof(lv_color_t);
else if((prop & 0xF) < LV_STYLE_ID_PTR) prop_size += sizeof(lv_opa_t);
else prop_size += sizeof(const void *);
else prop_size += sizeof(lv_style_fptr_dptr_t);
/*Move the props to fill the space of the property to delete*/
uint32_t i;
@@ -341,7 +341,7 @@ uint16_t lv_style_get_mem_size(const lv_style_t * style)
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(void *);
else i += sizeof(lv_style_fptr_dptr_t);
i += sizeof(lv_style_property_t);
}
@@ -499,7 +499,7 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property is really has pointer type
*/
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p)
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, lv_style_fptr_dptr_t p)
{
LV_ASSERT_STYLE(style);
@@ -513,26 +513,26 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state) {
memcpy(style->map + id + sizeof(lv_style_property_t), &p, sizeof(void *));
memcpy(style->map + id + sizeof(lv_style_property_t), &p, sizeof(lv_style_fptr_dptr_t));
return;
}
}
/*Add new property if not exists yet*/
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(void *));
uint8_t new_prop_size = (sizeof(lv_style_property_t) + sizeof(lv_style_fptr_dptr_t));
lv_style_property_t end_mark = _LV_STYLE_CLOSEING_PROP;
uint8_t end_mark_size = sizeof(end_mark);
uint16_t size = lv_style_get_mem_size(style);
if(size == 0) size += end_mark_size;
size += sizeof(lv_style_property_t) + sizeof(void *);
size += sizeof(lv_style_property_t) + sizeof(lv_style_fptr_dptr_t);
style->map = lv_mem_realloc(style->map, size);
LV_ASSERT_MEM(style->map);
if(style == NULL) return;
memcpy(style->map + size - new_prop_size - end_mark_size, &prop, sizeof(lv_style_property_t));
memcpy(style->map + size - sizeof(void *) - end_mark_size, &p, sizeof(void *));
memcpy(style->map + size - sizeof(lv_style_fptr_dptr_t) - end_mark_size, &p, sizeof(lv_style_fptr_dptr_t));
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
}
@@ -654,7 +654,7 @@ int16_t _lv_style_get_color(const lv_style_t * style, lv_style_property_t prop,
*/
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * v_res)
{
void ** res = (void *)v_res;
lv_style_fptr_dptr_t * res = (lv_style_fptr_dptr_t *)v_res;
if(style == NULL) return -1;
if(style->map == NULL) return -1;
int32_t id = get_property_index(style, prop);
@@ -662,7 +662,7 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo
return -1;
}
else {
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(void *));
memcpy(res, &style->map[id + sizeof(lv_style_property_t)], sizeof(lv_style_fptr_dptr_t));
lv_style_attr_t attr_act;
attr_act.full = style->map[id + 1];
@@ -788,7 +788,7 @@ void lv_style_list_set_local_color(lv_style_list_t * list, lv_style_property_t p
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value)
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t value)
{
LV_ASSERT_STYLE_LIST(list);
@@ -796,6 +796,8 @@ void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t pro
_lv_style_set_ptr(local, prop, value);
}
/**
* Get an integer typed property from a style list.
* It will return the property which match best with given state.
@@ -959,7 +961,7 @@ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop,
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
*/
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, void ** res)
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t * res)
{
LV_ASSERT_STYLE_LIST(list);
@@ -972,7 +974,9 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop,
int16_t weight = -1;
void * value_act = NULL;
lv_style_fptr_dptr_t value_act;
value_act.dptr = NULL;
value_act.fptr = NULL;
int16_t ci;
for(ci = 0; ci < list->style_cnt; ci++) {
@@ -980,17 +984,20 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop,
int16_t weight_act = _lv_style_get_ptr(class, prop, &value_act);
/*On perfect match return the value immediately*/
if(weight_act == weight_goal) {
*res = value_act;
res->dptr = value_act.dptr;
res->fptr = value_act.fptr;
return LV_RES_OK;
}
else if(list->has_trans && weight_act >= 0 && ci == 0 && !list->skip_trans) {
*res = value_act;
res->dptr = value_act.dptr;
res->fptr = value_act.fptr;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) {
weight = weight_act;
*res = value_act;
res->dptr = value_act.dptr;
res->fptr = value_act.fptr;
}
}
@@ -1050,7 +1057,7 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
if((style->map[i] & 0xF) < LV_STYLE_ID_COLOR) i += sizeof(lv_style_int_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_OPA) i += sizeof(lv_color_t);
else if((style->map[i] & 0xF) < LV_STYLE_ID_PTR) i += sizeof(lv_opa_t);
else i += sizeof(void *);
else i += sizeof(lv_style_fptr_dptr_t);
i += sizeof(lv_style_property_t);
}

View File

@@ -210,6 +210,13 @@ typedef struct {
typedef int16_t lv_style_int_t;
typedef void(*lv_style_prop_cb_t)(void);
typedef union {
lv_style_prop_cb_t fptr;
const void * dptr;
}lv_style_fptr_dptr_t;
typedef struct {
lv_style_t ** style_list;
@@ -358,7 +365,44 @@ void _lv_style_set_opa(lv_style_t * style, lv_style_property_t prop, lv_opa_t op
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void * p);
void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, lv_style_fptr_dptr_t p);
/**
* Set a function pointer typed property in a style.
* @param style pointer to a style where the property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note shouldn't be used directly. Use the specific property set functions instead.
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_style_set_func_ptr(lv_style_t * style, lv_style_property_t prop, lv_style_prop_cb_t p)
{
lv_style_fptr_dptr_t fd;
fd.dptr = NULL;
fd.fptr = p;
_lv_style_set_ptr(style, prop, fd);
}
/**
* Set a data pointer typed property in a style.
* @param style pointer to a style where the property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note shouldn't be used directly. Use the specific property set functions instead.
* For example: `lv_style_set_border_width()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void _lv_style_set_data_ptr(lv_style_t * style, lv_style_property_t prop, const void * p)
{
lv_style_fptr_dptr_t fd;
fd.fptr = NULL;
fd.dptr = p;
_lv_style_set_ptr(style, prop, fd);
}
/**
* Get an integer typed property from a style.
@@ -420,6 +464,57 @@ int16_t _lv_style_get_opa(const lv_style_t * style, lv_style_property_t prop, vo
*/
int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * res);
/**
* Get a pointer typed property from a style.
* @param style pointer to a style from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result value
* @return -1: the property wasn't found in the style.
* The matching state bits of the desired state (in `prop`) and the best matching property's state
* Higher value means match in higher precedence state.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_style_get_transition_path()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline int16_t _lv_style_get_func_ptr(const lv_style_t * style, lv_style_property_t prop, void * res)
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = _lv_style_get_ptr(style, prop, &fd_res);
lv_style_prop_cb_t * res2 = (lv_style_prop_cb_t *)res;
*res2 = fd_res.fptr;
return r;
}
/**
* Get a pointer typed property from a style.
* @param style pointer to a style from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result value
* @return -1: the property wasn't found in the style.
* The matching state bits of the desired state (in `prop`) and the best matching property's state
* Higher value means match in higher precedence state.
* @note shouldn't be used directly. Use the specific property get functions instead.
* For example: `lv_style_get_text_font()`
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline int16_t _lv_style_get_data_ptr(const lv_style_t * style, lv_style_property_t prop, void * res)
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = _lv_style_get_ptr(style, prop, &fd_res);
void** res2 = (void**)res;
*res2 = (void*)fd_res.dptr;
return r;
}
/**
* Get the local style of a style list
* @param list pointer to a style list where the local property should be set
@@ -479,8 +574,39 @@ void lv_style_list_set_local_opa(lv_style_list_t * list, lv_style_property_t pro
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value);
void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t value);
/**
* Set a local pointer typed property in a style list.
* @param list pointer to a style list where the local property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void lv_style_list_set_local_func_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_prop_cb_t value)
{
lv_style_fptr_dptr_t fd;
fd.dptr = NULL;
fd.fptr = value;
lv_style_list_set_local_ptr(list, prop, fd);
}
/**
* Set a local pointer typed property in a style list.
* @param list pointer to a style list where the local property should be set
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param value the value to set
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline void lv_style_list_set_local_data_ptr(lv_style_list_t * list, lv_style_property_t prop, const void * value)
{
lv_style_fptr_dptr_t fd;
fd.fptr = NULL;
fd.dptr = value;
lv_style_list_set_local_ptr(list, prop, fd);
}
/**
* Get an integer typed property from a style list.
* It will return the property which match best with given state.
@@ -531,8 +657,54 @@ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop,
* @return LV_RES_OK: there was a matching property in the list
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
* @note Do not use this function directly. Use `lv_style_list_get_func_ptr` or `lv_style_list_get_data_ptr`
*/
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, void ** res);
lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, lv_style_fptr_dptr_t * res);
/**
* Get a function pointer typed property from a style list.
* It will return the property which match best with given state.
* @param list pointer to a style list from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TRANSITION_PATH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result
* @return LV_RES_OK: there was a matching property in the list
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline lv_res_t lv_style_list_get_func_ptr(lv_style_list_t * list, lv_style_property_t prop, void (**res)(void))
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = lv_style_list_get_ptr(list, prop, &fd_res);
*res = fd_res.fptr;
return r;
}
/**
* Get a data pointer typed property from a style list.
* It will return the property which match best with given state.
* @param list pointer to a style list from where the property should be get
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @param res pointer to a buffer to store the result
* @return LV_RES_OK: there was a matching property in the list
* LV_RES_INV: there was NO matching property in the list
* @note for performance reasons it's not checked if the property really has pointer type
*/
static inline lv_res_t lv_style_list_get_data_ptr(lv_style_list_t * list, lv_style_property_t prop, const void ** res)
{
lv_style_fptr_dptr_t fd_res;
fd_res.dptr = NULL;
fd_res.fptr = NULL;
lv_res_t r = lv_style_list_get_ptr(list, prop, &fd_res);
*res = fd_res.dptr;
return r;
}
/*************************
* GLOBAL VARIABLES

View File

@@ -1708,8 +1708,8 @@ static void refr_cursor_area(lv_obj_t * ta)
{
lv_textarea_ext_t * ext = lv_obj_get_ext_attr(ta);
const lv_font_t * font = _lv_obj_get_style_ptr(ta, LV_TEXTAREA_PART_BG, LV_STYLE_TEXT_FONT);
lv_style_int_t line_space = _lv_obj_get_style_int(ta, LV_TEXTAREA_PART_BG, LV_STYLE_TEXT_LINE_SPACE);
const lv_font_t * font = lv_obj_get_style_text_font(ta, LV_TEXTAREA_PART_BG);
lv_style_int_t line_space = lv_obj_get_style_text_line_space(ta, LV_TEXTAREA_PART_BG);
uint16_t cur_pos = lv_textarea_get_cursor_pos(ta);
const char * txt = lv_label_get_text(ext->label);

View File

@@ -73,7 +73,7 @@ static void empty_style(void)
lv_res_t found;
lv_style_int_t value;
lv_opa_t opa;
void * ptr;
const void * ptr;
lv_color_t color;
lv_test_print("Get a properties from an empty style");
@@ -84,7 +84,7 @@ static void empty_style(void)
found = lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property");
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'ptr' property");
found = lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
@@ -108,7 +108,7 @@ static void add_remove_read_prop(void)
lv_res_t found;
lv_style_int_t value;
lv_opa_t opa;
void * ptr;
const void * ptr;
lv_color_t color;
lv_test_print("Add an empty style and read properties");
@@ -119,7 +119,7 @@ static void add_remove_read_prop(void)
found = lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'opa' property");
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'ptr' property");
found = lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
@@ -128,7 +128,7 @@ static void add_remove_read_prop(void)
lv_test_print("Set properties and read back the values");
_lv_style_set_int(&style, LV_STYLE_TEXT_LINE_SPACE, 5);
_lv_style_set_opa(&style, LV_STYLE_BG_OPA, LV_OPA_50);
_lv_style_set_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_data_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_color(&style, LV_STYLE_BG_COLOR, LV_COLOR_RED);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -139,7 +139,7 @@ static void add_remove_read_prop(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'opa' property");
lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property");
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property");
@@ -155,7 +155,7 @@ static void add_remove_read_prop(void)
found = lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property from a reseted style");
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'ptr' property from a reseted style");
found = lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
@@ -186,14 +186,14 @@ static void cascade(void)
lv_res_t found;
lv_style_int_t value;
lv_opa_t opa;
void * ptr;
const void * ptr;
lv_color_t color;
lv_test_print("Read properties set only in the firstly added style");
_lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5);
_lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50);
_lv_style_set_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_data_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
_lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_RED);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -204,7 +204,7 @@ static void cascade(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property");
lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property");
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property");
@@ -216,7 +216,7 @@ static void cascade(void)
_lv_style_set_int(&style_second, LV_STYLE_TEXT_LINE_SPACE, 10);
_lv_style_set_opa(&style_second, LV_STYLE_BG_OPA, LV_OPA_60);
_lv_style_set_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1);
_lv_style_set_data_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1);
_lv_style_set_color(&style_second, LV_STYLE_BG_COLOR, LV_COLOR_BLUE);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -227,7 +227,7 @@ static void cascade(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'opa' property");
lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an overwritten 'opa' property");
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 1, ptr, "Get the value of an overwritten 'ptr' property");
@@ -239,7 +239,7 @@ static void cascade(void)
lv_test_print("Overwrite the properties with the local style");
lv_style_list_set_local_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, 20);
lv_style_list_set_local_opa(&style_list, LV_STYLE_BG_OPA, LV_OPA_70);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 2);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 2);
lv_style_list_set_local_color(&style_list, LV_STYLE_BG_COLOR, LV_COLOR_LIME);
found = lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
@@ -250,7 +250,7 @@ static void cascade(void)
lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'opa' property");
lv_test_assert_int_eq(LV_OPA_70, opa, "Get the value of a local 'opa' property");
found = lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
found = lv_style_list_get_data_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'ptr' property");
lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 2, ptr, "Get the value of a local'ptr' property");
@@ -469,17 +469,17 @@ static void mem_leak(void)
lv_test_print("Use local style");
lv_mem_monitor(&mon_start);
for(i = 0; i < 100; i++) {
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_reset(&style_list);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_reset(&style_list);
}
@@ -558,7 +558,7 @@ static void mem_leak(void)
for(i = 0; i < 100; i++) {
if(i % 2 == 0) {
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
}
_lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
@@ -570,7 +570,7 @@ static void mem_leak(void)
if(i % 4 == 0) {
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
}
lv_style_list_remove_style(&style_list, &style1);
@@ -585,7 +585,7 @@ static void mem_leak(void)
lv_style_list_add_style(&style_list, &style2);
if(i % 8 == 0) {
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
}
lv_style_list_add_style(&style_list, &style2);
@@ -603,14 +603,14 @@ static void mem_leak(void)
_lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12);
_lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 23);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_set_local_data_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
lv_style_list_add_style(&style_list, &style3);
lv_style_list_add_style(&style_list, &style2);

View File

@@ -26,7 +26,7 @@ int main(void)
static void hal_init(void)
{
static lv_disp_buf_t disp_buf;
lv_color_t * disp_buf1 = malloc(LV_HOR_RES * LV_VER_RES * sizeof(lv_color_t));
lv_color_t * disp_buf1 = (lv_color_t *)malloc(LV_HOR_RES * LV_VER_RES * sizeof(lv_color_t));
lv_disp_buf_init(&disp_buf, disp_buf1, NULL, LV_HOR_RES* LV_VER_RES);