1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

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.
This commit is contained in:
Gabor Kiss-Vamosi 2021-03-19 16:10:35 +01:00
parent fa5e42ac0e
commit 4bdb0e94a3

View File

@ -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) void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th)
{ {
disp->theme = 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 * Get the theme of a display