1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

start to improve style transitions

This commit is contained in:
Gabor Kiss-Vamosi 2020-02-21 10:50:50 +01:00
parent 7f14726ba3
commit 7756d0cc88
11 changed files with 497 additions and 183 deletions

View File

@ -54,6 +54,24 @@ typedef struct _lv_event_temp_data
struct _lv_event_temp_data * prev; struct _lv_event_temp_data * prev;
} lv_event_temp_data_t; } lv_event_temp_data_t;
typedef struct {
lv_obj_t * obj;
lv_style_property_t prop;
lv_state_t dest_state;
union {
lv_color_t _color;
lv_style_int_t _int;
lv_opa_t _opa;
const void * _ptr;
}start_value;
union {
lv_color_t _color;
lv_style_int_t _int;
lv_opa_t _opa;
const void * _ptr;
}end_value;
}lv_anim_trans_t;
/********************** /**********************
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
@ -65,7 +83,8 @@ static void refresh_children_style(lv_obj_t * obj);
static void delete_children(lv_obj_t * obj); static void delete_children(lv_obj_t * obj);
static void base_dir_refr_children(lv_obj_t * obj); static void base_dir_refr_children(lv_obj_t * obj);
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
static void obj_state_anim_cb(void * p, lv_anim_value_t value); static void trans_anim_cb(lv_anim_trans_t * tr, lv_anim_value_t v);
static void trans_anim_ready_cb(lv_anim_t * a);
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v);
#endif #endif
static void lv_event_mark_deleted(lv_obj_t * obj); static void lv_event_mark_deleted(lv_obj_t * obj);
@ -115,6 +134,7 @@ void lv_init(void)
lv_group_init(); lv_group_init();
#endif #endif
lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(lv_anim_trans_t));
lv_theme_t * th = LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY, LV_THEME_DEFAULT_COLOR_SECONDARY, lv_theme_t * th = LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY, LV_THEME_DEFAULT_COLOR_SECONDARY,
@ -268,8 +288,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy)
new_obj->parent_event = 0; new_obj->parent_event = 0;
new_obj->gesture_parent = 1; new_obj->gesture_parent = 1;
new_obj->state_dsc.act = LV_STATE_NORMAL; new_obj->state_dsc.act = LV_STATE_NORMAL;
new_obj->state_dsc.prev = LV_STATE_NORMAL;
new_obj->state_dsc.anim = 0;
#if LV_USE_BIDI #if LV_USE_BIDI
if(parent == NULL) new_obj->base_dir = LV_BIDI_BASE_DIR_DEF; if(parent == NULL) new_obj->base_dir = LV_BIDI_BASE_DIR_DEF;
@ -1197,6 +1215,20 @@ void _lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t pro
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj);
} }
/**
* Get the local style of a part of an object.
* @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`
* @return pointer to the local style if exists else `NULL`.
*/
lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part)
{
lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part);
return lv_style_list_get_local_style(style_dsc);
}
/** /**
* Notify an object (and its children) about its style is modified * Notify an object (and its children) about its style is modified
* @param obj pointer to an object * @param obj pointer to an object
@ -1422,55 +1454,155 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
LV_ASSERT_OBJ(obj, LV_OBJX_NAME); LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
/*Get the transition time for the new state*/ #if LV_USE_ANIMATION == 0
lv_obj_state_dsc_t dsc_ori = obj->state_dsc;
obj->state_dsc.act = new_state;
obj->state_dsc.prev = new_state;
#if LV_USE_ANIMATION
lv_style_int_t t = lv_obj_get_style_transition_time(obj, LV_OBJ_PART_MAIN);
#else
lv_style_int_t t = 0;
#endif
obj->state_dsc = dsc_ori;
if(t == 0) {
#if LV_USE_ANIMATION
lv_anim_del(obj, obj_state_anim_cb);
#endif
obj->state_dsc.act = new_state; obj->state_dsc.act = new_state;
obj->state_dsc.prev = new_state; obj->state_dsc.prev = new_state;
obj->state_dsc.anim = 0; obj->state_dsc.anim = 0;
lv_obj_refresh_style(obj); lv_obj_refresh_style(obj);
} #else
else { lv_state_t prev_state = obj->state_dsc.act;
#if LV_USE_ANIMATION
/* If there was an animation keep the previous state and
* move to the new from there*/
bool was_anim = lv_anim_del(obj, obj_state_anim_cb);
if(was_anim) {
obj->state_dsc.act = new_state; obj->state_dsc.act = new_state;
lv_style_int_t time = lv_obj_get_style_trans_time(obj, LV_OBJ_PART_MAIN);
if(time == 0) {
lv_obj_refresh_style(obj);
return;
}
lv_style_property_t props[LV_STYLE_TRANS_NUM_MAX];
// lv_style_int_t delay = lv_obj_get_style_trans_delay(obj, LV_OBJ_PART_MAIN);
// lv_anim_path_cb_t path = lv_obj_get_style_trans_path(obj, LV_OBJ_PART_MAIN);
props[0] = lv_obj_get_style_trans_prop1(obj, LV_OBJ_PART_MAIN);
props[1] = lv_obj_get_style_trans_prop2(obj, LV_OBJ_PART_MAIN);
props[2] = lv_obj_get_style_trans_prop3(obj, LV_OBJ_PART_MAIN);
props[3] = lv_obj_get_style_trans_prop4(obj, LV_OBJ_PART_MAIN);
props[4] = lv_obj_get_style_trans_prop5(obj, LV_OBJ_PART_MAIN);
props[5] = lv_obj_get_style_trans_prop6(obj, LV_OBJ_PART_MAIN);
lv_style_list_t * style_list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
uint8_t i;
for(i = 0; i < LV_STYLE_TRANS_NUM_MAX; i++) {
if(props[i] != 0) {
lv_style_t * style_trans = lv_style_list_add_trans_style(style_list);
lv_anim_trans_t * tr;
/*Get the previous and current values*/
if((props[i] & 0xF) < LV_STYLE_ID_COLOR) { /*Int*/
style_list->skip_trans = 1;
obj->state_dsc.act = prev_state;
lv_style_int_t int1 = _lv_obj_get_style_int(obj, LV_OBJ_PART_MAIN, props[i]);
obj->state_dsc.act = new_state;
lv_style_int_t int2 = _lv_obj_get_style_int(obj, LV_OBJ_PART_MAIN, props[i]);
style_list->skip_trans = 0;
if(int1 != int2) {
obj->state_dsc.act = prev_state;
int1 = _lv_obj_get_style_int(obj, LV_OBJ_PART_MAIN, props[i]);
obj->state_dsc.act = new_state;
if(props[i] == LV_STYLE_RADIUS) {
if(int1 == LV_RADIUS_CIRCLE || int2 == LV_RADIUS_CIRCLE) {
lv_coord_t whalf = lv_obj_get_width(obj) / 2;
lv_coord_t hhalf = lv_obj_get_width(obj) / 2;
if(int1 == LV_RADIUS_CIRCLE) int1 = LV_MATH_MIN(whalf + 1, hhalf + 1);
if(int2 == LV_RADIUS_CIRCLE) int2 = LV_MATH_MIN(whalf + 1, hhalf + 1);
}
}
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return;
tr->start_value._int = int1;
tr->end_value._int = int2;
} else { } else {
obj->state_dsc.prev = obj->state_dsc.act; tr = NULL; /*Mark that there is nothing to do here*/
obj->state_dsc.act = new_state;
obj->state_dsc.anim = 0;
} }
if(obj->state_dsc.prev != obj->state_dsc.act) { }
t = t - ((obj->state_dsc.anim * t) / 255); else if((props[i] & 0xF) < LV_STYLE_ID_OPA) { /*Color*/
obj->state_dsc.act = prev_state;
lv_color_t c1 = _lv_obj_get_style_color(obj, LV_OBJ_PART_MAIN, props[i]);
obj->state_dsc.act = new_state;
lv_color_t c2 = _lv_obj_get_style_color(obj, LV_OBJ_PART_MAIN, props[i]);
if(c1.full != c2.full) {
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return;
tr->start_value._color = c1;
tr->end_value._color = c2;
} else {
tr = NULL; /*Mark that there is nothing to do here*/
}
}
else if((props[i] & 0xF) < LV_STYLE_ID_PTR) { /*Opa*/
obj->state_dsc.act = prev_state;
lv_opa_t o1 = _lv_obj_get_style_opa(obj, LV_OBJ_PART_MAIN, props[i]);
obj->state_dsc.act = new_state;
lv_opa_t o2 = _lv_obj_get_style_opa(obj, LV_OBJ_PART_MAIN, props[i]);
if(o1 != o2) {
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return;
tr->start_value._opa= o1;
tr->end_value._opa = o2;
} else {
tr = NULL;
}
} else { /*Ptr*/
obj->state_dsc.act = prev_state;
const void * p1 = _lv_obj_get_style_ptr(obj, LV_OBJ_PART_MAIN, props[i]);
obj->state_dsc.act = new_state;
const void * p2 = _lv_obj_get_style_ptr(obj, LV_OBJ_PART_MAIN, props[i]);
if(p1 != p2) {
tr = lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll));
LV_ASSERT_MEM(tr);
if(tr == NULL) return;
tr->start_value._ptr= p1;
tr->end_value._ptr = p2;
} else {
tr = NULL;
}
}
/*If there is a pending anim for this property remove it*/
if(tr) {
lv_anim_trans_t * tri;
LV_LL_READ(LV_GC_ROOT(_lv_obj_style_trans_ll), tri) {
if(props[i] == tri->prop && tri != tr) {
lv_style_remove_prop(style_trans, props[i]);
lv_anim_del(tri, NULL);
lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tri);
}
}
tr->obj = obj;
tr->dest_state = new_state;
tr->prop = props[i];
lv_anim_t a; lv_anim_t a;
lv_anim_init(&a); lv_anim_init(&a);
lv_anim_set_var(&a, obj); lv_anim_set_var(&a, tr);
lv_anim_set_exec_cb(&a, obj_state_anim_cb); lv_anim_set_exec_cb(&a, trans_anim_cb);
lv_anim_set_values(&a, obj->state_dsc.anim, 255); lv_anim_set_ready_cb(&a, trans_anim_ready_cb);
lv_anim_set_time(&a, t); lv_anim_set_values(&a, 0x00, 0xFF);
lv_anim_set_time(&a, time);
lv_anim_start(&a); lv_anim_start(&a);
} else { }
lv_obj_refresh_style(obj);
} }
#endif #endif
} }
lv_obj_refresh_style(obj);
} }
/** /**
@ -2122,35 +2254,7 @@ lv_style_int_t _lv_obj_get_style_int(const lv_obj_t * obj, uint8_t part, lv_styl
prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS); prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS);
res = lv_style_list_get_int(dsc, prop, &value_act); res = lv_style_list_get_int(dsc, prop, &value_act);
if(res == LV_RES_OK) { if(res == LV_RES_OK) return value_act;
if(state->act == state->prev) return value_act;
else {
/*Handle transition*/
lv_style_int_t value_prev;
prop = (uint16_t)prop_ori + ((uint16_t)state->prev << LV_STYLE_STATE_POS);
res = lv_style_list_get_int(dsc, prop, &value_prev);
if(res == LV_RES_INV) value_prev = value_act;
if(prop == LV_STYLE_RADIUS) {
if(value_act == LV_RADIUS_CIRCLE || value_prev == LV_RADIUS_CIRCLE) {
lv_coord_t whalf = lv_obj_get_width(obj) / 2;
lv_coord_t hhalf = lv_obj_get_width(obj) / 2;
if(value_act == LV_RADIUS_CIRCLE) {
value_act = LV_MATH_MIN(whalf + 1, hhalf + 1);
}
if(value_prev == LV_RADIUS_CIRCLE) {
value_prev = LV_MATH_MIN(whalf + 1, hhalf + 1);
}
}
}
if(state->anim >= 255) return value_act;
return value_prev + (((value_act - value_prev) * state->anim) >> 8);
}
}
if(attr.bits.inherit == 0) break; if(attr.bits.inherit == 0) break;
@ -2211,18 +2315,18 @@ lv_color_t _lv_obj_get_style_color(const lv_obj_t * obj, uint8_t part, lv_style_
prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS); prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS);
res = lv_style_list_get_color(dsc, prop, &value_act); res = lv_style_list_get_color(dsc, prop, &value_act);
if(res == LV_RES_OK) { if(res == LV_RES_OK) return value_act;
if(state->act == state->prev) return value_act; // if(state->act == state->prev) r
else { // else {
/*Handle transition*/ // /*Handle transition*/
lv_color_t value_prev; // lv_color_t value_prev;
prop = (uint16_t)prop_ori + ((uint16_t)state->prev << LV_STYLE_STATE_POS); // prop = (uint16_t)prop_ori + ((uint16_t)state->prev << LV_STYLE_STATE_POS);
res = lv_style_list_get_color(dsc, prop, &value_prev); // res = lv_style_list_get_color(dsc, prop, &value_prev);
if(res == LV_RES_INV) value_prev = value_act; // if(res == LV_RES_INV) value_prev = value_act;
if(value_act.full == value_prev.full) return value_act; // if(value_act.full == value_prev.full) return value_act;
return lv_color_mix(value_act, value_prev, state->anim); // return lv_color_mix(value_act, value_prev, state->anim);
} // }
} // }
if(attr.bits.inherit == 0) break; if(attr.bits.inherit == 0) break;
@ -2278,19 +2382,19 @@ lv_opa_t _lv_obj_get_style_opa(const lv_obj_t * obj, uint8_t part, lv_style_prop
prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS); prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS);
res = lv_style_list_get_opa(dsc, prop, &value_act); res = lv_style_list_get_opa(dsc, prop, &value_act);
if(res == LV_RES_OK) { if(res == LV_RES_OK) return value_act;
if(state->act == state->prev) return value_act; // if(state->act == state->prev)
else { // else {
/*Handle transition*/ // /*Handle transition*/
lv_opa_t value_prev; // lv_opa_t value_prev;
prop = (uint16_t)prop_ori + ((uint16_t)state->prev << LV_STYLE_STATE_POS); // prop = (uint16_t)prop_ori + ((uint16_t)state->prev << LV_STYLE_STATE_POS);
res = lv_style_list_get_opa(dsc, prop, &value_prev); // res = lv_style_list_get_opa(dsc, prop, &value_prev);
if(res == LV_RES_INV) value_prev = value_act; // if(res == LV_RES_INV) value_prev = value_act;
//
if(state->anim >= 255) return value_act; // if(state->anim >= 255) return value_act;
return value_prev + (((value_act - value_prev) * state->anim) >> 8); // return value_prev + (((value_act - value_prev) * state->anim) >> 8);
} // }
} // }
if(attr.bits.inherit == 0) break; if(attr.bits.inherit == 0) break;
@ -2347,20 +2451,20 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_
prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS); prop = (uint16_t)prop_ori + ((uint16_t)state->act << LV_STYLE_STATE_POS);
res = lv_style_list_get_ptr(dsc, prop, &value_act); res = lv_style_list_get_ptr(dsc, prop, &value_act);
if(res == LV_RES_OK) { if(res == LV_RES_OK) return value_act;
if(state->act == state->prev) return value_act; // if(state->act == state->prev)
else { // else {
/*Handle transition*/ // /*Handle transition*/
if(state->anim > 128) return value_act; // if(state->anim > 128) return value_act;
//
void * value_prev; // void * value_prev;
prop = (uint16_t)prop_ori + ((uint16_t)state->prev << LV_STYLE_STATE_POS); // prop = (uint16_t)prop_ori + ((uint16_t)state->prev << LV_STYLE_STATE_POS);
res = lv_style_list_get_ptr(dsc, prop, &value_prev); // res = lv_style_list_get_ptr(dsc, prop, &value_prev);
if(res == LV_RES_INV) value_prev = value_act; // if(res == LV_RES_INV) value_prev = value_act;
//
return value_prev; // return value_prev;
} // }
} // }
if(attr.bits.inherit == 0) break; if(attr.bits.inherit == 0) break;
@ -3447,13 +3551,36 @@ static void base_dir_refr_children(lv_obj_t * obj)
} }
#if LV_USE_ANIMATION #if LV_USE_ANIMATION
static void obj_state_anim_cb(void * p, lv_anim_value_t value)
{
lv_obj_t * obj = p;
obj->state_dsc.anim = value;
if(value == 255) obj->state_dsc.prev = obj->state_dsc.act;
lv_obj_refresh_style(obj); static void trans_anim_cb(lv_anim_trans_t * tr, lv_anim_value_t v)
{
if((tr->prop & 0xF) < LV_STYLE_ID_COLOR) { /*Value*/
lv_style_int_t x = tr->start_value._int + ((int32_t)((int32_t)(tr->end_value._int - tr->start_value._int) * v) >> 8);
lv_style_list_t * list = lv_obj_get_style_list(tr->obj, LV_OBJ_PART_MAIN);
lv_style_t * style = lv_style_list_get_trans_style(list);
_lv_style_set_int(style, tr->prop, x);
lv_obj_refresh_style(tr->obj);
}
}
static void trans_anim_ready_cb(lv_anim_t * a)
{
lv_anim_trans_t * tr = a->var;
if((tr->prop & 0xF) < LV_STYLE_ID_COLOR) { /*Value*/
lv_style_t * style = lv_obj_get_local_style(tr->obj, LV_OBJ_PART_MAIN);
lv_style_remove_prop(style, tr->prop | (tr->dest_state << LV_STYLE_STATE_POS));
}
lv_anim_trans_t * i;
LV_LL_READ(LV_GC_ROOT(_lv_obj_style_trans_ll), tr) {
if(tr->obj == i->obj && tr->dest_state == i->dest_state) {
lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);
return;
}
}
} }
static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v) static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v)

