1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

fix theme initialization

This commit is contained in:
manison 2019-02-12 15:02:43 +01:00
parent 728cd17275
commit c94fb96bb2
10 changed files with 20 additions and 17 deletions

View File

@ -35,7 +35,7 @@ static lv_theme_t * current_theme;
* (The pointers in the theme points to the styles declared by the theme itself) */ * (The pointers in the theme points to the styles declared by the theme itself) */
/* Store the styles in this array. */ /* Store the styles in this array. */
static lv_style_t th_styles[sizeof(((lv_theme_t *)0)->style) / sizeof(lv_style_t *)]; static lv_style_t th_styles[LV_THEME_STYLE_COUNT];
static bool inited = false; static bool inited = false;
static lv_theme_t current_theme; static lv_theme_t current_theme;
#endif #endif

View File

@ -314,6 +314,9 @@ lv_theme_t * lv_theme_get_current(void);
* MACROS * MACROS
**********************/ **********************/
/* Returns number of styles within the `lv_theme_t` structure. */
#define LV_THEME_STYLE_COUNT (sizeof(((lv_theme_t *)0)->style) / sizeof(lv_style_t *))
/********************** /**********************
* POST INCLUDE * POST INCLUDE
*********************/ *********************/

View File

@ -817,8 +817,8 @@ lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }

View File

@ -376,8 +376,8 @@ lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }

View File

@ -801,8 +801,8 @@ lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }

View File

@ -435,8 +435,8 @@ lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }

View File

@ -800,8 +800,8 @@ lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }

View File

@ -710,8 +710,8 @@ lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }

View File

@ -385,8 +385,8 @@ lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }

View File

@ -767,8 +767,8 @@ lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font)
/*For backward compatibility initialize all theme elements with a default style */ /*For backward compatibility initialize all theme elements with a default style */
uint16_t i; uint16_t i;
lv_style_t ** style_p = (lv_style_t **) &theme; lv_style_t ** style_p = (lv_style_t **) &theme.style;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t *); i++) { for(i = 0; i < LV_THEME_STYLE_COUNT; i++) {
*style_p = &def; *style_p = &def;
style_p++; style_p++;
} }