From 9d6d0094f553d2c70bc6b6ebb34a3334be31137e Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 23 Apr 2021 14:06:50 +0200 Subject: [PATCH] fix(layout) fix missing layout recalculation on screen --- examples/widgets/checkbox/lv_example_checkbox_1.c | 2 ++ src/core/lv_obj.h | 1 + src/core/lv_obj_pos.c | 10 +++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/widgets/checkbox/lv_example_checkbox_1.c b/examples/widgets/checkbox/lv_example_checkbox_1.c index 5a9fd8896..72f284200 100644 --- a/examples/widgets/checkbox/lv_example_checkbox_1.c +++ b/examples/widgets/checkbox/lv_example_checkbox_1.c @@ -36,6 +36,8 @@ void lv_example_checkbox_1(void) lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); lv_checkbox_set_text(cb, "Melon"); lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); + + lv_obj_update_layout(cb); } #endif diff --git a/src/core/lv_obj.h b/src/core/lv_obj.h index d88ee31b4..862df3b8c 100644 --- a/src/core/lv_obj.h +++ b/src/core/lv_obj.h @@ -247,6 +247,7 @@ typedef struct _lv_obj_t { lv_obj_flag_t flags; lv_state_t state; uint16_t layout_inv :1; + uint16_t scr_layout_inv :1; uint16_t skip_trans :1; uint16_t style_cnt :6; uint16_t h_layout :1; diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index 8066faeb6..eaab9418c 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -277,7 +277,7 @@ void lv_obj_mark_layout_as_dirty(lv_obj_t * obj) /*Mark the screen as dirty too to mark that there is an something to do on this screen*/ lv_obj_t * scr = lv_obj_get_screen(obj); - scr->layout_inv = 1; + scr->scr_layout_inv = 1; /*Make the display refreshing*/ lv_disp_t * disp = lv_obj_get_disp(scr); @@ -296,11 +296,11 @@ void lv_obj_update_layout(const lv_obj_t * obj) lv_obj_t * scr = lv_obj_get_screen(obj); /*Repeat until there where layout invalidations*/ - while(scr->layout_inv) { - LV_LOG_INFO("Start layout update") - scr->layout_inv = 0; + while(scr->scr_layout_inv) { + LV_LOG_INFO("Layout update begin") + scr->scr_layout_inv = 0; layout_update_core(scr); - LV_LOG_TRACE("Layout update finished") + LV_LOG_TRACE("Layout update end") } mutex = false;