1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

add groups to the linked list

https://github.com/littlevgl/lvgl/issues/806
This commit is contained in:
manison 2019-02-15 08:46:12 +01:00
parent 79dc8b2ace
commit 8ec60fbe3e
5 changed files with 56 additions and 16 deletions

View File

@ -10,6 +10,7 @@
#if USE_LV_GROUP != 0
#include "../lv_themes/lv_theme.h"
#include <stddef.h>
#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;
}
}

View File

@ -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);

View File

@ -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();

View File

@ -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;\

View File

@ -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
}