View File

@ -195,8 +195,6 @@ typedef uint8_t lv_state_t;
typedef struct { typedef struct {
lv_state_t act; lv_state_t act;
lv_state_t prev;
uint8_t anim;
}lv_obj_state_dsc_t; }lv_obj_state_dsc_t;
typedef struct _lv_obj_t typedef struct _lv_obj_t
@ -565,6 +563,15 @@ void _lv_obj_set_style_opa(lv_obj_t * obj, uint8_t type, lv_style_property_t pro
*/ */
void _lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value); void _lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t type, lv_style_property_t prop, const void * value);
/**
* Get the local style of a part of an object.
* @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`
* @return pointer to the local style if exists else `NULL`.
*/
lv_style_t * lv_obj_get_local_style(lv_obj_t * obj, uint8_t part);
/*----------------- /*-----------------
* Attribute set * Attribute set
*----------------*/ *----------------*/

View File

@ -69,7 +69,6 @@ static inline void lv_style_set_##func_name (lv_style_t * style, lv_state_t stat
_LV_OBJ_STYLE_SET_GET_DECLARE(RADIUS, radius, lv_style_int_t,_int, scalar) _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) _LV_OBJ_STYLE_SET_GET_DECLARE(CLIP_CORNER, clip_corner, bool, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANSITION_TIME, transition_time, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(OPA_SCALE, opa_scale, lv_opa_t, _opa, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(OPA_SCALE, opa_scale, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(PAD_TOP, pad_top, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(PAD_TOP, pad_top, lv_style_int_t, _int, scalar)
@ -137,11 +136,26 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_BLEND_MODE, image_blend_mode, lv_blend_mode_
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR, image_recolor, lv_color_t, _color, nonscalar) _LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR, image_recolor, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_OPA, image_opa, lv_opa_t, _opa, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_OPA, image_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR_OPA, image_recolor_opa, lv_opa_t, _opa, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR_OPA, image_recolor_opa, lv_opa_t, _opa, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_TIME, trans_time, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_DELAY, trans_delay, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_PROP_1, trans_prop1, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_PROP_2, trans_prop2, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_PROP_3, trans_prop3, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_PROP_4, trans_prop4, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_PROP_5, trans_prop5, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_PROP_6, trans_prop6, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS_PATH, trans_path, const lv_anim_path_cb_t , _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS2_TIME, trans2_time, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS2_DELAY, trans2_delay, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS2_PROP_1, trans2_prop1, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS2_PROP_2, trans2_prop2, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS2_PROP_3, trans2_prop3, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS2_PROP_4, trans2_prop4, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(TRANS2_PATH, trans2_path, const lv_anim_path_cb_t , _ptr, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int, scalar) _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) _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_BORDER_WIDTH, scale_end_border_width, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_BORDER_WIDTH, scale_end_border_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_LINE_WIDTH, scale_end_line_width, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_LINE_WIDTH, scale_end_line_width, lv_style_int_t, _int, scalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_COLOR, scale_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_GRAD_COLOR, scale_grad_color, lv_color_t, _color, nonscalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_GRAD_COLOR, scale_grad_color, lv_color_t, _color, nonscalar)
_LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_COLOR, scale_end_color, lv_color_t, _color, nonscalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_COLOR, scale_end_color, lv_color_t, _color, nonscalar)

