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_menu_4.c (2057B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_MENU && LV_BUILD_EXAMPLES
      3 
      4 static uint32_t btn_cnt = 1;
      5 static lv_obj_t * main_page;
      6 static lv_obj_t * menu;
      7 
      8 static void float_btn_event_cb(lv_event_t * e)
      9 {
     10     LV_UNUSED(e);
     11 
     12     btn_cnt++;
     13 
     14     lv_obj_t * cont;
     15     lv_obj_t * label;
     16 
     17     lv_obj_t * sub_page = lv_menu_page_create(menu, NULL);
     18 
     19     cont = lv_menu_cont_create(sub_page);
     20     label = lv_label_create(cont);
     21     lv_label_set_text_fmt(label, "Hello, I am hiding inside %i", btn_cnt);
     22 
     23     cont = lv_menu_cont_create(main_page);
     24     label = lv_label_create(cont);
     25     lv_label_set_text_fmt(label, "Item %i", btn_cnt);
     26     lv_menu_set_load_page_event(menu, cont, sub_page);
     27 
     28     lv_obj_scroll_to_view_recursive(cont, LV_ANIM_ON);
     29 }
     30 
     31 void lv_example_menu_4(void)
     32 {
     33     /*Create a menu object*/
     34     menu = lv_menu_create(lv_scr_act());
     35     lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));
     36     lv_obj_center(menu);
     37 
     38     lv_obj_t * cont;
     39     lv_obj_t * label;
     40 
     41     /*Create a sub page*/
     42     lv_obj_t * sub_page = lv_menu_page_create(menu, NULL);
     43 
     44     cont = lv_menu_cont_create(sub_page);
     45     label = lv_label_create(cont);
     46     lv_label_set_text(label, "Hello, I am hiding inside the first item");
     47 
     48     /*Create a main page*/
     49     main_page = lv_menu_page_create(menu, NULL);
     50 
     51     cont = lv_menu_cont_create(main_page);
     52     label = lv_label_create(cont);
     53     lv_label_set_text(label, "Item 1");
     54     lv_menu_set_load_page_event(menu, cont, sub_page);
     55 
     56     lv_menu_set_page(menu, main_page);
     57 
     58     /*Create floating btn*/
     59     lv_obj_t * float_btn = lv_btn_create(lv_scr_act());
     60     lv_obj_set_size(float_btn, 50, 50);
     61     lv_obj_add_flag(float_btn, LV_OBJ_FLAG_FLOATING);
     62     lv_obj_align(float_btn, LV_ALIGN_BOTTOM_RIGHT, -10, -10);
     63     lv_obj_add_event_cb(float_btn, float_btn_event_cb, LV_EVENT_CLICKED, menu);
     64     lv_obj_set_style_radius(float_btn, LV_RADIUS_CIRCLE, 0);
     65     lv_obj_set_style_bg_img_src(float_btn, LV_SYMBOL_PLUS, 0);
     66     lv_obj_set_style_text_font(float_btn, lv_theme_get_font_large(float_btn), 0);
     67 }
     68 
     69 #endif
     70