diff --git a/lv_core/lv_group.c b/lv_core/lv_group.c index f5c585ade..83c22ca76 100644 --- a/lv_core/lv_group.c +++ b/lv_core/lv_group.c @@ -10,6 +10,7 @@ #if USE_LV_GROUP != 0 #include "../lv_themes/lv_theme.h" #include +#include "../lv_misc/lv_gc.h" /********************* * DEFINES @@ -24,7 +25,8 @@ **********************/ static void style_mod_def(lv_style_t * style); static void style_mod_edit_def(lv_style_t * style); -static void lv_group_refocus(lv_group_t *g); +static void refresh_theme(lv_group_t * g, lv_theme_t * th); +static void lv_group_refocus(lv_group_t * g); /********************** * STATIC VARIABLES @@ -38,13 +40,21 @@ static void lv_group_refocus(lv_group_t *g); * GLOBAL FUNCTIONS **********************/ +/** + * Init. the group module + */ +void lv_group_init(void) +{ + lv_ll_init(&LV_GC_ROOT(_lv_group_ll), sizeof(lv_group_t)); +} + /** * Create a new object group * @return pointer to the new object group */ lv_group_t * lv_group_create(void) { - lv_group_t * group = lv_mem_alloc(sizeof(lv_group_t)); + lv_group_t * group = lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll)); lv_mem_assert(group); if(group == NULL) return NULL; lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *)); @@ -56,7 +66,7 @@ lv_group_t * lv_group_create(void) group->editing = 0; /*Initialize style modification callbacks from current theme*/ - lv_group_report_style_mod(group); + refresh_theme(group, lv_theme_get_current()); return group; } @@ -462,6 +472,25 @@ bool lv_group_get_wrap(lv_group_t * group) return group->wrap ? true : false; } +/** + * Notify the group that current theme changed and style modification callbacks need to be refreshed. + * @param group pointer to group. If NULL then all groups are notified. + */ +void lv_group_report_style_mod(lv_group_t * group) +{ + lv_theme_t * th = lv_theme_get_current(); + + if(group != NULL) { + refresh_theme(group, th); + return; + } + + lv_group_t * i; + LL_READ(LV_GC_ROOT(_lv_group_ll), i) { + refresh_theme(i, th); + } +} + /********************** * STATIC FUNCTIONS **********************/ @@ -524,20 +553,15 @@ 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) +static void refresh_theme(lv_group_t * g, lv_theme_t * th) { - group->style_mod = style_mod_def; - group->style_mod_edit = style_mod_edit_def; - lv_theme_t * th = lv_theme_get_current(); + g->style_mod = style_mod_def; + g->style_mod_edit = style_mod_edit_def; 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; + if(th->group.style_mod) + g->style_mod = th->group.style_mod; + if(th->group.style_mod_edit) + g->style_mod_edit = th->group.style_mod_edit; } } diff --git a/lv_core/lv_group.h b/lv_core/lv_group.h index 38fcfe009..7b3a6d482 100644 --- a/lv_core/lv_group.h +++ b/lv_core/lv_group.h @@ -72,6 +72,12 @@ typedef enum _lv_group_refocus_policy_t { * GLOBAL PROTOTYPES **********************/ +/** +* Init. the group module +* @remarks Internal function, do not call directly. +*/ +void lv_group_init(void); + /** * Create a new object group * @return pointer to the new object group @@ -238,7 +244,7 @@ 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 + * @param group pointer to group. If NULL then all groups are notified. */ void lv_group_report_style_mod(lv_group_t * group); diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index f379e1635..41049bdfd 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -91,6 +91,10 @@ void lv_init(void) lv_anim_init(); #endif +#if USE_LV_GROUP + lv_group_init(); +#endif + /*Init. the sstyles*/ lv_style_init(); diff --git a/lv_misc/lv_gc.h b/lv_misc/lv_gc.h index 72b10fc45..38090f044 100644 --- a/lv_misc/lv_gc.h +++ b/lv_misc/lv_gc.h @@ -35,6 +35,7 @@ extern "C" { prefix lv_ll_t _lv_drv_ll;\ prefix lv_ll_t _lv_file_ll;\ prefix lv_ll_t _lv_anim_ll;\ + prefix lv_ll_t _lv_group_ll;\ prefix void * _lv_def_scr;\ prefix void * _lv_act_scr;\ prefix void * _lv_top_layer;\ diff --git a/lv_themes/lv_theme.c b/lv_themes/lv_theme.c index 1b192af62..b27e035a7 100644 --- a/lv_themes/lv_theme.c +++ b/lv_themes/lv_theme.c @@ -85,6 +85,11 @@ void lv_theme_set_current(lv_theme_t * th) /*Let the object know their style might change*/ lv_obj_report_style_mod(NULL); + +#if USE_LV_GROUP + lv_group_report_style_mod(NULL); +#endif + #endif }