View File

@ -36,7 +36,7 @@
* STATIC PROTOTYPES * STATIC PROTOTYPES
**********************/ **********************/
static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop); static inline int32_t get_property_index(const lv_style_t * style, lv_style_property_t prop);
static lv_style_t * get_local_style(lv_style_list_t * list); static lv_style_t * get_alloc_local_style(lv_style_list_t * list);
/********************** /**********************
* GLOABAL VARIABLES * GLOABAL VARIABLES
@ -85,6 +85,51 @@ void lv_style_copy(lv_style_t * style_dest, const lv_style_t * style_src)
memcpy(style_dest->map, style_src->map, size); memcpy(style_dest->map, style_src->map, size);
} }
/**
* Remove a property from a style
* @param style pointer to a style
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @return true: the property was found and removed; false: the property wasn't found
*/
bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop)
{
if(style == NULL) return false;
LV_ASSERT_STYLE(style);
int32_t id = get_property_index(style, prop);
/*The property exists but not sure it's state is the same*/
if(id >= 0) {
lv_style_attr_t attr_found;
lv_style_attr_t attr_goal;
attr_found.full = *(style->map + id + 1);
attr_goal.full = (prop >> 8) & 0xFFU;
if(attr_found.bits.state == attr_goal.bits.state)
{
uint32_t map_size = lv_style_get_mem_size(style);
uint8_t prop_size = sizeof(lv_style_property_t);
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 *);
/*Move the props to fill the space of the property to delete*/
uint32_t i;
for(i = id; i < map_size - prop_size; i++) {
style->map[i] = style->map[i + prop_size];
}
style->map = lv_mem_realloc(style->map, map_size - prop_size);
return true;
}
}
return false;
}
/** /**
* Initialize a style list * Initialize a style list
* @param list a style list to initialize * @param list a style list to initialize
@ -113,18 +158,30 @@ void lv_style_list_copy(lv_style_list_t * list_dest, const lv_style_list_t * lis
if(list_src->style_list == NULL) return; if(list_src->style_list == NULL) return;
/*Copy the styles but skip the transitions*/
if(list_src->has_local == 0) { if(list_src->has_local == 0) {
if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1;
} else {
list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *)); list_dest->style_list = lv_mem_alloc(list_src->style_cnt * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *)); memcpy(list_dest->style_list, list_src->style_list, list_src->style_cnt * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt; list_dest->style_cnt = list_src->style_cnt;
}
} else {
if(list_src->has_trans) {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 2) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 2, (list_src->style_cnt - 2) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 2;
} else { } else {
list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *)); list_dest->style_list = lv_mem_alloc((list_src->style_cnt - 1) * sizeof(lv_style_t *));
memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *)); memcpy(list_dest->style_list, list_src->style_list + 1, (list_src->style_cnt - 1) * sizeof(lv_style_t *));
list_dest->style_cnt = list_src->style_cnt - 1; list_dest->style_cnt = list_src->style_cnt - 1;
}
lv_style_t * local_style = get_local_style(list_dest); lv_style_t * local_style = get_alloc_local_style(list_dest);
lv_style_copy(local_style, get_local_style((lv_style_list_t *)list_src)); lv_style_copy(local_style, get_alloc_local_style((lv_style_list_t *)list_src));
} }
} }
@ -154,9 +211,11 @@ void lv_style_list_add_style(lv_style_list_t * list, lv_style_t * style)
return; return;
} }
/*Make space for the new style at the beginning. Leave local style if exists*/ /*Make space for the new style at the beginning. Leave local and trans style if exists*/
uint8_t i; uint8_t i;
uint8_t first_style = list->has_local ? 1 : 0; uint8_t first_style = 0;
if(list->has_trans) first_style++;
if(list->has_local) first_style++;
for(i = list->style_cnt; i > first_style; i--) { for(i = list->style_cnt; i > first_style; i--) {
new_classes[i] = new_classes[i - 1]; new_classes[i] = new_classes[i - 1];
} }
@ -226,10 +285,17 @@ void lv_style_list_reset(lv_style_list_t * list)
if(list == NULL) return; if(list == NULL) return;
if(list->has_local) { if(list->has_local) {
lv_style_t * local = lv_style_list_get_style(list, 0); lv_style_t * local = lv_style_list_get_local_style(list);
if(local) {
lv_style_reset(local); lv_style_reset(local);
lv_mem_free(local); lv_mem_free(local);
} }
lv_style_t * trans = lv_style_list_get_trans_style(list);
if(trans) {
lv_style_reset(trans);
lv_mem_free(trans);
}
}
if(list->style_cnt > 0) lv_mem_free(list->style_list); if(list->style_cnt > 0) lv_mem_free(list->style_list);
list->style_list = NULL; list->style_list = NULL;
list->style_cnt = 0; list->style_cnt = 0;
@ -460,7 +526,6 @@ void _lv_style_set_ptr(lv_style_t * style, lv_style_property_t prop, const void
memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark)); memcpy(style->map + size - end_mark_size, &end_mark, sizeof(end_mark));
} }
/** /**
* Get the a property from a style. * Get the a property from a style.
* Take into account the style state and return the property which matches the best. * Take into account the style state and return the property which matches the best.
@ -594,6 +659,58 @@ int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, vo
} }
} }
/**
* Get the local style of a style list
* @param list pointer to a style list where the local property should be set
* @return pointer to the local style if exists else `NULL`.
*/
lv_style_t * lv_style_list_get_local_style(lv_style_list_t * list)
{
LV_ASSERT_STYLE_LIST(list);
if(!list->has_local) return NULL;
if(list->has_trans) return list->style_list[1];
else return list->style_list[0];
}
/**
* Get the transition style of a style list
* @param list pointer to a style list where the local property should be set
* @return pointer to the transition style if exists else `NULL`.
*/
lv_style_t * lv_style_list_get_trans_style(lv_style_list_t * list)
{
LV_ASSERT_STYLE_LIST(list);
if(!list->has_trans) return NULL;
return list->style_list[0];
}
/**
* Allocate the transition style in a style list. If already exists simply return it.
* @param list pointer to a style list
* @return the transition style of a style list
*/
lv_style_t * lv_style_list_add_trans_style(lv_style_list_t * list)
{
LV_ASSERT_STYLE_LIST(list);
if(list->has_trans) return lv_style_list_get_trans_style(list);
lv_style_t * trans_style = lv_mem_alloc(sizeof(lv_style_t));
LV_ASSERT_MEM(trans_style);
if(trans_style == NULL) {
LV_LOG_WARN("lv_style_list_add_trans_style: couldn't create transition style");
return NULL;
}
lv_style_init(trans_style);
lv_style_list_add_style(list, trans_style);
list->has_trans = 1;
return trans_style;
}
/** /**
* Set a local integer typed property in a style list. * Set a local integer typed property in a style list.
@ -607,7 +724,7 @@ void lv_style_list_set_local_int(lv_style_list_t * list, lv_style_property_t pro
{ {
LV_ASSERT_STYLE_LIST(list); LV_ASSERT_STYLE_LIST(list);
lv_style_t * local = get_local_style(list); lv_style_t * local = get_alloc_local_style(list);
_lv_style_set_int(local, prop, value); _lv_style_set_int(local, prop, value);
} }
@ -623,7 +740,7 @@ void lv_style_list_set_local_opa(lv_style_list_t * list, lv_style_property_t pro
{ {
LV_ASSERT_STYLE_LIST(list); LV_ASSERT_STYLE_LIST(list);
lv_style_t * local = get_local_style(list); lv_style_t * local = get_alloc_local_style(list);
_lv_style_set_opa(local, prop, value); _lv_style_set_opa(local, prop, value);
} }
@ -639,7 +756,7 @@ void lv_style_list_set_local_color(lv_style_list_t * list, lv_style_property_t p
{ {
LV_ASSERT_STYLE_LIST(list); LV_ASSERT_STYLE_LIST(list);
lv_style_t * local = get_local_style(list); lv_style_t * local = get_alloc_local_style(list);
_lv_style_set_color(local, prop, value); _lv_style_set_color(local, prop, value);
} }
@ -655,7 +772,7 @@ void lv_style_list_set_local_ptr(lv_style_list_t * list, lv_style_property_t pro
{ {
LV_ASSERT_STYLE_LIST(list); LV_ASSERT_STYLE_LIST(list);
lv_style_t * local = get_local_style(list); lv_style_t * local = get_alloc_local_style(list);
_lv_style_set_ptr(local, prop, value); _lv_style_set_ptr(local, prop, value);
} }
@ -695,6 +812,10 @@ lv_res_t lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop,
*res = value_act; *res = value_act;
return LV_RES_OK; return LV_RES_OK;
} }
else if(weight_act >= 0 && ci == 0 && list->has_trans && !list->skip_trans) {
*res = value_act;
return LV_RES_OK;
}
/*If the found ID is better the current candidate then use it*/ /*If the found ID is better the current candidate then use it*/
else if(weight_act > weight) { else if(weight_act > weight) {
weight = weight_act; weight = weight_act;
@ -913,7 +1034,7 @@ static inline int32_t get_property_index(const lv_style_t * style, lv_style_prop
* @param list pointer to a style list * @param list pointer to a style list
* @return pointer to the local style * @return pointer to the local style
*/ */
static lv_style_t * get_local_style(lv_style_list_t * list) static lv_style_t * get_alloc_local_style(lv_style_list_t * list)
{ {
LV_ASSERT_STYLE_LIST(list); LV_ASSERT_STYLE_LIST(list);
@ -927,6 +1048,7 @@ static lv_style_t * get_local_style(lv_style_list_t * list)
} }
lv_style_init(local_style); lv_style_init(local_style);
/*Add the local style to the furst place*/
lv_style_list_add_style(list, local_style); lv_style_list_add_style(list, local_style);
list->has_local = 1; list->has_local = 1;

View File

@ -39,6 +39,8 @@ LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
#define _LV_STYLE_CLOSEING_PROP 0xFF #define _LV_STYLE_CLOSEING_PROP 0xFF
#define LV_STYLE_TRANS_NUM_MAX 6
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
@ -84,15 +86,15 @@ typedef union {
}lv_style_attr_t; }lv_style_attr_t;
#define LV_STYLE_ID_VALUE 0x0 /*max 6 pcs*/ #define LV_STYLE_ID_VALUE 0x0 /*max 8 pcs*/
#define LV_STYLE_ID_COLOR 0x6 /*max 4 pcs*/ #define LV_STYLE_ID_COLOR 0x8 /*max 3 pcs*/
#define LV_STYLE_ID_OPA 0xA /*max 4 pcs*/ #define LV_STYLE_ID_OPA 0xB /*max 3 pcs*/
#define LV_STYLE_ID_PTR 0xE /*max 2 pcs*/ #define LV_STYLE_ID_PTR 0xE /*max 2 pcs*/
enum { enum {
LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), /*Skip 0th property*/
LV_STYLE_PROP_INIT(LV_STYLE_CLIP_CORNER, 0x0, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANSITION_TIME, 0x0, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_CLIP_CORNER, 0x0, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SIZE, 0x0, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SIZE, 0x0, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_OPA_SCALE, 0x0, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
@ -171,13 +173,32 @@ enum {
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_OPA, 0xA, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_OPA, 0xA, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR_OPA, 0xA, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_INHERIT), LV_STYLE_PROP_INIT(LV_STYLE_IMAGE_RECOLOR_OPA, 0xA, LV_STYLE_ID_OPA + 1, LV_STYLE_ATTR_INHERIT),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xB, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANS_TIME, 0xB, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0xB, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANS_DELAY, 0xB, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0xB, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANS_PROP_1, 0xB, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xB, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANS_PROP_2, 0xB, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_COLOR, 0xB, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANS_PROP_3, 0xB, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xB, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANS_PROP_4, 0xB, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xB, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_TRANS_PROP_5, 0xB, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS_PROP_6, 0xB, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS_PATH, 0xB, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_TIME, 0xC, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_DELAY, 0xC, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_PROP_1, 0xC, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_PROP_2, 0xC, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_PROP_3, 0xC, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_PROP_4, 0xC, LV_STYLE_ID_VALUE + 5, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_PROP_5, 0xC, LV_STYLE_ID_VALUE + 6, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_PROP_6, 0xC, LV_STYLE_ID_VALUE + 7, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_TRANS2_PATH, 0xC, LV_STYLE_ID_PTR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0xD, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0xD, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0xD, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_LINE_WIDTH, 0xD, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0xD, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE),
LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0xD, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE),
}; };
typedef uint16_t lv_style_property_t; typedef uint16_t lv_style_property_t;
@ -204,6 +225,8 @@ typedef struct {
#endif #endif
uint8_t style_cnt; uint8_t style_cnt;
uint8_t has_local :1; uint8_t has_local :1;
uint8_t has_trans :1;
uint8_t skip_trans :1;
}lv_style_list_t; }lv_style_list_t;
/********************** /**********************
@ -260,8 +283,8 @@ void lv_style_list_reset(lv_style_list_t * style_list);
static inline lv_style_t * lv_style_list_get_style(lv_style_list_t * list, uint8_t id) static inline lv_style_t * lv_style_list_get_style(lv_style_list_t * list, uint8_t id)
{ {
if(list->has_trans && list->skip_trans) id++;
if(list->style_cnt == 0 || id >= list->style_cnt) return NULL; if(list->style_cnt == 0 || id >= list->style_cnt) return NULL;
return list->style_list[id]; return list->style_list[id];
} }
@ -285,6 +308,15 @@ uint16_t lv_style_get_mem_size(const lv_style_t * style);
*/ */
void lv_style_copy(lv_style_t * dest, const lv_style_t * src); void lv_style_copy(lv_style_t * dest, const lv_style_t * src);
/**
* Remove a property from a style
* @param style pointer to a style
* @param prop a style property ORed with a state.
* E.g. `LV_STYLE_BORDER_WIDTH | (LV_STATE_PRESSED << LV_STYLE_STATE_POS)`
* @return true: the property was found and removed; false: the property wasn't found
*/
bool lv_style_remove_prop(lv_style_t * style, lv_style_property_t prop);
/** /**
* Set an integer typed property in a style. * Set an integer typed property in a style.
* @param style pointer to a style where the property should be set * @param style pointer to a style where the property should be set
@ -393,6 +425,27 @@ 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); int16_t _lv_style_get_ptr(const lv_style_t * style, lv_style_property_t prop, void * res);
/**
* Get the local style of a style list
* @param list pointer to a style list where the local property should be set
* @return pointer to the local style if exists else `NULL`.
*/
lv_style_t * lv_style_list_get_local_style(lv_style_list_t * list);
/**
* Get the transition style of a style list
* @param list pointer to a style list where the local property should be set
* @return pointer to the transition style if exists else `NULL`.
*/
lv_style_t * lv_style_list_get_trans_style(lv_style_list_t * list);
/**
* Allocate the transition style in a style list. If already exists simply return it.
* @param list pointer to a style list
* @return the transition style of a style list
*/
lv_style_t * lv_style_list_add_trans_style(lv_style_list_t * list);
/** /**
* Set a local integer typed property in a style list. * Set a local integer typed property in a style list.
* @param list pointer to a style list where the local property should be set * @param list pointer to a style list where the local property should be set

View File

@ -33,6 +33,7 @@ extern "C" {
f(lv_ll_t, _lv_anim_ll) \ f(lv_ll_t, _lv_anim_ll) \
f(lv_ll_t, _lv_group_ll) \ f(lv_ll_t, _lv_group_ll) \
f(lv_ll_t, _lv_img_defoder_ll) \ f(lv_ll_t, _lv_img_defoder_ll) \
f(lv_ll_t, _lv_obj_style_trans_ll) \
f(lv_img_cache_entry_t*, _lv_img_cache_array) \ f(lv_img_cache_entry_t*, _lv_img_cache_array) \
f(void*, _lv_task_act) \ f(void*, _lv_task_act) \
f(lv_mem_buf_arr_t , _lv_mem_buf) \ f(lv_mem_buf_arr_t , _lv_mem_buf) \

View File

@ -183,7 +183,7 @@ static void basic_init(void)
lv_style_set_image_recolor(&panel, LV_STATE_NORMAL, color_panel_txt(LV_STATE_NORMAL)); lv_style_set_image_recolor(&panel, LV_STATE_NORMAL, color_panel_txt(LV_STATE_NORMAL));
lv_style_set_line_color(&panel, LV_STATE_NORMAL, color_panel_txt(LV_STATE_NORMAL)); lv_style_set_line_color(&panel, LV_STATE_NORMAL, color_panel_txt(LV_STATE_NORMAL));
lv_style_set_line_width(&panel, LV_STATE_NORMAL, 1); lv_style_set_line_width(&panel, LV_STATE_NORMAL, 1);
lv_style_set_transition_time(&panel, LV_STATE_NORMAL, TRANSITION_TIME); lv_style_set_trans_time(&panel, LV_STATE_NORMAL, TRANSITION_TIME);
lv_style_set_pad_left(&panel, LV_STATE_NORMAL, LV_DPI / 5); lv_style_set_pad_left(&panel, LV_STATE_NORMAL, LV_DPI / 5);
lv_style_set_pad_right(&panel, LV_STATE_NORMAL, LV_DPI / 5); lv_style_set_pad_right(&panel, LV_STATE_NORMAL, LV_DPI / 5);
lv_style_set_pad_top(&panel, LV_STATE_NORMAL, LV_DPI / 5); lv_style_set_pad_top(&panel, LV_STATE_NORMAL, LV_DPI / 5);
@ -208,7 +208,7 @@ static void basic_init(void)
lv_style_set_pad_top(&bg, LV_STATE_NORMAL, LV_DPI / 5); lv_style_set_pad_top(&bg, LV_STATE_NORMAL, LV_DPI / 5);
lv_style_set_pad_bottom(&bg, LV_STATE_NORMAL, LV_DPI / 5); lv_style_set_pad_bottom(&bg, LV_STATE_NORMAL, LV_DPI / 5);
lv_style_set_pad_inner(&bg, LV_STATE_NORMAL, LV_DPI / 5); lv_style_set_pad_inner(&bg, LV_STATE_NORMAL, LV_DPI / 5);
lv_style_set_transition_time(&panel, LV_STATE_NORMAL, TRANSITION_TIME); lv_style_set_trans_time(&panel, LV_STATE_NORMAL, TRANSITION_TIME);
lv_style_init(&btn); lv_style_init(&btn);
lv_style_set_radius(&btn, LV_STATE_NORMAL, LV_RADIUS_CIRCLE); lv_style_set_radius(&btn, LV_STATE_NORMAL, LV_RADIUS_CIRCLE);
@ -221,6 +221,7 @@ static void basic_init(void)
lv_style_set_border_color(&btn, LV_STATE_NORMAL, color_btn_border(LV_STATE_NORMAL)); lv_style_set_border_color(&btn, LV_STATE_NORMAL, color_btn_border(LV_STATE_NORMAL));
lv_style_set_border_color(&btn, LV_STATE_PRESSED, color_btn_border(LV_STATE_PRESSED)); lv_style_set_border_color(&btn, LV_STATE_PRESSED, color_btn_border(LV_STATE_PRESSED));
lv_style_set_border_width(&btn, LV_STATE_NORMAL, BORDER_WIDTH); lv_style_set_border_width(&btn, LV_STATE_NORMAL, BORDER_WIDTH);
lv_style_set_border_width(&btn, LV_STATE_PRESSED, BORDER_WIDTH * 10);
lv_style_set_border_width(&btn, LV_STATE_CHECKED, 0); lv_style_set_border_width(&btn, LV_STATE_CHECKED, 0);
lv_style_set_text_color(&btn, LV_STATE_NORMAL, color_btn_txt(LV_STATE_NORMAL)); lv_style_set_text_color(&btn, LV_STATE_NORMAL, color_btn_txt(LV_STATE_NORMAL));
lv_style_set_text_color(&btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_PRESSED)); lv_style_set_text_color(&btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_PRESSED));
@ -237,10 +238,12 @@ static void basic_init(void)
lv_style_set_pad_top(&btn, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_top(&btn, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_bottom(&btn, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_bottom(&btn, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_inner(&btn, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_inner(&btn, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_outline_width(&btn, LV_STATE_FOCUSED, 3); lv_style_set_outline_width(&btn, LV_STATE_FOCUSED, 10);
lv_style_set_outline_opa(&btn, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_opa(&btn, LV_STATE_NORMAL, LV_OPA_50);
lv_style_set_outline_color(&btn, LV_STATE_FOCUSED, _color_primary); lv_style_set_outline_color(&btn, LV_STATE_NORMAL, _color_primary);
lv_style_set_transition_time(&btn, LV_STATE_NORMAL, TRANSITION_TIME); lv_style_set_trans_time(&btn, LV_STATE_NORMAL, TRANSITION_TIME);
lv_style_set_trans_prop1(&btn, LV_STATE_NORMAL, LV_STYLE_BORDER_WIDTH);
lv_style_set_trans_prop2(&btn, LV_STATE_NORMAL, LV_STYLE_OUTLINE_WIDTH);
} }
static void cont_init(void) static void cont_init(void)
@ -358,7 +361,7 @@ static void linemeter_init(void)
lv_style_set_pad_inner(&lmeter, LV_STATE_NORMAL, LV_DPI / 6); lv_style_set_pad_inner(&lmeter, LV_STATE_NORMAL, LV_DPI / 6);
lv_style_set_scale_width(&lmeter, LV_STATE_NORMAL, LV_DPI/12); lv_style_set_scale_width(&lmeter, LV_STATE_NORMAL, LV_DPI/12);
lv_style_set_scale_color(&lmeter, LV_STATE_NORMAL, _color_primary); lv_style_set_line_color(&lmeter, LV_STATE_NORMAL, _color_primary);
lv_style_set_scale_grad_color(&lmeter, LV_STATE_NORMAL, _color_primary); lv_style_set_scale_grad_color(&lmeter, LV_STATE_NORMAL, _color_primary);
lv_style_set_scale_end_color(&lmeter, LV_STATE_NORMAL, lv_color_hex3(0x888)); lv_style_set_scale_end_color(&lmeter, LV_STATE_NORMAL, lv_color_hex3(0x888));
lv_style_set_line_rounded(&lmeter, LV_STATE_NORMAL, true); lv_style_set_line_rounded(&lmeter, LV_STATE_NORMAL, true);
@ -374,7 +377,7 @@ static void gauge_init(void)
lv_style_copy(&gauge_main, &panel); lv_style_copy(&gauge_main, &panel);
lv_style_set_radius(&gauge_main, LV_STATE_NORMAL, LV_RADIUS_CIRCLE); lv_style_set_radius(&gauge_main, LV_STATE_NORMAL, LV_RADIUS_CIRCLE);
lv_style_set_border_side(&gauge_main, LV_STATE_NORMAL, LV_BORDER_SIDE_FULL); lv_style_set_border_side(&gauge_main, LV_STATE_NORMAL, LV_BORDER_SIDE_FULL);
lv_style_set_scale_color(&gauge_main, LV_STATE_NORMAL, lv_color_hex3(0x888)); lv_style_set_line_color(&gauge_main, LV_STATE_NORMAL, lv_color_hex3(0x888));
lv_style_set_scale_grad_color(&gauge_main, LV_STATE_NORMAL, lv_color_hex3(0x888)); lv_style_set_scale_grad_color(&gauge_main, LV_STATE_NORMAL, lv_color_hex3(0x888));
lv_style_set_scale_end_color(&gauge_main, LV_STATE_NORMAL, _color_primary); lv_style_set_scale_end_color(&gauge_main, LV_STATE_NORMAL, _color_primary);
lv_style_set_line_width(&gauge_main, LV_STATE_NORMAL, LV_DPI / 50); lv_style_set_line_width(&gauge_main, LV_STATE_NORMAL, LV_DPI / 50);
@ -388,7 +391,7 @@ static void gauge_init(void)
lv_style_set_scale_width(&gauge_main, LV_STATE_NORMAL, LV_DPI/12); lv_style_set_scale_width(&gauge_main, LV_STATE_NORMAL, LV_DPI/12);
lv_style_init(&gauge_strong); lv_style_init(&gauge_strong);
lv_style_set_scale_color(&gauge_strong, LV_STATE_NORMAL, lv_color_hex3(0x888)); lv_style_set_line_color(&gauge_strong, LV_STATE_NORMAL, lv_color_hex3(0x888));
lv_style_set_scale_grad_color(&gauge_strong, LV_STATE_NORMAL, lv_color_hex3(0x888)); lv_style_set_scale_grad_color(&gauge_strong, LV_STATE_NORMAL, lv_color_hex3(0x888));
lv_style_set_scale_end_color(&gauge_strong, LV_STATE_NORMAL, _color_primary); lv_style_set_scale_end_color(&gauge_strong, LV_STATE_NORMAL, _color_primary);
lv_style_set_line_width(&gauge_strong, LV_STATE_NORMAL, LV_DPI / 25); lv_style_set_line_width(&gauge_strong, LV_STATE_NORMAL, LV_DPI / 25);
@ -538,7 +541,7 @@ static void checkbox_init(void)
lv_style_set_pattern_image(&cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK); lv_style_set_pattern_image(&cb_bullet, LV_STATE_CHECKED, LV_SYMBOL_OK);
lv_style_set_pattern_recolor(&cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE); lv_style_set_pattern_recolor(&cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE);
lv_style_set_text_font(&cb_bullet, LV_STATE_CHECKED, _font_small); lv_style_set_text_font(&cb_bullet, LV_STATE_CHECKED, _font_small);
lv_style_set_transition_time(&cb_bullet, LV_STATE_NORMAL , TRANSITION_TIME); lv_style_set_trans_time(&cb_bullet, LV_STATE_NORMAL , TRANSITION_TIME);
#endif #endif
} }
@ -626,7 +629,7 @@ static void textarea_init(void)
lv_style_set_pad_right(&ta_oneline, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_right(&ta_oneline, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_top(&ta_oneline, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_top(&ta_oneline, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_bottom(&ta_oneline, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_bottom(&ta_oneline, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_transition_time(&ta_oneline, LV_STATE_NORMAL, TRANSITION_TIME); lv_style_set_trans_time(&ta_oneline, LV_STATE_NORMAL, TRANSITION_TIME);
lv_style_init(&ta_placeholder); lv_style_init(&ta_placeholder);
lv_style_set_text_color(&ta_placeholder, LV_STATE_NORMAL, lv_color_hex(0x3b3e43)); lv_style_set_text_color(&ta_placeholder, LV_STATE_NORMAL, lv_color_hex(0x3b3e43));
@ -693,7 +696,7 @@ static void list_init(void)
lv_style_set_pad_top(&list_btn, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_top(&list_btn, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_bottom(&list_btn, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_bottom(&list_btn, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_pad_inner(&list_btn, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_inner(&list_btn, LV_STATE_NORMAL, LV_DPI / 10);
lv_style_set_transition_time(&list_btn, LV_STATE_NORMAL, TRANSITION_TIME); lv_style_set_trans_time(&list_btn, LV_STATE_NORMAL, TRANSITION_TIME);
#endif #endif
} }

View File

@ -617,7 +617,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
/*The state changes without re-caching the styles, disable the use of cache*/ /*The state changes without re-caching the styles, disable the use of cache*/
lv_obj_state_dsc_t state_ori = btnm->state_dsc; lv_obj_state_dsc_t state_ori = btnm->state_dsc;
btnm->state_dsc.act = LV_STATE_NORMAL; btnm->state_dsc.act = LV_STATE_NORMAL;
btnm->state_dsc.prev = btnm->state_dsc.act;
lv_draw_rect_dsc_init(&draw_rect_rel_dsc); lv_draw_rect_dsc_init(&draw_rect_rel_dsc);
lv_draw_label_dsc_init(&draw_label_rel_dsc); lv_draw_label_dsc_init(&draw_label_rel_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_rel_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_rel_dsc);
@ -657,7 +656,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
if(tgl_state) { if(tgl_state) {
if(!chk_inited) { if(!chk_inited) {
btnm->state_dsc.act = LV_STATE_CHECKED; btnm->state_dsc.act = LV_STATE_CHECKED;
btnm->state_dsc.prev = btnm->state_dsc.act;
lv_draw_rect_dsc_init(&draw_rect_chk_dsc); lv_draw_rect_dsc_init(&draw_rect_chk_dsc);
lv_draw_label_dsc_init(&draw_label_chk_dsc); lv_draw_label_dsc_init(&draw_label_chk_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_chk_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_chk_dsc);
@ -671,7 +669,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
if(button_is_inactive(ext->ctrl_bits[btn_i])) { if(button_is_inactive(ext->ctrl_bits[btn_i])) {
if(!disabled_inited) { if(!disabled_inited) {
btnm->state_dsc.act = LV_STATE_DISABLED; btnm->state_dsc.act = LV_STATE_DISABLED;
btnm->state_dsc.prev = btnm->state_dsc.act;
lv_draw_rect_dsc_init(&draw_rect_ina_dsc); lv_draw_rect_dsc_init(&draw_rect_ina_dsc);
lv_draw_label_dsc_init(&draw_label_ina_dsc); lv_draw_label_dsc_init(&draw_label_ina_dsc);
lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_ina_dsc); lv_obj_init_draw_rect_dsc(btnm, LV_BTNMATRIX_PART_BTN, &draw_rect_ina_dsc);
@ -694,7 +691,6 @@ static lv_design_res_t lv_btnmatrix_design(lv_obj_t * btnm, const lv_area_t * cl
if(tgl_state) btnm->state_dsc.act = LV_STATE_CHECKED; if(tgl_state) btnm->state_dsc.act = LV_STATE_CHECKED;
if(ext->btn_id_pr == btn_i) btnm->state_dsc.act |= LV_STATE_PRESSED; if(ext->btn_id_pr == btn_i) btnm->state_dsc.act |= LV_STATE_PRESSED;
if(ext->btn_id_focused == btn_i) btnm->state_dsc.act |= LV_STATE_FOCUSED; if(ext->btn_id_focused == btn_i) btnm->state_dsc.act |= LV_STATE_FOCUSED;
btnm->state_dsc.prev = btnm->state_dsc.act;
lv_draw_rect_dsc_init(&draw_rect_tmp_dsc); lv_draw_rect_dsc_init(&draw_rect_tmp_dsc);
lv_draw_label_dsc_init(&draw_label_tmp_dsc); lv_draw_label_dsc_init(&draw_label_tmp_dsc);

View File

@ -681,7 +681,6 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month)); strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month));
calendar->state_dsc.act = LV_STATE_NORMAL; calendar->state_dsc.act = LV_STATE_NORMAL;
calendar->state_dsc.prev = LV_STATE_NORMAL;
lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc); lv_draw_label_dsc_init(&label_dsc);
@ -695,8 +694,6 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
if(ext->btn_pressing < 0) calendar->state_dsc.act |= LV_STATE_PRESSED; if(ext->btn_pressing < 0) calendar->state_dsc.act |= LV_STATE_PRESSED;
else calendar->state_dsc.act &= ~(LV_STATE_PRESSED); else calendar->state_dsc.act &= ~(LV_STATE_PRESSED);
calendar->state_dsc.prev = calendar->state_dsc.act;
header_area.x1 += header_left; header_area.x1 += header_left;
lv_draw_label_dsc_init(&label_dsc); lv_draw_label_dsc_init(&label_dsc);
@ -709,8 +706,6 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask)
if(ext->btn_pressing > 0) calendar->state_dsc.act |= LV_STATE_PRESSED; if(ext->btn_pressing > 0) calendar->state_dsc.act |= LV_STATE_PRESSED;
else calendar->state_dsc.act &= ~(LV_STATE_PRESSED); else calendar->state_dsc.act &= ~(LV_STATE_PRESSED);
calendar->state_dsc.prev = calendar->state_dsc.act;
header_area.x1 = header_area.x2 - header_right - lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT), font, 0, LV_TXT_FLAG_NONE); header_area.x1 = header_area.x2 - header_right - lv_txt_get_width(LV_SYMBOL_RIGHT, (uint16_t)strlen(LV_SYMBOL_RIGHT), font, 0, LV_TXT_FLAG_NONE);
lv_draw_label_dsc_init(&label_dsc); lv_draw_label_dsc_init(&label_dsc);
@ -790,7 +785,6 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
/*The state changes without re-caching the styles, disable the use of cache*/ /*The state changes without re-caching the styles, disable the use of cache*/
lv_obj_state_dsc_t state_ori = calendar->state_dsc; lv_obj_state_dsc_t state_ori = calendar->state_dsc;
calendar->state_dsc.act = LV_STATE_NORMAL; calendar->state_dsc.act = LV_STATE_NORMAL;
calendar->state_dsc.prev = LV_STATE_NORMAL;
lv_state_t month_state = LV_STATE_DISABLED; lv_state_t month_state = LV_STATE_DISABLED;
@ -882,7 +876,6 @@ static void draw_dates(lv_obj_t * calendar, const lv_area_t * clip_area)
label_dsc.flag = LV_TXT_FLAG_CENTER; label_dsc.flag = LV_TXT_FLAG_CENTER;
calendar->state_dsc.act = day_state; calendar->state_dsc.act = day_state;
calendar->state_dsc.prev = day_state;
lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE, &label_dsc); lv_obj_init_draw_label_dsc(calendar, LV_CALENDAR_PART_DATE, &label_dsc);
lv_obj_init_draw_rect_dsc(calendar, LV_CALENDAR_PART_DATE, &rect_dsc); lv_obj_init_draw_rect_dsc(calendar, LV_CALENDAR_PART_DATE, &rect_dsc);

