fix(style): use struct as color filter instead of pure callback for Micropython compatibility

This commit is contained in:
Gabor Kiss-Vamosi
2021-02-24 15:12:36 +01:00
parent d2d8f973b0
commit 8a7f9cb131
9 changed files with 58 additions and 39 deletions

View File

@@ -5,10 +5,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event)
{
LV_UNUSED(obj);
if(event == LV_EVENT_CLICKED) {
LV_LOG_USER("Clicked\n");
LV_LOG_USER("Clicked");
}
else if(event == LV_EVENT_VALUE_CHANGED) {
LV_LOG_USER("Toggled\n");
LV_LOG_USER("Toggled");
}
}

View File

@@ -18,7 +18,7 @@ void lv_example_btn_2(void)
lv_style_set_bg_opa(&style, LV_OPA_70);
lv_style_set_bg_color(&style, lv_color_blue());
lv_style_set_bg_grad_color(&style, lv_color_blue_darken_4());
lv_style_set_bg_grad_color(&style, lv_color_blue_darken_2());
lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);
lv_style_set_border_opa(&style, LV_OPA_40);
@@ -27,16 +27,15 @@ void lv_example_btn_2(void)
lv_style_set_shadow_width(&style, 8);
lv_style_set_shadow_color(&style, lv_color_grey());
lv_style_set_shadow_ofs_x(&style, 8);
lv_style_set_shadow_ofs_y(&style, 8);
lv_style_set_text_color(&style, lv_color_white());
/*Init the pressed style*/
lv_style_set_shadow_ofs_x(&style_pr, 4);
lv_style_set_shadow_ofs_y(&style_pr, 4);
lv_style_set_color_filter_cb(&style_pr, lv_color_darken); /*Darken every color*/
lv_style_set_color_filter_opa(&style_pr, LV_OPA_30);
lv_style_set_shadow_ofs_y(&style_pr, 3);
lv_style_set_bg_color(&style_pr, lv_color_blue_darken_2());
lv_style_set_bg_grad_color(&style_pr, lv_color_blue_darken_4());
lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL);
lv_obj_remove_style(btn1, LV_PART_ANY, LV_STATE_ANY, NULL);