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_tabview_2.c (2048B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_TABVIEW && LV_BUILD_EXAMPLES
      3 
      4 static void scroll_begin_event(lv_event_t * e)
      5 {
      6     /*Disable the scroll animations. Triggered when a tab button is clicked */
      7     if(lv_event_get_code(e) == LV_EVENT_SCROLL_BEGIN) {
      8         lv_anim_t * a = lv_event_get_param(e);
      9         if(a)  a->time = 0;
     10     }
     11 }
     12 
     13 void lv_example_tabview_2(void)
     14 {
     15     /*Create a Tab view object*/
     16     lv_obj_t * tabview;
     17     tabview = lv_tabview_create(lv_scr_act(), LV_DIR_LEFT, 80);
     18     lv_obj_add_event_cb(lv_tabview_get_content(tabview), scroll_begin_event, LV_EVENT_SCROLL_BEGIN, NULL);
     19 
     20     lv_obj_set_style_bg_color(tabview, lv_palette_lighten(LV_PALETTE_RED, 2), 0);
     21 
     22     lv_obj_t * tab_btns = lv_tabview_get_tab_btns(tabview);
     23     lv_obj_set_style_bg_color(tab_btns, lv_palette_darken(LV_PALETTE_GREY, 3), 0);
     24     lv_obj_set_style_text_color(tab_btns, lv_palette_lighten(LV_PALETTE_GREY, 5), 0);
     25     lv_obj_set_style_border_side(tab_btns, LV_BORDER_SIDE_RIGHT, LV_PART_ITEMS | LV_STATE_CHECKED);
     26 
     27 
     28     /*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
     29     lv_obj_t * tab1 = lv_tabview_add_tab(tabview, "Tab 1");
     30     lv_obj_t * tab2 = lv_tabview_add_tab(tabview, "Tab 2");
     31     lv_obj_t * tab3 = lv_tabview_add_tab(tabview, "Tab 3");
     32     lv_obj_t * tab4 = lv_tabview_add_tab(tabview, "Tab 4");
     33     lv_obj_t * tab5 = lv_tabview_add_tab(tabview, "Tab 5");
     34 
     35     lv_obj_set_style_bg_color(tab2, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0);
     36     lv_obj_set_style_bg_opa(tab2, LV_OPA_COVER, 0);
     37 
     38     /*Add content to the tabs*/
     39     lv_obj_t * label = lv_label_create(tab1);
     40     lv_label_set_text(label, "First tab");
     41 
     42     label = lv_label_create(tab2);
     43     lv_label_set_text(label, "Second tab");
     44 
     45     label = lv_label_create(tab3);
     46     lv_label_set_text(label, "Third tab");
     47 
     48     label = lv_label_create(tab4);
     49     lv_label_set_text(label, "Forth tab");
     50 
     51     label = lv_label_create(tab5);
     52     lv_label_set_text(label, "Fifth tab");
     53 
     54     lv_obj_clear_flag(lv_tabview_get_content(tabview), LV_OBJ_FLAG_SCROLLABLE);
     55 }
     56 #endif