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

add lv_theme_copy

This commit is contained in:
Gabor Kiss-Vamosi 2020-06-27 06:53:19 +02:00
parent aad9f4f0c1
commit 6971d603d2
2 changed files with 43 additions and 6 deletions

View File

@ -69,6 +69,30 @@ void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
apply_theme(act_theme, obj, name);
}
/**
* Copy a theme to an other or initialize a theme
* @param theme pointer to a theme to initialize
* @param copy pointer to a theme to copy
* or `NULL` to initialize `theme` to empty
*/
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy)
{
_lv_memset_00(theme, sizeof(lv_theme_t));
if(copy) {
theme->font_small = copy->font_small;
theme->font_normal = copy->font_normal;
theme->font_subtitle = copy->font_subtitle;
theme->font_title = copy->font_title;
theme->color_primary = copy->color_primary;
theme->color_secondary = copy->color_secondary;
theme->flags = copy->flags;
theme->base = copy->base;
theme->apply_cb = copy->apply_cb;
theme->apply_xcb = copy->apply_xcb;
}
}
/**
* Set a base theme for a theme.
@ -79,7 +103,7 @@ void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
*/
void lv_theme_set_base(lv_theme_t * new, lv_theme_t * base)
{
new->base_theme = base;
new->base = base;
}
/**
@ -151,8 +175,8 @@ uint32_t lv_theme_get_flags(void)
static void apply_theme(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name)
{
if(th->base_theme) {
apply_theme(th->base_theme, obj, name);
if(th->base) {
apply_theme(th->base, obj, name);
}
/*apply_xcb is deprecated, use apply_cb instead*/

View File

@ -146,10 +146,15 @@ typedef enum {
} lv_theme_style_t;
struct _lv_theme_t;
typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t);
typedef void (*lv_theme_apply_xcb_t)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/
typedef struct _lv_theme_t {
void (*apply_xcb)(lv_obj_t *, lv_theme_style_t); /*Deprecated: use `apply_cb` instead*/
void (*apply_cb)(struct _lv_theme_t *, lv_obj_t *, lv_theme_style_t);
struct _lv_theme_t * base_theme; /**< Apply the current theme's style on top of this theme.*/
lv_theme_apply_cb_t apply_cb;
lv_theme_apply_xcb_t apply_xcb; /*Deprecated: use `apply_cb` instead*/
struct _lv_theme_t * base; /**< Apply the current theme's style on top of this theme.*/
lv_color_t color_primary;
lv_color_t color_secondary;
const lv_font_t * font_small;
@ -184,6 +189,14 @@ lv_theme_t * lv_theme_get_act(void);
*/
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name);
/**
* Copy a theme to an other or initialize a theme
* @param theme pointer to a theme to initialize
* @param copy pointer to a theme to copy
* or `NULL` to initialize `theme` to empty
*/
void lv_theme_copy(lv_theme_t * theme, const lv_theme_t * copy);
/**
* Set a base theme for a theme.
* The styles from the base them will be added before the styles of the current theme.