From 03c3838605851dec06d01c8ee4cd937871be567e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 1 Sep 2020 16:45:36 +0200 Subject: [PATCH 01/13] arc: use value_update in lv_arc_set_value it was overwritten on merge --- src/lv_widgets/lv_arc.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/lv_widgets/lv_arc.c b/src/lv_widgets/lv_arc.c index 655a12802..c42402e7d 100644 --- a/src/lv_widgets/lv_arc.c +++ b/src/lv_widgets/lv_arc.c @@ -400,36 +400,7 @@ void lv_arc_set_value(lv_obj_t * arc, int16_t value) if(ext->cur_value == new_value) return; ext->cur_value = new_value; - int16_t bg_midpoint, range_midpoint, bg_end = ext->bg_angle_end; - if(ext->bg_angle_end < ext->bg_angle_start) bg_end = ext->bg_angle_end + 360; - - int16_t angle; - switch(ext->type) { - case LV_ARC_TYPE_SYMMETRIC: - bg_midpoint = (ext->bg_angle_start + bg_end) / 2; - range_midpoint = (int32_t)(ext->min_value + ext->max_value) / 2; - - if(ext->cur_value < range_midpoint) { - angle = _lv_map(ext->cur_value, ext->min_value, range_midpoint, ext->bg_angle_start, bg_midpoint); - lv_arc_set_start_angle(arc, angle); - lv_arc_set_end_angle(arc, bg_midpoint); - } - else { - angle = _lv_map(ext->cur_value, range_midpoint, ext->max_value, bg_midpoint, bg_end); - lv_arc_set_start_angle(arc, bg_midpoint); - lv_arc_set_end_angle(arc, angle); - } - break; - case LV_ARC_TYPE_REVERSE: - angle = _lv_map(ext->cur_value, ext->min_value, ext->max_value, ext->bg_angle_start, bg_end); - lv_arc_set_start_angle(arc, angle); - break; - default: /** LV_ARC_TYPE_NORMAL*/ - angle = _lv_map(ext->cur_value, ext->min_value, ext->max_value, ext->bg_angle_start, bg_end); - lv_arc_set_start_angle(arc, ext->bg_angle_start); - lv_arc_set_end_angle(arc, angle); - } - ext->last_angle = angle; /*Cache angle for slew rate limiting*/ + value_update(arc); } /** From 4613811c45d4e58929f739f6342a1b4c8ced56a9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 1 Sep 2020 17:59:53 +0200 Subject: [PATCH 02/13] lmeter: fix uninitialized 'mirror' property --- lv_conf_template.h | 2 +- src/lv_widgets/lv_linemeter.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lv_conf_template.h b/lv_conf_template.h index 7f009b082..01d8184a2 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -653,7 +653,7 @@ typedef void * lv_obj_user_data_t; * 1: Some extra precision * 2: Best precision */ -# define LV_LINEMETER_PRECISE 0 +# define LV_LINEMETER_PRECISE 1 #endif /*Mask (dependencies: -)*/ diff --git a/src/lv_widgets/lv_linemeter.c b/src/lv_widgets/lv_linemeter.c index cd7f291c0..a8c9d3db8 100644 --- a/src/lv_widgets/lv_linemeter.c +++ b/src/lv_widgets/lv_linemeter.c @@ -76,6 +76,7 @@ lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy) ext->line_cnt = 18; ext->scale_angle = 240; ext->angle_ofs = 0; + ext->mirrored = 0; /*The signal and design functions are not copied so set them here*/ lv_obj_set_signal_cb(linemeter, lv_linemeter_signal); From 85bd12a794b3525cfba8cc702f06c97d83dd01d6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 1 Sep 2020 19:14:03 +0200 Subject: [PATCH 03/13] fix lv_obj_del and lv_obj_clean if the children list changed during deletion https://forum.lvgl.io/t/lv-obj-del-and-kin-wrongly-assume-that-child-ll-wont-change-while-deleting/3091 --- CHANGELOG.md | 1 + src/lv_core/lv_obj.c | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adb860656..f45d45f7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add `gpu_wait_cb` to wait until the GPU is working. It allows to run CPU a wait only when the rendered data is needed. ### Bugfixes +- Fix `lv_obj_del` and `lv_obj_clean` if the children list changed during deletion. ## v7.4.0 (01.09.2020) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 30c5f6c6c..25fec838a 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -487,11 +487,8 @@ void lv_obj_clean(lv_obj_t * obj) lv_obj_t * child = lv_obj_get_child(obj, NULL); lv_obj_t * child_next; while(child) { - /* Read the next child before deleting the current - * because the next couldn't be read from a deleted (invalid) node*/ - child_next = lv_obj_get_child(obj, child); lv_obj_del(child); - child = child_next; + child = lv_obj_get_child(obj, NULL); /*Get the new first child*/ } } @@ -3709,17 +3706,13 @@ static void obj_del_core(lv_obj_t * obj) /*Recursively delete the children*/ lv_obj_t * i; - lv_obj_t * i_next; i = _lv_ll_get_head(&(obj->child_ll)); while(i != NULL) { - /*Get the next object before delete this*/ - i_next = _lv_ll_get_next(&(obj->child_ll), i); - - /*Call the recursive del to the child too*/ + /*Call the recursive delete to the child too*/ obj_del_core(i); - /*Set i to the next node*/ - i = i_next; + /*Set i to the new head node*/ + i = _lv_ll_get_head(&(obj->child_ll)); } lv_event_mark_deleted(obj); From 05960885440e7ac412ba7d4b5e7c46af9716134c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 1 Sep 2020 19:19:25 +0200 Subject: [PATCH 04/13] remove unused variable --- src/lv_core/lv_obj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 25fec838a..56284a063 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -485,7 +485,6 @@ void lv_obj_clean(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, LV_OBJX_NAME); lv_obj_t * child = lv_obj_get_child(obj, NULL); - lv_obj_t * child_next; while(child) { lv_obj_del(child); child = lv_obj_get_child(obj, NULL); /*Get the new first child*/ From 804c3c799489e3e1eb720b6ff318c1477442c11d Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 4 Sep 2020 13:06:10 +0200 Subject: [PATCH 05/13] fix unexpeted DEFOCUS on lv_page Fixes #1762 --- src/lv_core/lv_obj.c | 1 + src/lv_widgets/lv_page.c | 28 ++-------------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 30c5f6c6c..d8c0f85ca 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -392,6 +392,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) new_obj->protect = copy->protect; new_obj->gesture_parent = copy->gesture_parent; + new_obj->focus_parent = copy->focus_parent; #if LV_USE_GROUP /*Add to the same group*/ diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index 7be8f456f..03c15bcc3 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -118,6 +118,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new page object*/ if(copy == NULL) { ext->scrl = lv_cont_create(page, NULL); + lv_obj_set_focus_parent(ext->scrl, true); lv_obj_set_drag(ext->scrl, true); lv_obj_set_drag_throw(ext->scrl, true); lv_obj_add_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST); @@ -131,6 +132,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_set_signal_cb(page, lv_page_signal); lv_obj_set_design_cb(page, lv_page_design); + lv_page_set_scrollbar_mode(page, ext->scrlbar.mode); lv_theme_apply(page, LV_THEME_PAGE); @@ -1043,32 +1045,6 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } } - else if(sign == LV_SIGNAL_FOCUS) { -#if LV_USE_GROUP - if(lv_obj_get_group(page)) { - lv_group_focus_obj(page); - } - else -#endif - { - res = lv_signal_send(page, LV_SIGNAL_FOCUS, NULL); - if(res != LV_RES_OK) return res; - res = lv_event_send(page, LV_EVENT_FOCUSED, NULL); - if(res != LV_RES_OK) return res; - } - } - else if(sign == LV_SIGNAL_DEFOCUS) { - bool in_group = false; -#if LV_USE_GROUP - in_group = lv_obj_get_group(page) ? true : false; -#endif - if(in_group == false) { - res = lv_signal_send(page, LV_SIGNAL_DEFOCUS, NULL); - if(res != LV_RES_OK) return res; - res = lv_event_send(page, LV_EVENT_DEFOCUSED, NULL); - if(res != LV_RES_OK) return res; - } - } else if(sign == LV_SIGNAL_CLEANUP) { page_ext->scrl = NULL; From 1ab87eda0960328a32ddf3f522437cf0b23a5b44 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 4 Sep 2020 13:07:29 +0200 Subject: [PATCH 06/13] update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index adb860656..e4432ae53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Add `gpu_wait_cb` to wait until the GPU is working. It allows to run CPU a wait only when the rendered data is needed. ### Bugfixes - +- Fix unexpeted DEFOCUS on lv_page when clicking to bg after the scrollable ## v7.4.0 (01.09.2020) From 35c7197d1c059964407891aba20e7fa8662167ed Mon Sep 17 00:00:00 2001 From: tgillbe Date: Fri, 4 Sep 2020 12:30:39 +0100 Subject: [PATCH 07/13] Fix button matrix button width (#1768) --- CHANGELOG.md | 1 + src/lv_widgets/lv_btnmatrix.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f46572f8a..d37c77706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bugfixes - Fix unexpeted DEFOCUS on lv_page when clicking to bg after the scrollable - Fix `lv_obj_del` and `lv_obj_clean` if the children list changed during deletion. +- Adjust button matrix button width to include padding when spanning multiple units. ## v7.4.0 (01.09.2020) diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 9f39dd638..d4a4a5c59 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -208,7 +208,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]) /*Only deal with the non empty lines*/ if(btn_cnt != 0) { /*Calculate the width of all units*/ - lv_coord_t all_unit_w = max_w - ((btn_cnt - 1) * inner); + lv_coord_t all_unit_w = max_w - ((unit_cnt - 1) * inner); /*Set the button size and positions and set the texts*/ uint16_t i; @@ -216,19 +216,20 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]) unit_act_cnt = 0; for(i = 0; i < btn_cnt; i++) { + uint8_t btn_unit_w = get_button_width(ext->ctrl_bits[btn_i]); /* one_unit_w = all_unit_w / unit_cnt * act_unit_w = one_unit_w * button_width * do this two operations but the multiply first to divide a greater number */ - lv_coord_t act_unit_w = (all_unit_w * get_button_width(ext->ctrl_bits[btn_i])) / unit_cnt; + lv_coord_t act_unit_w = (all_unit_w * btn_unit_w) / unit_cnt + inner * (btn_unit_w - 1); act_unit_w--; /*-1 because e.g. width = 100 means 101 pixels (0..100)*/ /*Always recalculate act_x because of rounding errors */ if(base_dir == LV_BIDI_DIR_RTL) { - act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner; + act_x = (unit_act_cnt * all_unit_w) / unit_cnt + unit_act_cnt * inner; act_x = lv_obj_get_width(btnm) - right - act_x - act_unit_w - 1; } else { - act_x = (unit_act_cnt * all_unit_w) / unit_cnt + i * inner + + act_x = (unit_act_cnt * all_unit_w) / unit_cnt + unit_act_cnt * inner + left; } /* Set the button's area. @@ -243,7 +244,7 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]) lv_area_set(&ext->button_areas[btn_i], act_x, act_y, act_x + act_unit_w, act_y + btn_h); } - unit_act_cnt += get_button_width(ext->ctrl_bits[btn_i]); + unit_act_cnt += btn_unit_w; i_tot++; btn_i++; From a6150ea78ff646734d32f7ecf748c64961331e1e Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sat, 5 Sep 2020 14:46:07 +0300 Subject: [PATCH 08/13] CI - Build Micropython with LVGL submodule (#1771) --- .github/workflows/build_micropython.yml | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/build_micropython.yml diff --git a/.github/workflows/build_micropython.yml b/.github/workflows/build_micropython.yml new file mode 100644 index 000000000..b7097d5b3 --- /dev/null +++ b/.github/workflows/build_micropython.yml @@ -0,0 +1,40 @@ +name: Build Micropython with LVGL submodule + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Install SDL + run: | + sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" + sudo apt-get update -y -qq + sudo apt-get install libsdl2-dev + - name: Clone lv_micropython + run: git clone https://github.com/lvgl/lv_micropython.git . + - name: Update submodules + run: git submodule update --init --recursive + - name: Checkout lv_bindings + working-directory: ./lib/lv_bindings/lvgl + run: | + git fetch + git checkout $GITHUB_SHA + - name: Build mpy-cross + run: make -j $(nproc) -C mpy-cross + - name: Build the unix port + run: make -j $(nproc) -C ports/unix + - name: Run advanced_demo + run: > + echo "import gc,utime; + utime.sleep(5); + gc.collect(); + utime.sleep(5)" | + ports/unix/micropython -i lib/lv_bindings/examples/advanced_demo.py + From 176eb9fd4621b89bf539ab61b7999db25e527996 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sun, 6 Sep 2020 12:50:08 +0200 Subject: [PATCH 09/13] Update ROADMAP.md --- docs/ROADMAP.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 889b19fa6..aa81f4259 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -12,23 +12,23 @@ Planned to September/October 2020 - Support "elastic" scrolling when scrolled in - Support scroll chaining among any objects types (not only `lv_pages`s) - Remove `lv_drag`. Similar effect can be achieved by setting the position in `LV_EVENT_PRESSING` - - Add snapping? + - Add snapping + - Add snap stop to scroll max 1 snap point - Already working - New layouts: - See [#1615](https://github.com/lvgl/lvgl/issues/1615) issue - - [CSS Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)-like layout support - - Besides setting width/height in `px` add support to `partent percentage` and `screen percentage`. + - [CSS Grid](https://css-tricks.com/snippets/css/a-guide-to-grid/)-like layout support - Work in progress - Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier - Work in progress - Remove the align parameter from `lv_canvas_draw_text` ## v9 -- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3). - -## Ideas +- Simplify `group`s. Discussion is [here](https://forum.lvgl.io/t/lv-group-tabindex/2927/3).7 - Unit testing (gtest?). See [#1658](https://github.com/lvgl/lvgl/issues/1658) - Benchmarking (gem5?). See [#1660](https://github.com/lvgl/lvgl/issues/1660) + +## Ideas - CPP binding. See [Forum](https://forum.lvgl.io/t/is-it-possible-to-officially-support-optional-cpp-api/2736) - Optmize font decompression - Switch to RGBA colors in styles From 710ec7d417880acd8c19ab1f4675ad54fd9e66f9 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 7 Sep 2020 09:20:41 +0200 Subject: [PATCH 10/13] Update ROADMAP.md --- docs/ROADMAP.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index aa81f4259..4894a7f71 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -21,6 +21,7 @@ Planned to September/October 2020 - Work in progress - Simplified File system interface ([feat/new_fs_api](https://github.com/lvgl/lvgl/tree/feat/new-fs-api) branch) to make porting easier - Work in progress +- RGB888 support [#1722](https://github.com/lvgl/lvgl/issues/1722) - Remove the align parameter from `lv_canvas_draw_text` ## v9 From b1c43d329d4b9b9b62cd03d4085cd832973893d6 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 7 Sep 2020 10:13:07 +0200 Subject: [PATCH 11/13] update comments in lv_port_disp_template --- examples/porting/lv_port_disp_template.c | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/examples/porting/lv_port_disp_template.c b/examples/porting/lv_port_disp_template.c index b26c34e53..7bb9c3d70 100644 --- a/examples/porting/lv_port_disp_template.c +++ b/examples/porting/lv_port_disp_template.c @@ -54,7 +54,9 @@ void lv_port_disp_init(void) * Create a buffer for drawing *----------------------------*/ - /* LVGL requires a buffer where it draws the objects. The buffer's has to be greater than 1 display row + /* LVGL requires a buffer where it internally draws the widgets. + * Later this buffer will passed your display drivers `flush_cb` to copy its content to your dispay. + * The buffer has to be greater than 1 display row * * There are three buffering configurations: * 1. Create ONE buffer with some rows: @@ -73,21 +75,21 @@ void lv_port_disp_init(void) * */ /* Example for 1) */ - static lv_disp_buf_t disp_buf_1; - static lv_color_t buf1_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ - lv_disp_buf_init(&disp_buf_1, buf1_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ + static lv_disp_buf_t draw_buf_dsc_1; + static lv_color_t draw_buf_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ + lv_disp_buf_init(&draw_buf_dsc_1, draw_buf_1, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ /* Example for 2) */ - static lv_disp_buf_t disp_buf_2; - static lv_color_t buf2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ - static lv_color_t buf2_2[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/ - lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ + static lv_disp_buf_t draw_buf_dsc_2; + static lv_color_t draw_buf_2_1[LV_HOR_RES_MAX * 10]; /*A buffer for 10 rows*/ + static lv_color_t draw_buf_2_1[LV_HOR_RES_MAX * 10]; /*An other buffer for 10 rows*/ + lv_disp_buf_init(&draw_buf_dsc_2, draw_buf_2_1, draw_buf_2_1, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/ /* Example for 3) */ - static lv_disp_buf_t disp_buf_3; - static lv_color_t buf3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/ - static lv_color_t buf3_2[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/ - lv_disp_buf_init(&disp_buf_3, buf3_1, buf3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/ + static lv_disp_buf_t draw_buf_dsc_3; + static lv_color_t draw_buf_3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*A screen sized buffer*/ + static lv_color_t draw_buf_3_1[LV_HOR_RES_MAX * LV_VER_RES_MAX]; /*An other screen sized buffer*/ + lv_disp_buf_init(&draw_buf_dsc_3, draw_buf_3_1, draw_buf_3_2, LV_HOR_RES_MAX * LV_VER_RES_MAX); /*Initialize the display buffer*/ /*----------------------------------- @@ -107,7 +109,7 @@ void lv_port_disp_init(void) disp_drv.flush_cb = disp_flush; /*Set a display buffer*/ - disp_drv.buffer = &disp_buf_2; + disp_drv.buffer = &draw_buf_dsc_1; #if LV_USE_GPU /*Optionally add functions to access the GPU. (Only in buffered mode, LV_VDB_SIZE != 0)*/ From b87d16fc6ec92ed9f216b976c1e38fca3691959c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 7 Sep 2020 10:18:37 +0200 Subject: [PATCH 12/13] fix textra focus event sending --- src/lv_core/lv_indev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index f15852129..6b8f2e46c 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -1181,9 +1181,9 @@ static void indev_click_focus(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } - lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL); + lv_signal_send(obj_to_focus, LV_SIGNAL_FOCUS, NULL); if(indev_reset_check(proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL); + lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, NULL); if(indev_reset_check(proc)) return; } } @@ -1222,9 +1222,9 @@ static void indev_click_focus(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } else { - lv_signal_send(indev_obj_act, LV_SIGNAL_FOCUS, NULL); + lv_signal_send(obj_to_focus, LV_SIGNAL_FOCUS, NULL); if(indev_reset_check(proc)) return; - lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, NULL); + lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, NULL); if(indev_reset_check(proc)) return; } } From 81884401d236ff5cf47148ce307033e5d0c049ae Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Tue, 8 Sep 2020 13:20:29 +0200 Subject: [PATCH 13/13] style change check --- src/lv_core/lv_obj.c | 164 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 3 deletions(-) diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 56e5a0980..21ac1adb3 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -76,6 +76,42 @@ typedef struct { } end_value; } lv_style_trans_t; +typedef struct { + lv_draw_rect_dsc_t rect; + lv_draw_label_dsc_t label; + lv_draw_line_dsc_t line; + lv_draw_img_dsc_t img; + lv_style_int_t pad_top; + lv_style_int_t pad_bottom; + lv_style_int_t pad_right; + lv_style_int_t pad_left; + lv_style_int_t pad_inner; + lv_style_int_t margin_top; + lv_style_int_t margin_bottom; + lv_style_int_t margin_left; + lv_style_int_t margin_right; + lv_style_int_t size; + lv_style_int_t transform_width; + lv_style_int_t transform_height; + lv_style_int_t transform_angle; + lv_style_int_t transform_zoom; + lv_style_int_t scale_width; + lv_style_int_t scale_border_width; + lv_style_int_t scale_end_border_width; + lv_style_int_t scale_end_line_width; + lv_color_t scale_grad_color; + lv_color_t scale_end_color; + lv_opa_t opa_scale; + uint32_t clip_corder :1; + uint32_t border_post :1; +}style_snapshot_t; + +typedef enum { + STYLE_COMPARE_SAME, + STYLE_COMPARE_VISUAL_DIFF, + STYLE_COMPARE_DIFF, +} style_snapshot_res_t; + /********************** * STATIC PROTOTYPES **********************/ @@ -106,6 +142,10 @@ static void obj_del_core(lv_obj_t * obj); static void update_style_cache(lv_obj_t * obj, uint8_t part, uint16_t prop); static void update_style_cache_children(lv_obj_t * obj); static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_property_t prop); +static void style_snapshot(lv_obj_t * obj, uint8_t part, style_snapshot_t * shot); +static style_snapshot_res_t style_snapshot_compare(style_snapshot_t * shot1, style_snapshot_t * shot2); + + /********************** * STATIC VARIABLES **********************/ @@ -1670,9 +1710,49 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); #else lv_state_t prev_state = obj->state; - obj->state = new_state; - + style_snapshot_res_t cmp_res = STYLE_COMPARE_SAME; uint8_t part; + for(part = 0; part < _LV_OBJ_PART_REAL_FIRST; part++) { + lv_style_list_t * style_list = lv_obj_get_style_list(obj, part); + if(style_list == NULL) break; /*No more style lists*/ + obj->state = prev_state; + style_snapshot_t shot_pre; + style_snapshot(obj, part, &shot_pre); + obj->state = new_state; + style_snapshot_t shot_post; + style_snapshot(obj, part, &shot_post); + + style_snapshot_res_t r = style_snapshot_compare(&shot_pre, &shot_post); + if(r == STYLE_COMPARE_DIFF) { + cmp_res = STYLE_COMPARE_DIFF; + break; + } + if(r == STYLE_COMPARE_VISUAL_DIFF) { + cmp_res = STYLE_COMPARE_VISUAL_DIFF; + } + } + for(part = _LV_OBJ_PART_REAL_FIRST; part < 0xFF; part++) { + lv_style_list_t * style_list = lv_obj_get_style_list(obj, part); + if(style_list == NULL) break; /*No more style lists*/ + obj->state = prev_state; + style_snapshot_t shot_pre; + style_snapshot(obj, part, &shot_pre); + obj->state = new_state; + style_snapshot_t shot_post; + style_snapshot(obj, part, &shot_post); + + style_snapshot_res_t r = style_snapshot_compare(&shot_pre, &shot_post); + if(r == STYLE_COMPARE_DIFF) { + cmp_res = STYLE_COMPARE_DIFF; + break; + } + if(r == STYLE_COMPARE_VISUAL_DIFF) { + cmp_res = STYLE_COMPARE_VISUAL_DIFF; + } + } + + if(cmp_res == STYLE_COMPARE_SAME) return; + for(part = 0; part < _LV_OBJ_PART_REAL_LAST; part++) { lv_style_list_t * style_list = lv_obj_get_style_list(obj, part); if(style_list == NULL) break; /*No more style lists*/ @@ -1718,8 +1798,9 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) } } - lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); + if(cmp_res == STYLE_COMPARE_DIFF) lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL); } + if(cmp_res == STYLE_COMPARE_VISUAL_DIFF) lv_obj_invalidate(obj); #endif @@ -4659,3 +4740,80 @@ static void invalidate_style_cache(lv_obj_t * obj, uint8_t part, lv_style_proper } } +static void style_snapshot(lv_obj_t * obj, uint8_t part, style_snapshot_t * shot) +{ + _lv_obj_disable_style_caching(obj, true); + _lv_memset_00(shot, sizeof(style_snapshot_t)); + lv_draw_rect_dsc_init(&shot->rect); + lv_draw_label_dsc_init(&shot->label); + lv_draw_img_dsc_init(&shot->img); + lv_draw_line_dsc_init(&shot->line); + + lv_obj_init_draw_rect_dsc(obj, part, &shot->rect); + lv_obj_init_draw_label_dsc(obj, part, &shot->label); + lv_obj_init_draw_img_dsc(obj, part, &shot->img); + lv_obj_init_draw_line_dsc(obj, part, &shot->line); + + + shot->pad_top = lv_obj_get_style_pad_top(obj, part); + shot->pad_bottom = lv_obj_get_style_pad_bottom(obj, part); + shot->pad_right = lv_obj_get_style_pad_right(obj, part); + shot->pad_left = lv_obj_get_style_pad_left(obj, part); + shot->pad_inner = lv_obj_get_style_pad_inner(obj, part); + shot->margin_top = lv_obj_get_style_margin_top(obj, part); + shot->margin_bottom = lv_obj_get_style_margin_bottom(obj, part); + shot->margin_left = lv_obj_get_style_margin_left(obj, part); + shot->margin_right = lv_obj_get_style_margin_right(obj, part); + shot->size = lv_obj_get_style_size(obj, part); + shot->transform_width = lv_obj_get_style_transform_width(obj, part); + shot->transform_height = lv_obj_get_style_transform_height(obj, part); + shot->transform_angle = lv_obj_get_style_transform_angle(obj, part); + shot->transform_zoom = lv_obj_get_style_transform_zoom(obj, part); + shot->scale_width = lv_obj_get_style_scale_width(obj, part); + shot->scale_border_width = lv_obj_get_style_scale_border_width(obj, part); + shot->scale_end_border_width = lv_obj_get_style_scale_end_border_width(obj, part); + shot->scale_end_line_width = lv_obj_get_style_scale_end_line_width(obj, part); + shot->scale_grad_color = lv_obj_get_style_scale_grad_color(obj, part); + shot->scale_end_color = lv_obj_get_style_scale_end_color(obj, part); + shot->opa_scale = lv_obj_get_style_opa_scale(obj, part); + shot->clip_corder = lv_obj_get_style_clip_corner(obj, part); + shot->border_post = lv_obj_get_style_border_post(obj, part); + + _lv_obj_disable_style_caching(obj, false); +} + +static style_snapshot_res_t style_snapshot_compare(style_snapshot_t * shot1, style_snapshot_t * shot2) +{ + if(memcmp(shot1, shot2, sizeof(style_snapshot_t)) == 0) return STYLE_COMPARE_SAME; + + + if(shot1->pad_top != shot2->pad_top) return STYLE_COMPARE_DIFF; + if(shot1->pad_bottom != shot2->pad_bottom) return STYLE_COMPARE_DIFF; + if(shot1->pad_left != shot2->pad_right) return STYLE_COMPARE_DIFF; + if(shot1->pad_right != shot2->pad_right) return STYLE_COMPARE_DIFF; + if(shot1->pad_top != shot2->pad_top) return STYLE_COMPARE_DIFF; + if(shot1->pad_inner != shot2->pad_inner) return STYLE_COMPARE_DIFF; + if(shot1->margin_top != shot2->margin_top) return STYLE_COMPARE_DIFF; + if(shot1->margin_bottom != shot2->margin_bottom) return STYLE_COMPARE_DIFF; + if(shot1->margin_left != shot2->margin_right) return STYLE_COMPARE_DIFF; + if(shot1->margin_right != shot2->margin_right) return STYLE_COMPARE_DIFF; + if(shot1->margin_top != shot2->margin_top) return STYLE_COMPARE_DIFF; + if(shot1->transform_width != shot2->transform_width) return STYLE_COMPARE_DIFF; + if(shot1->transform_height != shot2->transform_height) return STYLE_COMPARE_DIFF; + if(shot1->transform_angle != shot2->transform_angle) return STYLE_COMPARE_DIFF; + if(shot1->transform_zoom != shot2->transform_zoom) return STYLE_COMPARE_DIFF; + if(shot1->rect.outline_width != shot2->rect.outline_width) return STYLE_COMPARE_DIFF; + if(shot1->rect.outline_pad != shot2->rect.outline_pad) return STYLE_COMPARE_DIFF; + if(shot1->rect.value_font != shot2->rect.value_font) return STYLE_COMPARE_DIFF; + if(shot1->rect.value_align != shot2->rect.value_align) return STYLE_COMPARE_DIFF; + if(shot1->rect.value_font != shot2->rect.value_font) return STYLE_COMPARE_DIFF; + if(shot1->rect.shadow_spread != shot2->rect.shadow_spread) return STYLE_COMPARE_DIFF; + if(shot1->rect.shadow_width != shot2->rect.shadow_width) return STYLE_COMPARE_DIFF; + if(shot1->rect.shadow_ofs_x != shot2->rect.shadow_ofs_x) return STYLE_COMPARE_DIFF; + if(shot1->rect.shadow_ofs_y != shot2->rect.shadow_ofs_y) return STYLE_COMPARE_DIFF; + + /*If not returned earlier its just a visual difference, a simple redraw is enough*/ + return STYLE_COMPARE_VISUAL_DIFF; + + +}