example i want to use container syle to lvgl demo printer like this,
lv_theme_apply(cont, (lv_theme_style_t)LV_DEMO_PRINTER_THEME_ICON);
can I use the printer theme on my container? i was trying to copy the demo printer, and include it in my project but did not work , to use printer demo style
this my whole project
iam using esp32 with ili9313 320x240
I think the easiest way is to make a copy of lv_demo_ printer_theme.c
, and then call xxx_ in your widgets file. call xxx_theme_init
to initialize theme, using lv_theme_set_ act(th) to bind the topic. Just like the
lv_demo_printer_theme.cand
lv_demo_printer` did.
In lv_demo_printer.c
lv_theme_t * th = lv_demo_printer_theme_init(LV_COLOR_BLACK, LV_COLOR_BLACK,
0, &lv_font_montserrat_14, &lv_font_montserrat_22,
&lv_font_montserrat_28, &lv_font_montserrat_32);
lv_theme_set_act(th);
It will set theme.apply_xcb
to theme_apply
which defined in theme file.
lv_theme_t * lv_demo_printer_theme_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags,
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle,
const lv_font_t * font_title)
{
theme.color_primary = color_primary;
theme.color_secondary = color_secondary;
theme.font_small = font_small;
theme.font_normal = font_normal;
theme.font_subtitle = font_subtitle;
theme.font_title = font_title;
theme.flags = flags;
basic_init();
theme.apply_xcb = theme_apply;
return &theme;
}
After these settings, when you create and widget, it will find the corresponding style in theme_apply
function and add it to existing style like this:
case LV_THEME_CONT:
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN);
_lv_style_list_add_style(list, &style_box);
break;