1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| static void lv_example_slider_2(void) { static const lv_style_prop_t props[] = {LV_STYLE_BG_COLOR, 0}; static lv_style_transition_dsc_t transition_dsc; lv_style_transition_dsc_init(&transition_dsc, props, lv_anim_path_linear, 300, 0, NULL);
static lv_style_t style_main; static lv_style_t style_indicator; static lv_style_t style_knob; static lv_style_t style_pressed_color;
lv_style_init(&style_main); lv_style_set_bg_opa(&style_main, LV_OPA_COVER); lv_style_set_bg_color(&style_main, lv_palette_main(LV_PALETTE_PINK)); lv_style_set_radius(&style_main, LV_RADIUS_CIRCLE); lv_style_set_pad_ver(&style_main, -2);
lv_style_init(&style_indicator); lv_style_set_bg_opa(&style_indicator, LV_OPA_COVER); lv_style_set_bg_color(&style_indicator, lv_palette_main(LV_PALETTE_LIGHT_BLUE)); lv_style_set_radius(&style_indicator, LV_RADIUS_CIRCLE); lv_style_set_transition(&style_indicator, &transition_dsc);
lv_style_init(&style_knob); lv_style_set_bg_opa(&style_knob, LV_OPA_COVER); lv_style_set_bg_color(&style_knob, lv_palette_main(LV_PALETTE_CYAN)); lv_style_set_border_color(&style_knob, lv_palette_darken(LV_PALETTE_CYAN, 3)); lv_style_set_border_width(&style_knob, 2); lv_style_set_radius(&style_knob, LV_RADIUS_CIRCLE); lv_style_set_pad_all(&style_knob, 8); lv_style_set_transition(&style_knob, &transition_dsc);
lv_style_init(&style_pressed_color); lv_style_set_bg_color(&style_pressed_color, lv_palette_darken(LV_PALETTE_BLUE, 2));
lv_obj_t * slider = lv_slider_create(lv_scr_act());
lv_obj_add_style(slider, &style_main, LV_PART_MAIN); lv_obj_add_style(slider, &style_indicator, LV_PART_INDICATOR); lv_obj_add_style(slider, &style_pressed_color, LV_PART_INDICATOR | LV_STATE_FOCUSED); lv_obj_add_style(slider, &style_knob, LV_PART_KNOB); lv_obj_add_style(slider, &style_pressed_color, LV_PART_KNOB | LV_STATE_FOCUSED);
lv_obj_center(slider); }
void lv_100ask_demo_course_2_2_5(void) { #if 1
static lv_style_t style_obj; lv_style_init(&style_obj);
lv_style_set_bg_color(&style_obj, lv_palette_main(LV_PALETTE_DEEP_ORANGE)); lv_style_set_text_color(&style_obj, lv_palette_main(LV_PALETTE_DEEP_ORANGE)); lv_style_set_bg_opa(&style_obj, LV_OPA_COVER);
lv_obj_t * obj = lv_obj_create(lv_scr_act()); lv_obj_t * obj2 = lv_obj_create(lv_scr_act()); lv_obj_align(obj2, LV_ALIGN_CENTER, 0 ,0);
lv_obj_set_style_bg_color(obj, lv_palette_main(LV_PALETTE_YELLOW), LV_STATE_PRESSED); lv_obj_set_style_bg_color(obj2, lv_palette_main(LV_PALETTE_AMBER), LV_STATE_PRESSED); lv_obj_set_style_bg_opa(obj, LV_OPA_50, LV_STATE_PRESSED);
lv_obj_add_style(obj, &style_obj, 0); lv_obj_add_style(obj2, &style_obj, 0);
lv_obj_add_style(obj, &style_obj, LV_STATE_PRESSED); lv_obj_add_style(obj2, &style_obj, LV_STATE_PRESSED); #endif
}
|