How to apply styles to a widget inside a custom widget


I’m developing my own widget which has a bar and a label inside. It works fine, but I want to let users of the widget to adjust the border of the bar in my widget. Previous LVGL versions let me define custom style lists for my widget, but I don’t know how to do this with the latest LVGL (9.0.0).

I tried the following to adjust the border of LV_PART_INDICATOR:

	static lv_style_t st_border;
	lv_style_set_border_width(&st_border, 3);
	lv_obj_add_style(toast_progress, &st_border, LV_PART_INDICATOR | LV_STATE_DEFAULT);

And I apply the border width in my widget’s LV_EVENT_STYLE_CHANGED handler:

lv_obj_set_style_border_width(toast->bar, lv_obj_get_style_border_width(obj, LV_PART_INDICATOR), 0);

However, lv_obj_get_style_border_width(obj, LV_PART_INDICATOR) returns 0. Also it would be nice to apply all styles set for LV_PART_INDICATOR to the bar widget, not just the border width.

What MCU/Processor/Board and compiler are you using?

I’m currently using an SDL-based simulator on an Intel PC running Linux.

What LVGL version are you using?


Screenshot and/or video