Skip to content

[LVGL] Add Set Style Prop action #960

@zalexzperez

Description

@zalexzperez

Set Obj Style Prop is essential, but sometimes we want to change multiple objects at the same time, that's why we have styles.

It would be helpful to have an option that allows modifying style properties at runtime. For example, this would make it possible to set a custom background color for multiple pages that share the same style through a flow action.

Currently, I have this native action that allows choosing from two different colors:

void action_handle_background_color(lv_event_t *e)
{

    uint32_t color_index = flow::getUserProperty(ACTION_HANDLE_BACKGROUND_COLOR_PROPERTY_COLOR_INDEX).getInt32();

    lv_style_t *style0 = get_style_main_panel_style_flex_layout_MAIN_DEFAULT();
    lv_style_t *style1 = get_style_main_panel_style_no_layout_MAIN_DEFAULT();

    switch (color_index)
    {
    case 0: // Violet
        lv_style_set_bg_color(style0, lv_color_hex(0xff7e3783));
        lv_style_set_bg_color(style1, lv_color_hex(0xff7e3783));
        break;

    case 1: // Amber
        lv_style_set_bg_color(style0, lv_color_hex(0xffa3541c));
        lv_style_set_bg_color(style1, lv_color_hex(0xffa3541c));
        break;

    default:
        CUSTOM_LOG("Unknown color index");
        break;
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions