acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_example_slider_2.c (2296B)
1 #include "../../lv_examples.h" 2 #if LV_USE_SLIDER && LV_BUILD_EXAMPLES 3 4 5 6 /** 7 * Show how to style a slider. 8 */ 9 void lv_example_slider_2(void) 10 { 11 /*Create a transition*/ 12 static const lv_style_prop_t props[] = {LV_STYLE_BG_COLOR, 0}; 13 static lv_style_transition_dsc_t transition_dsc; 14 lv_style_transition_dsc_init(&transition_dsc, props, lv_anim_path_linear, 300, 0, NULL); 15 16 static lv_style_t style_main; 17 static lv_style_t style_indicator; 18 static lv_style_t style_knob; 19 static lv_style_t style_pressed_color; 20 lv_style_init(&style_main); 21 lv_style_set_bg_opa(&style_main, LV_OPA_COVER); 22 lv_style_set_bg_color(&style_main, lv_color_hex3(0xbbb)); 23 lv_style_set_radius(&style_main, LV_RADIUS_CIRCLE); 24 lv_style_set_pad_ver(&style_main, -2); /*Makes the indicator larger*/ 25 26 lv_style_init(&style_indicator); 27 lv_style_set_bg_opa(&style_indicator, LV_OPA_COVER); 28 lv_style_set_bg_color(&style_indicator, lv_palette_main(LV_PALETTE_CYAN)); 29 lv_style_set_radius(&style_indicator, LV_RADIUS_CIRCLE); 30 lv_style_set_transition(&style_indicator, &transition_dsc); 31 32 lv_style_init(&style_knob); 33 lv_style_set_bg_opa(&style_knob, LV_OPA_COVER); 34 lv_style_set_bg_color(&style_knob, lv_palette_main(LV_PALETTE_CYAN)); 35 lv_style_set_border_color(&style_knob, lv_palette_darken(LV_PALETTE_CYAN, 3)); 36 lv_style_set_border_width(&style_knob, 2); 37 lv_style_set_radius(&style_knob, LV_RADIUS_CIRCLE); 38 lv_style_set_pad_all(&style_knob, 6); /*Makes the knob larger*/ 39 lv_style_set_transition(&style_knob, &transition_dsc); 40 41 lv_style_init(&style_pressed_color); 42 lv_style_set_bg_color(&style_pressed_color, lv_palette_darken(LV_PALETTE_CYAN, 2)); 43 44 /*Create a slider and add the style*/ 45 lv_obj_t * slider = lv_slider_create(lv_scr_act()); 46 lv_obj_remove_style_all(slider); /*Remove the styles coming from the theme*/ 47 48 lv_obj_add_style(slider, &style_main, LV_PART_MAIN); 49 lv_obj_add_style(slider, &style_indicator, LV_PART_INDICATOR); 50 lv_obj_add_style(slider, &style_pressed_color, LV_PART_INDICATOR | LV_STATE_PRESSED); 51 lv_obj_add_style(slider, &style_knob, LV_PART_KNOB); 52 lv_obj_add_style(slider, &style_pressed_color, LV_PART_KNOB | LV_STATE_PRESSED); 53 54 lv_obj_center(slider); 55 } 56 57 #endif