Questions about Version 7.0 styles and theme

@pete-pjb
We are fine, thank you. ^^ I hope you too!

I’ve added the run time theme change feature. Unlike in v6, in v7 you can change only the current theme run time by calling lv_theme_xxx_init.

 lv_theme_material_init(LV_COLOR_RED, LV_COLOR_BLUE,
                LV_THEME_MATERIAL_FLAG_DARK, 
                &lv_font_roboto_16, &lv_font_roboto_22, &lv_font_roboto_28, &lv_font_roboto_28);

As you probably already know v7 supports “style cascading” (similar to CSS). Therefore it’s not recommended to overwrite the theme styles directly, but you can add custom styles to overwrite some properties. For example to make a button green you can create a “green button style” and add it to the buttons you need. Like this:
btn

t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_set_pos(btn1, 10, 10);

static lv_style_t style_green_btn;
lv_style_init(&style_green_btn);
lv_style_set_border_color(&style_green_btn, LV_STATE_DEFAULT, LV_COLOR_LIME);
lv_style_set_border_color(&style_green_btn, LV_STATE_PRESSED, LV_COLOR_GREEN);
lv_style_set_bg_color(&style_green_btn, LV_STATE_PRESSED, LV_COLOR_LIME);

lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_add_style(btn2, LV_BTN_PART_MAIN, &style_green_btn);
lv_obj_set_pos(btn2, 10, 100);

v7 is designed to supports hovering but it’s still not implemented.

1 Like