1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

chore: fix warning related to #3472

This commit is contained in:
Gabor Kiss-Vamosi 2022-07-13 17:18:46 +02:00
parent b9a2977711
commit 5c5e15b629
3 changed files with 18 additions and 17 deletions

View File

@ -127,8 +127,8 @@ void lv_obj_remove_style(lv_obj_t * obj, const lv_style_t * style, lv_style_sele
}
if(obj->styles[i].is_local || obj->styles[i].is_trans) {
lv_style_reset(obj->styles[i].style);
lv_mem_free(obj->styles[i].style);
if(obj->styles[i].style) lv_style_reset((lv_style_t *)obj->styles[i].style);
lv_mem_free((lv_style_t *)obj->styles[i].style);
obj->styles[i].style = NULL;
}
@ -314,7 +314,7 @@ bool lv_obj_remove_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_sty
/*The style is not found*/
if(i == obj->style_cnt) return false;
return lv_style_remove_prop(obj->styles[i].style, prop);
return lv_style_remove_prop((lv_style_t *)obj->styles[i].style, prop);
}
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state, lv_state_t new_state,
@ -336,7 +336,7 @@ void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t
obj->state = new_state;
_lv_obj_style_t * style_trans = get_trans_style(obj, part);
lv_style_set_prop(style_trans->style, tr_dsc->prop, v1); /*Be sure `trans_style` has a valid value*/
lv_style_set_prop((lv_style_t *)style_trans->style, tr_dsc->prop, v1); /*Be sure `trans_style` has a valid value*/
if(tr_dsc->prop == LV_STYLE_RADIUS) {
if(v1.num == LV_RADIUS_CIRCLE || v2.num == LV_RADIUS_CIRCLE) {
@ -399,7 +399,7 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
bool valid1 = state_act & (~state1) ? false : true;
bool valid2 = state_act & (~state2) ? false : true;
if(valid1 != valid2) {
lv_style_t * style = obj->styles[i].style;
const lv_style_t * style = obj->styles[i].style;
lv_style_value_t v;
/*If there is layout difference on the main part, return immediately. There is no more serious difference*/
bool layout_diff = false;
@ -508,7 +508,7 @@ static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_local &&
obj->styles[i].selector == selector) {
return obj->styles[i].style;
return (lv_style_t *)obj->styles[i].style;
}
}
@ -525,10 +525,10 @@ static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector
lv_memset_00(&obj->styles[i], sizeof(_lv_obj_style_t));
obj->styles[i].style = lv_mem_alloc(sizeof(lv_style_t));
lv_style_init(obj->styles[i].style);
lv_style_init((lv_style_t *)obj->styles[i].style);
obj->styles[i].is_local = 1;
obj->styles[i].selector = selector;
return obj->styles[i].style;
return (lv_style_t *)obj->styles[i].style;
}
/**
@ -557,7 +557,7 @@ static _lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_style_selector_t se
lv_memset_00(&obj->styles[0], sizeof(_lv_obj_style_t));
obj->styles[0].style = lv_mem_alloc(sizeof(lv_style_t));
lv_style_init(obj->styles[0].style);
lv_style_init((lv_style_t *)obj->styles[0].style);
obj->styles[0].is_trans = 1;
obj->styles[0].selector = selector;
return &obj->styles[0];
@ -698,7 +698,7 @@ static bool trans_del(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, tran
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_trans && (part == LV_PART_ANY || obj->styles[i].selector == part)) {
lv_style_remove_prop(obj->styles[i].style, tr->prop);
lv_style_remove_prop((lv_style_t *)obj->styles[i].style, tr->prop);
}
}
@ -769,7 +769,7 @@ static void trans_anim_cb(void * _tr, int32_t v)
refr = false;
}
}
lv_style_set_prop(obj->styles[i].style, tr->prop, value_final);
lv_style_set_prop((lv_style_t *)obj->styles[i].style, tr->prop, value_final);
if(refr) lv_obj_refresh_style(tr->obj, tr->selector, tr->prop);
break;
@ -794,7 +794,8 @@ static void trans_anim_start_cb(lv_anim_t * a)
tr->prop = prop_tmp;
_lv_obj_style_t * style_trans = get_trans_style(tr->obj, tr->selector);
lv_style_set_prop(style_trans->style, tr->prop, tr->start_value); /*Be sure `trans_style` has a valid value*/
lv_style_set_prop((lv_style_t *)style_trans->style, tr->prop,
tr->start_value); /*Be sure `trans_style` has a valid value*/
}
@ -824,10 +825,10 @@ static void trans_anim_ready_cb(lv_anim_t * a)
lv_mem_free(tr);
_lv_obj_style_t * obj_style = &obj->styles[i];
lv_style_remove_prop(obj_style->style, prop);
lv_style_remove_prop((lv_style_t *)obj_style->style, prop);
if(lv_style_is_empty(obj->styles[i].style)) {
lv_obj_remove_style(obj, obj_style->style, obj_style->selector);
lv_obj_remove_style(obj, (lv_style_t *)obj_style->style, obj_style->selector);
}
break;

View File

@ -37,7 +37,7 @@ typedef enum {
typedef uint32_t lv_style_selector_t;
typedef struct {
lv_style_t * style;
const lv_style_t * style;
uint32_t selector : 24;
uint32_t is_local : 1;
uint32_t is_trans : 1;

View File

@ -50,9 +50,9 @@ extern "C" {
LV_EXPORT_CONST_INT(LV_IMG_ZOOM_NONE);
#if LV_USE_ASSERT_STYLE
#define LV_STYLE_CONST_INIT(var_name, prop_array) const lv_style_t var_name = { .sentinel = LV_STYLE_SENTINEL_VALUE, .v_p = { .const_props = prop_array }, .has_group = 0xFF, .prop1 = LV_STYLE_PROP_ANY }
#define LV_STYLE_CONST_INIT(var_name, prop_array) const lv_style_t var_name = { .sentinel = LV_STYLE_SENTINEL_VALUE, .v_p = { .const_props = prop_array }, .has_group = 0xFF, .prop1 = _LV_STYLE_PROP_CONST }
#else
#define LV_STYLE_CONST_INIT(var_name, prop_array) const lv_style_t var_name = { .v_p = { .const_props = prop_array }, .has_group = 0xFF, .prop1 = LV_STYLE_PROP_ANY }
#define LV_STYLE_CONST_INIT(var_name, prop_array) const lv_style_t var_name = { .v_p = { .const_props = prop_array }, .has_group = 0xFF, .prop1 = _LV_STYLE_PROP_CONST }
#endif
/** On simple system, don't waste resources on gradients */