View File

@ -948,7 +948,6 @@ static void draw_box(lv_obj_t * ddlist, const lv_area_t * clip_area, uint16_t id
page->state_dsc.act = LV_STATE_NORMAL; page->state_dsc.act = LV_STATE_NORMAL;
page->state_dsc.act |= state; page->state_dsc.act |= state;
page->state_dsc.prev = page->state_dsc.act;
/*Draw a rectangle under the selected item*/ /*Draw a rectangle under the selected item*/
const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_LIST); const lv_font_t * font = lv_obj_get_style_text_font(ddlist, LV_DROPDOWN_PART_LIST);
@ -984,7 +983,6 @@ static void draw_box_label(lv_obj_t * ddlist, const lv_area_t * clip_area, uint1
page->state_dsc.act = LV_STATE_NORMAL; page->state_dsc.act = LV_STATE_NORMAL;
page->state_dsc.act |= state; page->state_dsc.act |= state;
page->state_dsc.prev = page->state_dsc.act;
lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_t label_dsc;
lv_draw_label_dsc_init(&label_dsc); lv_draw_label_dsc_init(&label_dsc);

View File

@ -285,7 +285,7 @@ void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uin
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value); (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
uint8_t i; uint8_t i;
lv_color_t main_color = lv_obj_get_style_scale_color(lmeter, part); lv_color_t main_color = lv_obj_get_style_line_color(lmeter, part);
lv_color_t grad_color = lv_obj_get_style_scale_grad_color(lmeter, part); lv_color_t grad_color = lv_obj_get_style_scale_grad_color(lmeter, part);
lv_color_t end_color = lv_obj_get_style_scale_end_color(lmeter, part); lv_color_t end_color = lv_obj_get_style_scale_end_color(lmeter, part);