diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 2f0fbdce9f..30cd34b1ee 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -1,5 +1,5 @@ /** - * @file lv_base_obj.c + * @file lv_obj.c * */ @@ -70,7 +70,7 @@ typedef struct { lv_opa_t _opa; const void * _ptr; }end_value; -}lv_anim_trans_t; +}lv_style_trans_t; /********************** * STATIC PROTOTYPES @@ -83,14 +83,14 @@ static void refresh_children_style(lv_obj_t * obj); static void delete_children(lv_obj_t * obj); static void base_dir_refr_children(lv_obj_t * obj); #if LV_USE_ANIMATION -static void trans_anim_cb(lv_anim_trans_t * tr, lv_anim_value_t v); +static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v); static void trans_anim_start_cb(lv_anim_t * a); static void trans_anim_ready_cb(lv_anim_t * a); static void opa_scale_anim(lv_obj_t * obj, lv_anim_value_t v); #endif static void lv_event_mark_deleted(lv_obj_t * obj); static void lv_obj_del_async_cb(void * obj); -static lv_anim_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state); +static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state); static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop); /********************** @@ -137,8 +137,7 @@ void lv_init(void) lv_group_init(); #endif - lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(lv_anim_trans_t)); - + lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(lv_style_trans_t)); lv_theme_t * th = LV_THEME_DEFAULT_INIT(LV_THEME_DEFAULT_COLOR_PRIMARY, LV_THEME_DEFAULT_COLOR_SECONDARY, LV_THEME_DEFAULT_FLAGS, @@ -1122,6 +1121,8 @@ void lv_obj_add_style(lv_obj_t * obj, uint8_t part, lv_style_t * style) lv_style_list_add_style(style_dsc, style); + trans_del(obj, part, 0xFF); + lv_obj_refresh_style(obj); } @@ -1177,6 +1178,7 @@ void _lv_obj_set_style_int(lv_obj_t * obj, uint8_t part, lv_style_property_t pro { lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part); lv_style_list_set_local_int(style_dsc, prop, value); + trans_del(obj, part, prop); lv_obj_refresh_style(obj); } @@ -1196,6 +1198,7 @@ void _lv_obj_set_style_color(lv_obj_t * obj, uint8_t part, lv_style_property_t p { lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part); lv_style_list_set_local_color(style_dsc, prop, color); + trans_del(obj, part, prop); lv_obj_refresh_style(obj); } @@ -1215,6 +1218,7 @@ void _lv_obj_set_style_opa(lv_obj_t * obj, uint8_t part, lv_style_property_t pro { lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part); lv_style_list_set_local_opa(style_dsc, prop, opa); + trans_del(obj, part, prop); lv_obj_refresh_style(obj); } @@ -1234,6 +1238,7 @@ void _lv_obj_set_style_ptr(lv_obj_t * obj, uint8_t part, lv_style_property_t pro { lv_style_list_t * style_dsc = lv_obj_get_style_list(obj, part); lv_style_list_set_local_ptr(style_dsc, prop, p); + trans_del(obj, part, prop); lv_obj_refresh_style(obj); } @@ -1508,7 +1513,7 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) if(props[i] != 0) { lv_style_list_add_trans_style(style_list); - lv_anim_trans_t * tr = trans_create(obj, props[i], part, prev_state, new_state); + lv_style_trans_t * tr = trans_create(obj, props[i], part, prev_state, new_state); /*If there is a pending anim for this property remove it*/ if(tr) { @@ -1543,9 +1548,9 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) } -static lv_anim_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state) +static lv_style_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, uint8_t part, lv_state_t prev_state, lv_state_t new_state) { - lv_anim_trans_t * tr; + lv_style_trans_t * tr; lv_style_list_t * style_list = lv_obj_get_style_list(obj, part); lv_style_t * style_trans = lv_style_list_get_trans_style(style_list); @@ -1645,8 +1650,8 @@ static lv_anim_trans_t * trans_create(lv_obj_t * obj, lv_style_property_t prop, static void trans_del(lv_obj_t * obj, uint8_t part, lv_style_property_t prop) { - lv_anim_trans_t * tr; - lv_anim_trans_t * tr_next; + lv_style_trans_t * tr; + lv_style_trans_t * tr_next; tr = lv_ll_get_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); while(tr != NULL) { /*'tr' might be deleted, so get the next object while 'tr' is valid*/ @@ -3014,8 +3019,8 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t if(draw_dsc->shadow_width) { draw_dsc->shadow_opa = lv_obj_get_style_shadow_opa(obj, part); if(draw_dsc->shadow_opa > LV_OPA_MIN) { - draw_dsc->shadow_ofs_x = lv_obj_get_style_shadow_offset_x(obj, part); - draw_dsc->shadow_ofs_y = lv_obj_get_style_shadow_offset_y(obj, part); + draw_dsc->shadow_ofs_x = lv_obj_get_style_shadow_ofs_x(obj, part); + draw_dsc->shadow_ofs_y = lv_obj_get_style_shadow_ofs_y(obj, part); draw_dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, part); draw_dsc->shadow_color = lv_obj_get_style_shadow_color(obj, part); #if LV_USE_BLEND_MODES @@ -3158,8 +3163,8 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) sh_width = sh_width / 2; /*THe blur adds only half width*/ sh_width++; sh_width += lv_obj_get_style_shadow_spread(obj, part); - sh_width += LV_MATH_MAX(LV_MATH_ABS(lv_obj_get_style_shadow_offset_x(obj, part)), - LV_MATH_ABS(lv_obj_get_style_shadow_offset_y(obj, part))); + sh_width += LV_MATH_MAX(LV_MATH_ABS(lv_obj_get_style_shadow_ofs_x(obj, part)), + LV_MATH_ABS(lv_obj_get_style_shadow_ofs_y(obj, part))); s = LV_MATH_MAX(s, sh_width); } } @@ -3207,6 +3212,12 @@ lv_coord_t lv_obj_get_draw_rect_ext_pad_size(lv_obj_t * obj, uint8_t part) s = LV_MATH_MAX(s, outline_pad + outline_width); } } + + lv_coord_t w = lv_obj_get_style_width(obj, part); + lv_coord_t h = lv_obj_get_style_height(obj, part); + lv_coord_t wh = LV_MATH_MAX(w, h); + if(wh > 0) s += wh; + return s; } @@ -3284,7 +3295,16 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area if(mode == LV_DESIGN_COVER_CHK) { /*Most trivial test. Is the mask fully IN the object? If no it surely doesn't cover it*/ lv_coord_t r = lv_obj_get_style_radius(obj, LV_OBJ_PART_MAIN); - if(lv_area_is_in(clip_area, &obj->coords, r) == false) return LV_DESIGN_RES_NOT_COVER; + lv_coord_t w = lv_obj_get_style_width(obj, LV_OBJ_PART_MAIN); + lv_coord_t h = lv_obj_get_style_height(obj, LV_OBJ_PART_MAIN); + lv_area_t coords; + lv_area_copy(&coords, &obj->coords); + coords.x1 -= w; + coords.x2 += w; + coords.y1 -= h; + coords.y2 += h; + + if(lv_area_is_in(clip_area, &coords, r) == false) return LV_DESIGN_RES_NOT_COVER; if(lv_obj_get_style_clip_corner(obj, LV_OBJ_PART_MAIN)) return LV_DESIGN_RES_MASKED; @@ -3306,7 +3326,18 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area } lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc); - lv_draw_rect(&obj->coords, clip_area, &draw_dsc); + + + lv_coord_t w = lv_obj_get_style_width(obj, LV_OBJ_PART_MAIN); + lv_coord_t h = lv_obj_get_style_height(obj, LV_OBJ_PART_MAIN); + lv_area_t coords; + lv_area_copy(&coords, &obj->coords); + coords.x1 -= w; + coords.x2 += w; + coords.y1 -= h; + coords.y2 += h; + + lv_draw_rect(&coords, clip_area, &draw_dsc); if(lv_obj_get_style_clip_corner(obj, LV_OBJ_PART_MAIN)) { lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); @@ -3332,7 +3363,16 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area draw_dsc.pattern_opa = LV_OPA_TRANSP; draw_dsc.shadow_opa = LV_OPA_TRANSP; lv_obj_init_draw_rect_dsc(obj, LV_OBJ_PART_MAIN, &draw_dsc); - lv_draw_rect(&obj->coords, clip_area, &draw_dsc); + + lv_coord_t w = lv_obj_get_style_width(obj, LV_OBJ_PART_MAIN); + lv_coord_t h = lv_obj_get_style_height(obj, LV_OBJ_PART_MAIN); + lv_area_t coords; + lv_area_copy(&coords, &obj->coords); + coords.x1 -= w; + coords.x2 += w; + coords.y1 -= h; + coords.y2 += h; + lv_draw_rect(&coords, clip_area, &draw_dsc); } } @@ -3564,7 +3604,7 @@ static void base_dir_refr_children(lv_obj_t * obj) #if LV_USE_ANIMATION -static void trans_anim_cb(lv_anim_trans_t * tr, lv_anim_value_t v) +static void trans_anim_cb(lv_style_trans_t * tr, lv_anim_value_t v) { lv_style_list_t * list = lv_obj_get_style_list(tr->obj, tr->part); lv_style_t * style = lv_style_list_get_trans_style(list); @@ -3578,15 +3618,15 @@ static void trans_anim_cb(lv_anim_trans_t * tr, lv_anim_value_t v) } else if((tr->prop & 0xF) < LV_STYLE_ID_OPA) { /*Color*/ lv_color_t x; - if(v == 0) x = tr->start_value._color; - else if(v == 255) x = tr->end_value._color; + if(v <= 0) x = tr->start_value._color; + else if(v >= 255) x = tr->end_value._color; else x = lv_color_mix(tr->end_value._color, tr->start_value._color, v); _lv_style_set_color(style, tr->prop, x); } else if((tr->prop & 0xF) < LV_STYLE_ID_PTR) { /*Opa*/ lv_opa_t x; - if(v == 0) x = tr->start_value._opa; - else if(v == 255) x = tr->end_value._opa; + if(v <= 0) x = tr->start_value._opa; + else if(v >= 255) x = tr->end_value._opa; else x = tr->start_value._opa + (((tr->end_value._opa - tr->start_value._opa) * v) >> 8); _lv_style_set_opa(style, tr->prop, x); } else { @@ -3601,7 +3641,7 @@ static void trans_anim_cb(lv_anim_trans_t * tr, lv_anim_value_t v) static void trans_anim_start_cb(lv_anim_t * a) { - lv_anim_trans_t * tr = a->var; + lv_style_trans_t * tr = a->var; lv_style_property_t prop_tmp = tr->prop; /*Init prop to an invalid values to be sure `trans_del` won't delete the just added `tr`*/ @@ -3629,7 +3669,7 @@ static void trans_anim_start_cb(lv_anim_t * a) static void trans_anim_ready_cb(lv_anim_t * a) { - lv_anim_trans_t * tr = a->var; + lv_style_trans_t * tr = a->var; lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); lv_mem_free(tr); } diff --git a/src/lv_core/lv_obj_style_dec.h b/src/lv_core/lv_obj_style_dec.h index 947137f900..cc3fb9f9a0 100644 --- a/src/lv_core/lv_obj_style_dec.h +++ b/src/lv_core/lv_obj_style_dec.h @@ -70,6 +70,8 @@ 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(CLIP_CORNER, clip_corner, bool, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int, scalar) +_LV_OBJ_STYLE_SET_GET_DECLARE(WIDTH, width, lv_style_int_t, _int, scalar) +_LV_OBJ_STYLE_SET_GET_DECLARE(HEIGHT, height, 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(PAD_TOP, pad_top, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(PAD_BOTTOM, pad_bottom, lv_style_int_t, _int, scalar) @@ -95,8 +97,8 @@ _LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_BLEND_MODE, outline_blend_mode, lv_blend_m _LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_COLOR, outline_color, lv_color_t, _color, nonscalar) _LV_OBJ_STYLE_SET_GET_DECLARE(OUTLINE_OPA, outline_opa, lv_opa_t, _opa, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_WIDTH, shadow_width, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFFSET_X, shadow_offset_x, lv_style_int_t, _int, scalar) -_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFFSET_Y, shadow_offset_y, lv_style_int_t, _int, scalar) +_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_X, shadow_ofs_x, lv_style_int_t, _int, scalar) +_LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_OFS_Y, shadow_ofs_y, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_SPREAD, shadow_spread, lv_style_int_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_BLEND_MODE, shadow_blend_mode, lv_blend_mode_t, _int, scalar) _LV_OBJ_STYLE_SET_GET_DECLARE(SHADOW_COLOR, shadow_color, lv_color_t, _color, nonscalar) diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 41e2316966..f3de5c3ed5 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -96,6 +96,8 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_RADIUS, 0x0, LV_STYLE_ID_VALUE + 1, 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_WIDTH, 0x0, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_HEIGHT, 0x0, LV_STYLE_ID_VALUE + 5, 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_PAD_TOP, 0x1, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), @@ -126,8 +128,8 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_OUTLINE_OPA, 0x4, LV_STYLE_ID_OPA + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_WIDTH, 0x5, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFFSET_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), - LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFFSET_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_X, 0x5, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_OFS_Y, 0x5, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_SPREAD, 0x5, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_BLEND_MODE, 0x5, LV_STYLE_ID_VALUE + 4, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SHADOW_COLOR, 0x5, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index fef2101a0d..3f27469e89 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -222,7 +222,6 @@ 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_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_PRESSED, BORDER_WIDTH * 2); 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_PRESSED, color_btn_txt(LV_STATE_PRESSED)); @@ -245,14 +244,9 @@ static void basic_init(void) lv_style_set_outline_opa(&btn, LV_STATE_NORMAL, LV_OPA_0); lv_style_set_outline_opa(&btn, LV_STATE_FOCUSED, LV_OPA_50); lv_style_set_outline_color(&btn, LV_STATE_NORMAL, _color_primary); - lv_style_set_trans_time(&btn, LV_STATE_NORMAL, TRANSITION_TIME); - -// lv_style_set_trans_path(&btn, LV_STATE_PRESSED, lv_anim_path_overshoot); -// lv_style_set_trans_path(&btn, LV_STATE_NORMAL, lv_anim_path_linear); - lv_style_set_trans_prop_1(&btn, LV_STATE_NORMAL, LV_STYLE_BORDER_WIDTH); - lv_style_set_trans_prop_2(&btn, LV_STATE_NORMAL, LV_STYLE_OUTLINE_OPA); - lv_style_set_trans_prop_3(&btn, LV_STATE_NORMAL, LV_STYLE_BG_COLOR); + lv_style_set_trans_prop_5(&btn, LV_STATE_NORMAL, LV_STYLE_BG_COLOR); + lv_style_set_trans_prop_6(&btn, LV_STATE_NORMAL, LV_STYLE_OUTLINE_OPA); lv_style_set_trans_delay(&btn, LV_STATE_NORMAL, 100); lv_style_set_trans_delay(&btn, LV_STATE_PRESSED, 0); } @@ -286,9 +280,12 @@ static void bar_init(void) lv_style_set_bg_opa(&bar_bg, LV_STATE_NORMAL, LV_OPA_COVER); lv_style_set_bg_color(&bar_bg, LV_STATE_NORMAL, color_bg(LV_STATE_NORMAL)); lv_style_set_value_color(&bar_bg, LV_STATE_NORMAL, LV_COLOR_WHITE); - lv_style_set_outline_color(&bar_bg, LV_STATE_FOCUSED, _color_primary); + lv_style_set_outline_color(&bar_bg, LV_STATE_NORMAL, _color_primary); + lv_style_set_outline_opa(&bar_bg, LV_STATE_NORMAL, LV_OPA_TRANSP); lv_style_set_outline_opa(&bar_bg, LV_STATE_FOCUSED, LV_OPA_50); - lv_style_set_outline_width(&bar_bg, LV_STATE_FOCUSED, 3); + lv_style_set_outline_width(&bar_bg, LV_STATE_NORMAL, 3); + lv_style_set_trans_time(&bar_bg, LV_STATE_NORMAL, TRANSITION_TIME); + lv_style_set_trans_prop_6(&bar_bg, LV_STATE_NORMAL, LV_STYLE_OUTLINE_OPA); lv_style_init(&bar_indic); lv_style_set_bg_opa(&bar_indic, LV_STATE_NORMAL, LV_OPA_COVER); @@ -335,15 +332,12 @@ static void slider_init(void) lv_style_init(&slider_knob); lv_style_set_bg_opa(&slider_knob, LV_STATE_NORMAL, LV_OPA_COVER); lv_style_set_bg_color(&slider_knob, LV_STATE_NORMAL, LV_COLOR_WHITE); - lv_style_set_bg_color(&slider_knob, LV_STATE_FOCUSED, LV_COLOR_RED); lv_style_set_value_color(&slider_knob, LV_STATE_NORMAL, LV_COLOR_WHITE); lv_style_set_radius(&slider_knob, LV_STATE_NORMAL, LV_RADIUS_CIRCLE); lv_style_set_pad_left(&slider_knob, LV_STATE_NORMAL, LV_DPI/20); lv_style_set_pad_right(&slider_knob, LV_STATE_NORMAL, LV_DPI/20); lv_style_set_pad_top(&slider_knob, LV_STATE_NORMAL, LV_DPI/20); lv_style_set_pad_bottom(&slider_knob, LV_STATE_NORMAL, LV_DPI/20); - lv_style_set_trans_time(&slider_knob, LV_STATE_NORMAL, 500); - lv_style_set_trans_prop_1(&slider_knob, LV_STATE_NORMAL, LV_STYLE_BG_COLOR); #endif } @@ -449,7 +443,6 @@ static void spinner_init(void) static void chart_init(void) { #if LV_USE_CHART - lv_style_init(&chart_series_bg); lv_style_set_line_width(&chart_series_bg, LV_STATE_NORMAL , 1); lv_style_set_line_dash_width(&chart_series_bg, LV_STATE_NORMAL, 4); @@ -457,8 +450,7 @@ static void chart_init(void) lv_style_set_pad_bottom(&chart_series_bg, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_left(&chart_series_bg, LV_STATE_NORMAL, LV_DPI / 10); lv_style_set_pad_right(&chart_series_bg, LV_STATE_NORMAL, LV_DPI / 10); - lv_style_set_line_color(&chart_series_bg, LV_STATE_NORMAL, lv_color_hex3(0x888)); - + lv_style_set_line_color(&chart_series_bg, LV_STATE_NORMAL, lv_color_hex3(0x555)); lv_style_init(&chart_series); lv_style_set_line_width(&chart_series, LV_STATE_NORMAL, 1); @@ -539,24 +531,28 @@ static void checkbox_init(void) lv_style_init(&cb_bg); lv_style_set_radius(&cb_bg, LV_STATE_NORMAL, LV_DPI / 50); lv_style_set_pad_inner(&cb_bg, LV_STATE_NORMAL , LV_DPI / 20); - lv_style_set_outline_color(&cb_bg, LV_STATE_FOCUSED, _color_primary); + lv_style_set_outline_color(&cb_bg, LV_STATE_NORMAL, _color_primary); + lv_style_set_outline_opa(&cb_bg, LV_STATE_NORMAL, LV_OPA_TRANSP); lv_style_set_outline_opa(&cb_bg, LV_STATE_FOCUSED, LV_OPA_50); - lv_style_set_outline_width(&cb_bg, LV_STATE_FOCUSED, 3); - lv_style_set_outline_pad(&cb_bg, LV_STATE_FOCUSED, LV_DPI/20); + lv_style_set_outline_width(&cb_bg, LV_STATE_NORMAL, 3); + lv_style_set_outline_pad(&cb_bg, LV_STATE_NORMAL, LV_DPI/20); + lv_style_set_trans_time(&cb_bg, LV_STATE_NORMAL, TRANSITION_TIME); + lv_style_set_trans_prop_6(&cb_bg, LV_STATE_NORMAL, LV_STYLE_OUTLINE_OPA); lv_style_init(&cb_bullet); lv_style_set_radius(&cb_bullet, LV_STATE_NORMAL, LV_DPI / 50); lv_style_set_bg_color(&cb_bullet, LV_STATE_NORMAL, _color_primary); - lv_style_set_bg_opa(&cb_bullet, LV_STATE_NORMAL , LV_OPA_TRANSP); - lv_style_set_bg_opa(&cb_bullet, LV_STATE_CHECKED , LV_OPA_COVER); - lv_style_set_border_width(&cb_bullet, LV_STATE_NORMAL , 2); - lv_style_set_border_color(&cb_bullet, LV_STATE_NORMAL , color_bg_border(LV_STATE_NORMAL)); - lv_style_set_border_color(&cb_bullet, LV_STATE_PRESSED , color_bg_border(LV_STATE_PRESSED)); - lv_style_set_border_opa(&cb_bullet, LV_STATE_CHECKED , LV_OPA_80); + lv_style_set_bg_opa(&cb_bullet, LV_STATE_CHECKED, LV_OPA_COVER); + lv_style_set_border_width(&cb_bullet, LV_STATE_NORMAL, BORDER_WIDTH); + lv_style_set_border_color(&cb_bullet, LV_STATE_NORMAL, color_bg_border(LV_STATE_NORMAL)); + lv_style_set_border_color(&cb_bullet, LV_STATE_PRESSED, color_bg_border(LV_STATE_PRESSED)); + lv_style_set_border_opa(&cb_bullet, LV_STATE_CHECKED, LV_OPA_80); 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_text_font(&cb_bullet, LV_STATE_CHECKED, _font_small); lv_style_set_trans_time(&cb_bullet, LV_STATE_NORMAL , TRANSITION_TIME); + lv_style_set_trans_prop_5(&cb_bullet, LV_STATE_NORMAL, LV_STYLE_BG_OPA); + lv_style_set_trans_prop_6(&cb_bullet, LV_STATE_NORMAL, LV_STYLE_BORDER_COLOR); #endif } @@ -646,6 +642,7 @@ static void textarea_init(void) 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_trans_time(&ta_oneline, LV_STATE_NORMAL, TRANSITION_TIME); + lv_style_set_trans_prop_6(&ta_oneline, LV_STATE_NORMAL, LV_STYLE_BORDER_COLOR); lv_style_init(&ta_placeholder); lv_style_set_text_color(&ta_placeholder, LV_STATE_NORMAL, lv_color_hex(0x3b3e43)); @@ -686,7 +683,6 @@ static void list_init(void) lv_style_set_radius(&list_btn, LV_STATE_CHECKED, 0); lv_style_set_bg_opa(&list_btn, LV_STATE_PRESSED, LV_OPA_COVER); lv_style_set_bg_opa(&list_btn, LV_STATE_CHECKED , LV_OPA_COVER); - lv_style_set_bg_opa(&list_btn, LV_STATE_NORMAL, LV_OPA_TRANSP); lv_style_set_bg_color(&list_btn, LV_STATE_NORMAL, color_btn(LV_STATE_NORMAL)); lv_style_set_bg_color(&list_btn, LV_STATE_PRESSED, color_btn(LV_STATE_PRESSED)); lv_style_set_bg_color(&list_btn, LV_STATE_DISABLED, color_btn(LV_STATE_DISABLED)); @@ -699,8 +695,6 @@ static void list_init(void) lv_style_set_image_recolor(&list_btn, LV_STATE_PRESSED, color_btn_txt(LV_STATE_PRESSED)); lv_style_set_image_recolor(&list_btn, LV_STATE_DISABLED, color_btn_txt(LV_STATE_DISABLED)); - - lv_style_set_border_opa(&list_btn, LV_STATE_NORMAL, LV_OPA_COVER); lv_style_set_border_width(&list_btn, LV_STATE_NORMAL, 1); lv_style_set_border_side(&list_btn, LV_STATE_NORMAL, LV_BORDER_SIDE_BOTTOM); lv_style_set_border_color(&list_btn, LV_STATE_NORMAL, lv_color_hex(0x979a9f)); @@ -713,7 +707,9 @@ static void list_init(void) 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_trans_time(&list_btn, LV_STATE_NORMAL, TRANSITION_TIME); - + lv_style_set_trans_prop_4(&list_btn, LV_STATE_NORMAL, LV_STYLE_RADIUS); + lv_style_set_trans_prop_5(&list_btn, LV_STATE_NORMAL, LV_STYLE_BG_OPA); + lv_style_set_trans_prop_6(&list_btn, LV_STATE_NORMAL, LV_STYLE_BG_OPA); #endif } @@ -1458,7 +1454,7 @@ static inline lv_color_t color_btn(lv_state_t state) case LV_STATE_CHECKED: return _color_primary; case LV_STATE_CHECKED | LV_STATE_PRESSED: - return lv_color_hex(0x006adb); + return lv_color_lighten(_color_primary, LV_OPA_20); case LV_STATE_FOCUSED: case LV_STATE_EDITED: case LV_STATE_HOVERED: diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index e29e21f61c..bd91f0437a 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -79,7 +79,6 @@ lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy) ext->arc_angle_end = 270; lv_style_list_init(&ext->style_arc); - lv_obj_set_size(arc, LV_DPI, LV_DPI); /*The signal and design functions are not copied so set them here*/ @@ -419,7 +418,6 @@ static lv_res_t lv_arc_signal(lv_obj_t * arc, lv_signal_t sign, void * param) if(sign == LV_SIGNAL_GET_TYPE) return lv_obj_handle_get_type_signal(param, LV_OBJX_NAME); if(sign == LV_SIGNAL_CLEANUP) { - lv_arc_ext_t * ext = lv_obj_get_ext_attr(arc); lv_obj_clean_style_list(arc, LV_ARC_PART_ARC); } diff --git a/src/lv_widgets/lv_gauge.c b/src/lv_widgets/lv_gauge.c index 0efd038507..97125d7e07 100644 --- a/src/lv_widgets/lv_gauge.c +++ b/src/lv_widgets/lv_gauge.c @@ -103,7 +103,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, LV_GAUGE_DEF_LABEL_COUNT); lv_gauge_set_needle_count(new_gauge, 1, NULL); lv_gauge_set_critical_value(new_gauge, 80); - lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI); + lv_obj_set_size(new_gauge, 3 * LV_DPI / 2, 3 * LV_DPI / 2); lv_theme_apply(new_gauge, LV_THEME_GAUGE); diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index 3ee09bd1d4..96e7a6f5ff 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -1023,11 +1023,20 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_ else if(mode == LV_DESIGN_DRAW_MAIN) { lv_label_ext_t * ext = lv_obj_get_ext_attr(label); + lv_coord_t w = lv_obj_get_style_width(label, LV_LABEL_PART_MAIN); + lv_coord_t h = lv_obj_get_style_height(label, LV_LABEL_PART_MAIN); + lv_area_t bg_coords; + lv_area_copy(&bg_coords, &label->coords); + bg_coords.x1 -= w; + bg_coords.x2 += w; + bg_coords.y1 -= h; + bg_coords.y2 += h; + lv_draw_rect_dsc_t draw_rect_dsc; lv_draw_rect_dsc_init(&draw_rect_dsc); lv_obj_init_draw_rect_dsc(label, LV_LABEL_PART_MAIN, &draw_rect_dsc); - lv_draw_rect(&label->coords, clip_area, &draw_rect_dsc); + lv_draw_rect(&bg_coords, clip_area, &draw_rect_dsc); lv_area_t txt_coords; get_txt_coords(label, &txt_coords); @@ -1036,7 +1045,6 @@ static lv_design_res_t lv_label_design(lv_obj_t * label, const lv_area_t * clip_ bool is_common = lv_area_intersect(&txt_clip, clip_area, &txt_coords); if(!is_common) return LV_DESIGN_RES_OK; - lv_label_align_t align = lv_label_get_align(label); lv_txt_flag_t flag = LV_TXT_FLAG_NONE; diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index fa4cd9dbc5..e42f2f48c6 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -7,7 +7,7 @@ * INCLUDES *********************/ #include "lv_linemeter.h" -#if LV_USE_LMETER != 0 +#if LV_USE_LINEMETER != 0 #include "../lv_core/lv_debug.h" #include "../lv_draw/lv_draw.h"