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_scroll_3.c (1551B)
1 #include "../lv_examples.h" 2 #if LV_BUILD_EXAMPLES && LV_USE_LIST 3 4 static uint32_t btn_cnt = 1; 5 6 static void float_btn_event_cb(lv_event_t * e) 7 { 8 lv_event_code_t code = lv_event_get_code(e); 9 lv_obj_t * float_btn = lv_event_get_target(e); 10 11 if(code == LV_EVENT_CLICKED) { 12 lv_obj_t * list = lv_event_get_user_data(e); 13 char buf[32]; 14 lv_snprintf(buf, sizeof(buf), "Track %d", (int)btn_cnt); 15 lv_obj_t * list_btn = lv_list_add_btn(list, LV_SYMBOL_AUDIO, buf); 16 btn_cnt++; 17 18 lv_obj_move_foreground(float_btn); 19 20 lv_obj_scroll_to_view(list_btn, LV_ANIM_ON); 21 } 22 } 23 24 /** 25 * Create a list with a floating button 26 */ 27 void lv_example_scroll_3(void) 28 { 29 lv_obj_t * list = lv_list_create(lv_scr_act()); 30 lv_obj_set_size(list, 280, 220); 31 lv_obj_center(list); 32 33 for(btn_cnt = 1; btn_cnt <= 2; btn_cnt++) { 34 char buf[32]; 35 lv_snprintf(buf, sizeof(buf), "Track %d", (int)btn_cnt); 36 lv_list_add_btn(list, LV_SYMBOL_AUDIO, buf); 37 } 38 39 lv_obj_t * float_btn = lv_btn_create(list); 40 lv_obj_set_size(float_btn, 50, 50); 41 lv_obj_add_flag(float_btn, LV_OBJ_FLAG_FLOATING); 42 lv_obj_align(float_btn, LV_ALIGN_BOTTOM_RIGHT, 0, -lv_obj_get_style_pad_right(list, LV_PART_MAIN)); 43 lv_obj_add_event_cb(float_btn, float_btn_event_cb, LV_EVENT_ALL, list); 44 lv_obj_set_style_radius(float_btn, LV_RADIUS_CIRCLE, 0); 45 lv_obj_set_style_bg_img_src(float_btn, LV_SYMBOL_PLUS, 0); 46 lv_obj_set_style_text_font(float_btn, lv_theme_get_font_large(float_btn), 0); 47 } 48 49 #endif