From eef239fe70db46f0e75de5ceb785fe64b57789e4 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 3 Feb 2020 20:49:34 +0100 Subject: [PATCH] add LV_STYLE_SCALE_BORDER --- src/lv_core/lv_obj.h | 2 ++ src/lv_core/lv_style.h | 2 ++ src/lv_objx/lv_list.c | 14 ++++++-------- src/lv_objx/lv_lmeter.c | 35 ++++++++++++++++++++++++++++++++-- src/lv_objx/lv_tileview.h | 2 ++ src/lv_themes/lv_theme_alien.c | 25 ++++++++++++++++++------ 6 files changed, 64 insertions(+), 16 deletions(-) diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index a8dcd242b..17da63931 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -964,6 +964,8 @@ LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_OPA, image_opa, lv_opa_t, _opa); LV_OBJ_STYLE_SET_GET_DECLARE(IMAGE_RECOLOR_OPA, image_recolor_opa, lv_opa_t, _opa); LV_OBJ_STYLE_SET_GET_DECLARE(SIZE, size, lv_style_int_t, _int); LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_WIDTH, scale_width, lv_style_int_t, _int); +LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_BORDER_WIDTH, scale_border_width, lv_style_int_t, _int); +LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_BORDER_WIDTH, scale_end_border_width, lv_style_int_t, _int); LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_COLOR, scale_color, lv_color_t, _color); LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_GRAD_COLOR, scale_grad_color, lv_color_t, _color); LV_OBJ_STYLE_SET_GET_DECLARE(SCALE_END_COLOR, scale_end_color, lv_color_t, _color); diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index 8ba37a471..75f7dcea0 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -140,6 +140,8 @@ enum { LV_STYLE_PROP_INIT(LV_STYLE_SIZE, 0x9, LV_STYLE_ID_VALUE + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_WIDTH, 0x9, LV_STYLE_ID_VALUE + 1, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_BORDER_WIDTH, 0x9, LV_STYLE_ID_VALUE + 2, LV_STYLE_ATTR_NONE), + LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_BORDER_WIDTH, 0x9, LV_STYLE_ID_VALUE + 3, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_COLOR, 0x9, LV_STYLE_ID_COLOR + 0, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_GRAD_COLOR, 0x9, LV_STYLE_ID_COLOR + 1, LV_STYLE_ATTR_NONE), LV_STYLE_PROP_INIT(LV_STYLE_SCALE_END_COLOR, 0x9, LV_STYLE_ID_COLOR + 2, LV_STYLE_ATTR_NONE), diff --git a/src/lv_objx/lv_list.c b/src/lv_objx/lv_list.c index d66177e3a..9bfd2aa1b 100644 --- a/src/lv_objx/lv_list.c +++ b/src/lv_objx/lv_list.c @@ -794,18 +794,16 @@ static lv_res_t lv_list_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * para } } } - else if(sign == LV_SIGNAL_RELEASED) { + else if(sign == LV_SIGNAL_PRESSED) { + lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn)); + lv_list_focus_btn(list, btn); #if LV_USE_GROUP - lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn)); - lv_group_t * g = lv_obj_get_group(list); - if(g && lv_indev_is_dragging(lv_indev_get_act()) == false) { + if(lv_obj_get_group(list)) { lv_group_focus_obj(list); - /*Make the released button "selected"*/ - lv_list_focus_btn(list, btn); } #endif - } else if(sign == LV_SIGNAL_CLEANUP) { - + } + else if(sign == LV_SIGNAL_CLEANUP) { #if LV_USE_GROUP lv_obj_t * list = lv_obj_get_parent(lv_obj_get_parent(btn)); lv_obj_t * sel = lv_list_get_btn_selected(list); diff --git a/src/lv_objx/lv_lmeter.c b/src/lv_objx/lv_lmeter.c index 70f4ba816..e6d83e751 100644 --- a/src/lv_objx/lv_lmeter.c +++ b/src/lv_objx/lv_lmeter.c @@ -285,7 +285,8 @@ void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_ lv_color_t main_color = lv_obj_get_style_scale_color(lmeter, part); lv_color_t grad_color = lv_obj_get_style_scale_grad_color(lmeter, part); - lv_color_t ina_color = lv_obj_get_style_scale_end_color(lmeter, part); + lv_color_t end_color = lv_obj_get_style_scale_end_color(lmeter, part); + lv_draw_line_dsc_t line_dsc; lv_draw_line_dsc_init(&line_dsc); @@ -322,11 +323,41 @@ void lv_lmeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_ p1.x = x_out + x_ofs; p1.y = y_out + y_ofs; - if(i >= level) line_dsc.color = ina_color; + if(i >= level) line_dsc.color = end_color; else line_dsc.color = lv_color_mix(grad_color, main_color, (255 * i) / ext->line_cnt); lv_draw_line(&p1, &p2, clip_area, &line_dsc); } + + if(part == LV_LMETER_PART_MAIN) { + lv_style_int_t border_width = lv_obj_get_style_scale_border_width(lmeter, part); + lv_style_int_t end_border_width = lv_obj_get_style_scale_end_border_width(lmeter, part); + + + if(border_width || end_border_width) + { + int16_t end_angle = (level * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs - 1; + lv_draw_line_dsc_t arc_dsc; + lv_draw_line_dsc_init(&arc_dsc); + lv_obj_init_draw_line_dsc(lmeter, part, &arc_dsc); + + if(border_width) { + arc_dsc.width = border_width; + arc_dsc.color = main_color; + lv_draw_arc(x_ofs, y_ofs, r_out, angle_ofs, end_angle, clip_area, &arc_dsc); + } + + if(end_border_width) { + arc_dsc.width = end_border_width; + arc_dsc.color = end_color; + lv_draw_arc(x_ofs, y_ofs, r_out, end_angle, (angle_ofs + ext->scale_angle) % 360, clip_area, &arc_dsc); + } + + + } + } + + } /********************** diff --git a/src/lv_objx/lv_tileview.h b/src/lv_objx/lv_tileview.h index 4d48af03e..e534220df 100644 --- a/src/lv_objx/lv_tileview.h +++ b/src/lv_objx/lv_tileview.h @@ -47,6 +47,8 @@ typedef struct /*Parts of the Tileview*/ enum { LV_TILEVIEW_PART_BG = LV_PAGE_PART_BG, + LV_TILEVIEW_PART_SCRLBAR = LV_PAGE_PART_SCRLBAR, + LV_TILEVIEW_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, _LV_TILEVIEW_PART_VIRTUAL_LAST = _LV_PAGE_PART_VIRTUAL_LAST, _LV_TILEVIEW_PART_REAL_LAST = _LV_PAGE_PART_REAL_LAST }; diff --git a/src/lv_themes/lv_theme_alien.c b/src/lv_themes/lv_theme_alien.c index f60275f7f..2819ca955 100644 --- a/src/lv_themes/lv_theme_alien.c +++ b/src/lv_themes/lv_theme_alien.c @@ -278,15 +278,20 @@ static void gauge_init(void) { #if LV_USE_GAUGE != 0 lv_style_init(&gauge); - lv_style_set_color(&gauge, LV_STYLE_SCALE_COLOR, LV_COLOR_AQUA); - lv_style_set_color(&gauge, LV_STYLE_SCALE_GRAD_COLOR, LV_COLOR_NAVY); - lv_style_set_color(&gauge, LV_STYLE_SCALE_END_COLOR, LV_COLOR_RED); + lv_style_set_color(&gauge, LV_STYLE_SCALE_COLOR, COLOR_DISABLED); + lv_style_set_color(&gauge, LV_STYLE_SCALE_GRAD_COLOR, COLOR_DISABLED); + lv_style_set_color(&gauge, LV_STYLE_SCALE_END_COLOR, COLOR_ACCENT); lv_style_set_int(&gauge, LV_STYLE_LINE_WIDTH, 2); + lv_style_set_int(&gauge, LV_STYLE_SCALE_END_BORDER_WIDTH, 4); + lv_style_set_opa(&gauge, LV_STYLE_BG_OPA, LV_OPA_COVER); + lv_style_set_color(&gauge, LV_STYLE_BG_COLOR, LV_COLOR_LIME); + lv_style_set_int(&gauge, LV_STYLE_SIZE, 4); + lv_style_init(&gauge_strong); - lv_style_set_color(&gauge_strong, LV_STYLE_SCALE_COLOR, LV_COLOR_AQUA); - lv_style_set_color(&gauge_strong, LV_STYLE_SCALE_GRAD_COLOR, LV_COLOR_NAVY); - lv_style_set_color(&gauge_strong, LV_STYLE_SCALE_END_COLOR, LV_COLOR_RED); + lv_style_set_color(&gauge_strong, LV_STYLE_SCALE_COLOR, COLOR_DISABLED); + lv_style_set_color(&gauge_strong, LV_STYLE_SCALE_GRAD_COLOR, COLOR_DISABLED); + lv_style_set_color(&gauge_strong, LV_STYLE_SCALE_END_COLOR, COLOR_ACCENT); lv_style_set_int(&gauge_strong, LV_STYLE_LINE_WIDTH, 4); lv_style_set_int(&gauge_strong, LV_STYLE_SCALE_WIDTH, LV_DPI/5); lv_style_set_int(&gauge_strong, LV_STYLE_PAD_INNER, LV_DPI/10); @@ -896,6 +901,14 @@ void lv_theme_alien_apply(lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_BG); lv_style_list_reset(list); lv_style_list_add_style(list, &scr); + + list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_SCRLBAR); + lv_style_list_reset(list); + lv_style_list_add_style(list, &sb); + + list = lv_obj_get_style_list(obj, LV_TILEVIEW_PART_EDGE_FLASH); + lv_style_list_reset(list); + lv_style_list_add_style(list, &btn); break; #endif