diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index 46b71d15f..f5c585ade 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -8,6 +8,7 @@ *********************/ #include "lv_group.h" #if USE_LV_GROUP != 0 +#include "../lv_themes/lv_theme.h" #include /********************* @@ -48,14 +49,15 @@ lv_group_t * lv_group_create(void) if(group == NULL) return NULL; lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *)); - group->style_mod = style_mod_def; - group->style_mod_edit = style_mod_edit_def; group->obj_focus = NULL; group->frozen = 0; group->focus_cb = NULL; group->click_focus = 1; group->editing = 0; + /*Initialize style modification callbacks from current theme*/ + lv_group_report_style_mod(group); + return group; } @@ -522,4 +524,21 @@ static void style_mod_edit_def(lv_style_t * style) } +/** + * Notify the group that current theme changed and style modification callbacks need to be refreshed. + * @param group pointer to group + */ +void lv_group_report_style_mod(lv_group_t * group) +{ + group->style_mod = style_mod_def; + group->style_mod_edit = style_mod_edit_def; + lv_theme_t * th = lv_theme_get_current(); + if(th) { + if (th->group.style_mod) + group->style_mod = th->group.style_mod; + if (th->group.style_mod_edit) + group->style_mod_edit = th->group.style_mod_edit; + } +} + #endif /*USE_LV_GROUP != 0*/ diff --git a/lv_core/lv_group.h b/lv_core/lv_group.h index 133d5954e..38fcfe009 100644 --- a/lv_core/lv_group.h +++ b/lv_core/lv_group.h @@ -236,6 +236,12 @@ bool lv_group_get_click_focus(const lv_group_t * group); */ bool lv_group_get_wrap(lv_group_t * group); +/** + * Notify the group that current theme changed and style modification callbacks need to be refreshed. + * @param group pointer to group + */ +void lv_group_report_style_mod(lv_group_t * group); + /********************** * MACROS **********************/ diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index 4b76c8b78..1b192af62 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -80,6 +80,9 @@ void lv_theme_set_current(lv_theme_t * th) if(s) memcpy(&th_styles[i], (void *)s, sizeof(lv_style_t)); } + /*Copy group style modification callback functions*/ + current_theme.group = th->group; + /*Let the object know their style might change*/ lv_obj_report_style_mod(NULL); #endif diff --git a/lv_themes/lv_theme.h b/lv_themes/lv_theme.h index 24db3d5e6..8d681feae 100644 --- a/lv_themes/lv_theme.h +++ b/lv_themes/lv_theme.h @@ -20,6 +20,7 @@ extern "C" { #endif #include "../lv_core/lv_style.h" +#include "../lv_core/lv_group.h" /********************* * DEFINES @@ -291,6 +292,12 @@ typedef struct { } win; #endif } style; + + struct + { + lv_group_style_mod_func_t style_mod; + lv_group_style_mod_func_t style_mod_edit; + } group; } lv_theme_t; /**********************