diff --git a/lv_conf_template.h b/lv_conf_template.h index 832a3aabe..7471b8d13 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -460,8 +460,12 @@ typedef void * lv_user_data_t; /* A simple, impressive and very complete theme */ #define LV_USE_THEME_DEFAULT 1 #if LV_USE_THEME_DEFAULT + /* 1: Light mode; 0: Dark mode*/ -# define LV_THEME_DEFAULT_FLAG_LIGHT 1 +# define LV_THEME_DEFAULT_PALETTE_LIGHT 1 + +/* 1: Enable grow on press*/ +# define LV_THEME_DEFAULT_GROW 0 /*Default transition time in [ms]*/ # define LV_THEME_DEFAULT_TRANSITON_TIME 80 diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index eafee398f..865ee8a7f 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -71,7 +71,7 @@ #define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITON_TIME #define BORDER_WIDTH LV_DPX(2) #define OUTLINE_WIDTH LV_DPX(2) -#define IS_LIGHT (LV_THEME_DEFAULT_FLAG_LIGHT) +#define IS_LIGHT (LV_THEME_DEFAULT_PALETTE_LIGHT) #define PAD_DEF LV_DPX(15) //(lv_disp_get_size_category(NULL) <= LV_DISP_SIZE_MEDIUM ? LV_DPX(15) : (LV_DPX(30))) @@ -105,7 +105,9 @@ typedef struct { lv_style_t circle; lv_style_t no_radius; lv_style_t clip_corner; +#if LV_THEME_DEFAULT_GROW lv_style_t grow; +#endif lv_style_t transition_delayed; lv_style_t transition_normal; lv_style_t anim; @@ -334,9 +336,11 @@ static void style_init(void) style_init_reset(&styles->no_radius); lv_style_set_radius(&styles->no_radius, 0); +#if LV_THEME_DEFAULT_GROW style_init_reset(&styles->grow); lv_style_set_transform_width(&styles->grow, LV_DPX(3)); lv_style_set_transform_height(&styles->grow, LV_DPX(3)); +#endif style_init_reset(&styles->knob); lv_style_set_bg_color(&styles->knob, IS_LIGHT ? theme.color_primary : LV_COLOR_WHITE); @@ -578,7 +582,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_delayed); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal); +#if LV_THEME_DEFAULT_GROW lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->grow); +#endif lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->bg_color_secondary); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DISABLED, &styles->disabled); } @@ -636,7 +642,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->bg_color_primary); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->knob); +#if LV_THEME_DEFAULT_GROW lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_PRESSED, &styles->grow); +#endif lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->transition_delayed); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_PRESSED, &styles->transition_normal); } @@ -665,7 +673,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_CHECKED, &styles->bg_color_primary); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_CHECKED, &styles->cb_marker_checked); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_PRESSED, &styles->pressed); +#if LV_THEME_DEFAULT_GROW lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_PRESSED, &styles->grow); +#endif lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_PRESSED, &styles->transition_normal); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->transition_delayed); } @@ -719,7 +729,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_delayed); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal); +#if LV_THEME_DEFAULT_GROW lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->grow); +#endif lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->ddlist_flip); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_normal); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 9900b49ee..2233c0774 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -401,7 +401,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ # ifdef CONFIG_LV_ASSERT_HANDLER_INCLUDE # define LV_ASSERT_HANDLER_INCLUDE CONFIG_LV_ASSERT_HANDLER_INCLUDE # else -# define LV_ASSERT_HANDLER_INCLUDE +# define LV_ASSERT_HANDLER_INCLUDE # endif #endif #ifndef LV_ASSERT_HANDLER @@ -1371,12 +1371,22 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */ # endif #endif #if LV_USE_THEME_DEFAULT + /* 1: Light mode; 0: Dark mode*/ -#ifndef LV_THEME_DEFAULT_FLAG_LIGHT -# ifdef CONFIG_LV_THEME_DEFAULT_FLAG_LIGHT -# define LV_THEME_DEFAULT_FLAG_LIGHT CONFIG_LV_THEME_DEFAULT_FLAG_LIGHT +#ifndef LV_THEME_DEFAULT_PALETTE_LIGHT +# ifdef CONFIG_LV_THEME_DEFAULT_PALETTE_LIGHT +# define LV_THEME_DEFAULT_PALETTE_LIGHT CONFIG_LV_THEME_DEFAULT_PALETTE_LIGHT # else -# define LV_THEME_DEFAULT_FLAG_LIGHT 1 +# define LV_THEME_DEFAULT_PALETTE_LIGHT 1 +# endif +#endif + +/* 1: Enable grow on press*/ +#ifndef LV_THEME_DEFAULT_GROW +# ifdef CONFIG_LV_THEME_DEFAULT_GROW +# define LV_THEME_DEFAULT_GROW CONFIG_LV_THEME_DEFAULT_GROW +# else +# define LV_THEME_DEFAULT_GROW 0 # endif #endif diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index c707c91ca..574969ff3 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -890,6 +890,13 @@ static void indev_proc_release(lv_indev_proc_t * proc) /*Forget the act obj and send a released signal */ if(indev_obj_act) { + /*Send RELEASE signal and event*/ + lv_signal_send(indev_obj_act, LV_SIGNAL_RELEASED, indev_act); + if(indev_reset_check(proc)) return; + + lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL); + if(indev_reset_check(proc)) return; + /*Send CLICK if no scrolling*/ if(scroll_obj == NULL) { if(proc->long_pr_sent == 0) { @@ -901,13 +908,6 @@ static void indev_proc_release(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } - /*Send RELEASE signal and event*/ - lv_signal_send(indev_obj_act, LV_SIGNAL_RELEASED, indev_act); - if(indev_reset_check(proc)) return; - - lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL); - if(indev_reset_check(proc)) return; - proc->types.pointer.act_obj = NULL; proc->pr_timestamp = 0; proc->longpr_rep_timestamp = 0; diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 1afecb015..8e631bc64 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -195,7 +195,7 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, void * param) /*Nothing to do if no event function and not bubbled*/ lv_event_dsc_t * event_dsc = lv_obj_get_event_dsc(obj, 0); - if((event_dsc == NULL || event_dsc->cb == NULL) && lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) == false) { + if(event_dsc == NULL && lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) == false) { return LV_RES_OK; } diff --git a/src/lv_core/lv_obj_pos.c b/src/lv_core/lv_obj_pos.c index a9136efa0..7b664e924 100644 --- a/src/lv_core/lv_obj_pos.c +++ b/src/lv_core/lv_obj_pos.c @@ -221,12 +221,12 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co case LV_ALIGN_IN_LEFT_MID: x = 0; - y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2 - pleft; + y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2; break; case LV_ALIGN_IN_RIGHT_MID: x = lv_obj_get_width_fit(base) - lv_obj_get_width(obj); - y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2 - pleft; + y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height(obj) / 2; break; case LV_ALIGN_OUT_TOP_LEFT: @@ -490,36 +490,38 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area) /*Invalidate the object only if it belongs to the current or previous'*/ lv_obj_t * obj_scr = lv_obj_get_screen(obj); lv_disp_t * disp = lv_obj_get_disp(obj_scr); - if(obj_scr == lv_disp_get_scr_act(disp) || - obj_scr == lv_disp_get_scr_prev(disp) || - obj_scr == lv_disp_get_layer_top(disp) || - obj_scr == lv_disp_get_layer_sys(disp)) { - - /*Truncate the area to the object*/ - lv_area_t obj_coords; - lv_coord_t ext_size = _lv_obj_get_ext_draw_size(obj); - lv_area_copy(&obj_coords, &obj->coords); - obj_coords.x1 -= ext_size; - obj_coords.y1 -= ext_size; - obj_coords.x2 += ext_size; - obj_coords.y2 += ext_size; - - bool is_common; - - is_common = _lv_area_intersect(area, area, &obj_coords); - if(is_common == false) return false; /*The area is not on the object*/ - - /*Truncate recursively to the parents*/ - lv_obj_t * par = lv_obj_get_parent(obj); - while(par != NULL) { - is_common = _lv_area_intersect(area, area, &par->coords); - if(is_common == false) return false; /*If no common parts with parent break;*/ - if(lv_obj_has_flag(par, LV_OBJ_FLAG_HIDDEN)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/ - - par = lv_obj_get_parent(par); - } + if(obj_scr != lv_disp_get_scr_act(disp) && + obj_scr != lv_disp_get_scr_prev(disp) && + obj_scr != lv_disp_get_layer_top(disp) && + obj_scr != lv_disp_get_layer_sys(disp)) + { + return false; } + /*Truncate the area to the object*/ + lv_area_t obj_coords; + lv_coord_t ext_size = _lv_obj_get_ext_draw_size(obj); + lv_area_copy(&obj_coords, &obj->coords); + obj_coords.x1 -= ext_size; + obj_coords.y1 -= ext_size; + obj_coords.x2 += ext_size; + obj_coords.y2 += ext_size; + + bool is_common; + + is_common = _lv_area_intersect(area, area, &obj_coords); + if(is_common == false) return false; /*The area is not on the object*/ + + /*Truncate recursively to the parents*/ + lv_obj_t * par = lv_obj_get_parent(obj); + while(par != NULL) { + is_common = _lv_area_intersect(area, area, &par->coords); + if(is_common == false) return false; /*If no common parts with parent break;*/ + if(lv_obj_has_flag(par, LV_OBJ_FLAG_HIDDEN)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/ + + par = lv_obj_get_parent(par); + } + return true; } diff --git a/src/lv_core/lv_obj_tree.c b/src/lv_core/lv_obj_tree.c index 8124f7645..b6e5cb449 100644 --- a/src/lv_core/lv_obj_tree.c +++ b/src/lv_core/lv_obj_tree.c @@ -181,7 +181,7 @@ void lv_obj_move_foreground(lv_obj_t * obj) lv_obj_invalidate(parent); - uint32_t i; + int32_t i; for(i = lv_obj_get_child_id(obj) - 1; i > 0; i--) { parent->spec_attr->children[i] = parent->spec_attr->children[i-1]; } @@ -355,14 +355,32 @@ static void obj_del_core(lv_obj_t * obj) /* All children deleted. Now clean up the object specific data*/ _lv_obj_destruct(obj); - /*Remove the object from the child list of its parent*/ - uint32_t id = lv_obj_get_child_id(obj); - uint32_t i; - for(i = id; i < obj->parent->spec_attr->child_cnt - 1; i++) { - obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1]; + /*Remove the screen for the screen list*/ + if(obj->parent == NULL) { + lv_disp_t * disp = lv_obj_get_disp(obj); + uint32_t i; + /*Find the screen in the list*/ + for(i = 0; i < disp->screen_cnt; i++) { + if(disp->screens[i] == obj) break; + } + + uint32_t id = i; + for(i = id; i < disp->screen_cnt - 1; i++) { + disp->screens[i] = disp->screens[i + 1]; + } + disp->screen_cnt--; + disp->screens = lv_mem_realloc(disp->screens, disp->screen_cnt * sizeof(lv_obj_t *)); + } + /*Remove the object from the child list of its parent*/ + else { + uint32_t id = lv_obj_get_child_id(obj); + uint32_t i; + for(i = id; i < obj->parent->spec_attr->child_cnt - 1; i++) { + obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1]; + } + obj->parent->spec_attr->child_cnt--; + obj->parent->spec_attr->children = lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *)); } - obj->parent->spec_attr->child_cnt--; - obj->parent->spec_attr->children = lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *)); /*Free the object itself*/ lv_mem_free(obj); diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 165d641db..9dd7d41b8 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -129,6 +129,7 @@ void _lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p) if(lv_disp_is_true_double_buf(disp)) { disp->inv_areas[0] = scr_area; disp->inv_p = 1; + lv_timer_pause(disp->read_task, false); return; } diff --git a/src/lv_misc/lv_style.h b/src/lv_misc/lv_style.h index 18d02068c..561e6f8ee 100644 --- a/src/lv_misc/lv_style.h +++ b/src/lv_misc/lv_style.h @@ -161,11 +161,11 @@ typedef enum { LV_STYLE_BORDER_SIDE = 51, LV_STYLE_BORDER_POST = 52, - LV_STYLE_OUTLINE_WIDTH = 48 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_OUTLINE_COLOR = 49, - LV_STYLE_OUTLINE_COLOR_FILTERED = 49 | LV_STYLE_PROP_FILTER, - LV_STYLE_OUTLINE_OPA = 50 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_OUTLINE_PAD = 51 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_OUTLINE_WIDTH = 58 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_OUTLINE_COLOR = 59, + LV_STYLE_OUTLINE_COLOR_FILTERED = 59 | LV_STYLE_PROP_FILTER, + LV_STYLE_OUTLINE_OPA = 60 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_OUTLINE_PAD = 61 | LV_STYLE_PROP_EXT_DRAW, /*Group 4*/ LV_STYLE_SHADOW_WIDTH = 64 | LV_STYLE_PROP_EXT_DRAW,