mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
added style modification callbacks to lv_theme_t struct
https://github.com/littlevgl/lvgl/issues/806
This commit is contained in:
parent
c94fb96bb2
commit
327d7c84ca
@ -8,6 +8,7 @@
|
|||||||
*********************/
|
*********************/
|
||||||
#include "lv_group.h"
|
#include "lv_group.h"
|
||||||
#if USE_LV_GROUP != 0
|
#if USE_LV_GROUP != 0
|
||||||
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
@ -48,14 +49,15 @@ lv_group_t * lv_group_create(void)
|
|||||||
if(group == NULL) return NULL;
|
if(group == NULL) return NULL;
|
||||||
lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *));
|
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->obj_focus = NULL;
|
||||||
group->frozen = 0;
|
group->frozen = 0;
|
||||||
group->focus_cb = NULL;
|
group->focus_cb = NULL;
|
||||||
group->click_focus = 1;
|
group->click_focus = 1;
|
||||||
group->editing = 0;
|
group->editing = 0;
|
||||||
|
|
||||||
|
/*Initialize style modification callbacks from current theme*/
|
||||||
|
lv_group_report_style_mod(group);
|
||||||
|
|
||||||
return 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*/
|
#endif /*USE_LV_GROUP != 0*/
|
||||||
|
@ -236,6 +236,12 @@ bool lv_group_get_click_focus(const lv_group_t * group);
|
|||||||
*/
|
*/
|
||||||
bool lv_group_get_wrap(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
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
@ -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));
|
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*/
|
/*Let the object know their style might change*/
|
||||||
lv_obj_report_style_mod(NULL);
|
lv_obj_report_style_mod(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,6 +20,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../lv_core/lv_style.h"
|
#include "../lv_core/lv_style.h"
|
||||||
|
#include "../lv_core/lv_group.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@ -291,6 +292,12 @@ typedef struct {
|
|||||||
} win;
|
} win;
|
||||||
#endif
|
#endif
|
||||||
} style;
|
} style;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
lv_group_style_mod_func_t style_mod;
|
||||||
|
lv_group_style_mod_func_t style_mod_edit;
|
||||||
|
} group;
|
||||||
} lv_theme_t;
|
} lv_theme_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user