From 4bdb0e94a3e33f0d1fd7f31f5806c8079b02da2c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 19 Mar 2021 16:10:35 +0100 Subject: [PATCH] fix(theme): apply the new theme on the screen if there are no object created When a display is registered the act_screen, top_layer and sys_layer are created with the default theme. If a new theme is set immediatelly after the driver regsitration (with lv_theme_set_act) the created screens should use the styles from the new theme. If there are more obejct do not add the theme becasue it's possibelt that the user already added styles to the screens and applying the theme would clear these styles. --- src/core/lv_disp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/lv_disp.c b/src/core/lv_disp.c index ab808cd60..3c3e6db61 100644 --- a/src/core/lv_disp.c +++ b/src/core/lv_disp.c @@ -128,6 +128,16 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp) void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th) { disp->theme = th; + + if(disp->screen_cnt == 3 && + lv_obj_get_child_cnt(disp->screens[0]) == 0 && + lv_obj_get_child_cnt(disp->screens[1]) == 0 && + lv_obj_get_child_cnt(disp->screens[2]) == 0) + { + lv_theme_apply(disp->screens[0]); + lv_theme_apply(disp->screens[1]); + lv_theme_apply(disp->screens[2]); + } } /** * Get the theme of a display