2017-11-16 15:32:33 +01:00
|
|
|
/**
|
|
|
|
* @file lv_theme.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_theme.h"
|
2018-09-06 01:28:58 +02:00
|
|
|
#include "../lv_core/lv_obj.h"
|
2017-11-16 15:32:33 +01:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC VARIABLES
|
|
|
|
**********************/
|
2019-12-31 07:03:34 +01:00
|
|
|
static lv_theme_t * act_theme;
|
2017-11-16 15:32:33 +01:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a theme for the system.
|
|
|
|
* From now, all the created objects will use styles from this theme by default
|
|
|
|
* @param th pointer to theme (return value of: 'lv_theme_init_xxx()')
|
|
|
|
*/
|
2019-12-31 07:03:34 +01:00
|
|
|
void lv_theme_set_act(lv_theme_t * th)
|
2017-11-16 15:32:33 +01:00
|
|
|
{
|
2019-12-31 07:03:34 +01:00
|
|
|
act_theme = th;
|
2017-11-16 15:32:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current system theme.
|
|
|
|
* @return pointer to the current system theme. NULL if not set.
|
|
|
|
*/
|
2019-12-31 07:03:34 +01:00
|
|
|
lv_theme_t * lv_theme_get_act(void)
|
|
|
|
{
|
|
|
|
return act_theme;
|
|
|
|
}
|
|
|
|
|
2020-04-14 09:55:11 +02:00
|
|
|
/**
|
|
|
|
* Get the small font of the theme
|
|
|
|
* @return pointer to the font
|
|
|
|
*/
|
|
|
|
const lv_font_t * lv_theme_get_font_small(void)
|
|
|
|
{
|
|
|
|
return act_theme->font_small;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the normal font of the theme
|
|
|
|
* @return pointer to the font
|
|
|
|
*/
|
|
|
|
const lv_font_t * lv_theme_get_font_normal(void)
|
|
|
|
{
|
|
|
|
return act_theme->font_normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the subtitle font of the theme
|
|
|
|
* @return pointer to the font
|
|
|
|
*/
|
|
|
|
const lv_font_t * lv_theme_get_font_subtitle(void)
|
|
|
|
{
|
|
|
|
return act_theme->font_subtitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the title font of the theme
|
|
|
|
* @return pointer to the font
|
|
|
|
*/
|
|
|
|
const lv_font_t * lv_theme_get_font_title(void)
|
|
|
|
{
|
|
|
|
return act_theme->font_title;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the primary color of the theme
|
|
|
|
* @return the color
|
|
|
|
*/
|
|
|
|
lv_color_t lv_theme_get_color_primary(void)
|
|
|
|
{
|
|
|
|
return act_theme->color_primary;
|
|
|
|
}
|
|
|
|
|
2020-05-25 11:49:04 +02:00
|
|
|
/**
|
|
|
|
* Get the secondary color of the theme
|
|
|
|
* @return the color
|
|
|
|
*/
|
|
|
|
lv_color_t lv_theme_get_color_secondary(void)
|
|
|
|
{
|
|
|
|
return act_theme->color_secondary;
|
|
|
|
}
|
|
|
|
|
2020-04-14 09:55:11 +02:00
|
|
|
/**
|
|
|
|
* Get the flags of the theme
|
|
|
|
* @return the flags
|
|
|
|
*/
|
|
|
|
uint32_t lv_theme_get_flags(void)
|
|
|
|
{
|
|
|
|
return act_theme->flags;
|
|
|
|
}
|
2019-12-31 11:13:09 +01:00
|
|
|
|
2020-01-18 23:34:34 +01:00
|
|
|
void lv_theme_apply(lv_obj_t * obj, lv_theme_style_t name)
|
|
|
|
{
|
2020-04-17 13:34:27 +02:00
|
|
|
act_theme->apply_xcb(obj, name);
|
2020-01-18 23:34:34 +01:00
|
|
|
}
|
|
|
|
|
2019-12-31 11:13:09 +01:00
|
|
|
|
2017-11-16 15:32:33 +01:00
|
|
|
/**********************
|
|
|
|
* STATIC FUNCTIONS
|
|
|
|
**********************/
|