lvgl lv_tabview tab透明设置

#if 1
#if 1
    static lv_style_t style_tab, style1;
    lv_style_init(&style_tab);
    lv_style_init(&style1);
    //lv_style_set_pad_top(&style_tab, LV_STATE_DEFAULT, LV_DPX(8));
    //lv_style_set_pad_bottom(&style_tab, LV_STATE_DEFAULT, LV_DPX(8));
    lv_style_set_pad_left(&style_tab, LV_STATE_DEFAULT, LV_DPX(0));
    lv_style_set_pad_right(&style_tab, LV_STATE_DEFAULT, LV_DPX(160));

    //lv_style_set_border_width(&style1, LV_STATE_DEFAULT, 120);

    //lv_style_set_bg_color(&style_tab, LV_STATE_FOCUSED, LV_COLOR_GREEN);  // FOCUSED is not working ???
    //lv_style_set_bg_color(&style_tab, LV_STATE_PRESSED, LV_COLOR_RED);
    //lv_style_set_bg_opa(&style_tab, LV_STATE_CHECKED, LV_OPA_COVER);
#if 1
    lv_style_set_bg_opa(&style1,LV_STATE_DEFAULT,LV_OPA_0);
    lv_style_set_bg_opa(&style1,LV_STATE_PRESSED,LV_OPA_0);
    lv_style_set_bg_opa(&style1,LV_STATE_FOCUSED,LV_OPA_0);
    lv_style_set_bg_opa(&style1,LV_STATE_EDITED,LV_OPA_0);
    lv_style_set_bg_opa(&style1,LV_STATE_CHECKED,LV_OPA_0);
    lv_style_set_bg_opa(&style1,LV_STATE_HOVERED,LV_OPA_0);
    lv_style_set_bg_opa(&style1,LV_STATE_DISABLED,LV_OPA_0);
    lv_style_set_border_opa(&style1,LV_STATE_DISABLED,LV_OPA_0);

    lv_style_set_outline_opa(&style1,LV_STATE_DEFAULT,LV_OPA_0);
    lv_style_set_outline_opa(&style1,LV_STATE_PRESSED,LV_OPA_0);
    lv_style_set_outline_opa(&style1,LV_STATE_FOCUSED,LV_OPA_0);
    lv_style_set_outline_opa(&style1,LV_STATE_EDITED,LV_OPA_0);
    lv_style_set_outline_opa(&style1,LV_STATE_CHECKED,LV_OPA_0);
    lv_style_set_outline_opa(&style1,LV_STATE_HOVERED,LV_OPA_0);

    lv_style_set_bg_opa(&style_tab,LV_STATE_DEFAULT,LV_OPA_0);
    lv_style_set_bg_opa(&style_tab,LV_STATE_PRESSED,LV_OPA_0);
    lv_style_set_bg_opa(&style_tab,LV_STATE_FOCUSED,LV_OPA_0);
    lv_style_set_bg_opa(&style_tab,LV_STATE_EDITED,LV_OPA_0);
    lv_style_set_bg_opa(&style_tab,LV_STATE_CHECKED,LV_OPA_0);
    lv_style_set_bg_opa(&style_tab,LV_STATE_HOVERED,LV_OPA_0);
    lv_style_set_bg_opa(&style_tab,LV_STATE_DISABLED,LV_OPA_0);
    lv_style_set_border_opa(&style_tab,LV_STATE_DISABLED,LV_OPA_0);

    lv_style_set_outline_opa(&style_tab,LV_STATE_DEFAULT,LV_OPA_0);
    lv_style_set_outline_opa(&style_tab,LV_STATE_PRESSED,LV_OPA_0);
    lv_style_set_outline_opa(&style_tab,LV_STATE_FOCUSED,LV_OPA_0);
    lv_style_set_outline_opa(&style_tab,LV_STATE_EDITED,LV_OPA_0);
    lv_style_set_outline_opa(&style_tab,LV_STATE_CHECKED,LV_OPA_0);
    lv_style_set_outline_opa(&style_tab,LV_STATE_HOVERED,LV_OPA_0);
#endif
    //lv_style_set_bg_opa(&style_tab,LV_STATE_DEFAULT,LV_OPA_0);
    //style_tab.body.empty = 1;

    lv_obj_t * lt = lv_tabview_create(data->lvgl_screen, NULL);
    
    lv_obj_reset_style_list(lt, LV_TABVIEW_PART_TAB_BTN ); /*Remove the styles,coming from the theme*/
    lv_obj_add_style(lt, LV_TABVIEW_PART_TAB_BTN, &style_tab);
    //lv_obj_add_style(lt, LV_TABVIEW_PART_TAB_BG, &style1);
    //lv_obj_add_style(lt, LV_TABVIEW_PART_TAB_BTN, &style1);

    #if 1
    //lv_obj_add_style(lt, LV_TABVIEW_PART_TAB_BTN, &style_tab);
    lv_obj_reset_style_list(lt, LV_TABVIEW_PART_BG );
    lv_obj_reset_style_list(lt, LV_TABVIEW_PART_TAB_BG );
    lv_obj_reset_style_list(lt, LV_TABVIEW_PART_INDIC );
    lv_obj_add_style(lt, LV_TABVIEW_PART_BG , &style1);
    lv_obj_add_style(lt, LV_TABVIEW_PART_TAB_BG, &style1);
    lv_obj_add_style(lt, LV_TABVIEW_PART_INDIC, &style1);
    //lv_obj_add_style(lt, LV_TABVIEW_PART_BG_SCRLLABLE, &style1);
    #endif
    
    lv_obj_set_hidden(lt,0);
    lv_tabview_set_anim_time(lt, 0);
    
    lv_tabview_set_btns_pos(lt, LV_TABVIEW_TAB_POS_LEFT);
    lv_obj_t * tab1 = lv_tabview_add_tab(lt," ");
    lv_obj_t * tab2 = lv_tabview_add_tab(lt," ");
    lv_obj_t * tab3 = lv_tabview_add_tab(lt," ");
    lv_obj_t * tab4 = lv_tabview_add_tab(lt," ");
    lv_obj_t * tab5 = lv_tabview_add_tab(lt," ");
    lv_obj_t * obj = NULL;
    avm_init_background(obj, tab1,0, 0, 540, 720, LV_COLOR_BLACK);
    avm_init_background(obj, tab2,0, 0, 540, 720, LV_COLOR_RED);
    avm_init_background(obj, tab3,0, 0, 540, 720, LV_COLOR_BLUE);
    avm_init_background(obj, tab4,0, 0, 540, 720, LV_COLOR_GREEN);
    avm_init_background(obj, tab5,0, 0, 540, 720, LV_COLOR_YELLOW);

    //lv_page_set_scrollbar_mode(tab1, LV_SCROLLBAR_MODE_OFF);
    //lv_page_set_sb_mode(tab1, LV_SB_MODE_OFF);

//    lv_obj_set_style_local_pad_all(tab1, LV_PAGE_PART_SCROLLABLE, LV_STATE_DEFAULT, 0);
//    lv_obj_set_style_local_pad_all(tab1, LV_PAGE_PART_BG, LV_STATE_DEFAULT, 0);
#if 0
    lv_obj_t * img = lv_img_create(tab3, NULL);
    lv_img_set_src(img, "S:/early_app/fastrvc/img_big_b.png");
    lv_obj_set_pos(img, 0, 0);
    lv_obj_set_hidden(img, 0);

    lv_obj_t * sw = lv_switch_create(tab4, NULL);
    lv_obj_set_size(sw, 100, 20);
    lv_obj_set_pos(sw, 100,100);
#endif

#if 0
    lv_style_t style_btn;
    lv_style_init(&style_btn);    
    lv_style_set_bg_opa(&style_btn,LV_STATE_DEFAULT,LV_OPA_0);
    lv_obj_add_style(tab3,LV_TABVIEW_PART_TAB_BTN,&style_btn);
#endif
#if 0
    //lv_obj_set_size(lt, 120,720);
    lv_obj_set_event_cb(lt, avmLtEvent);
    //lv_obj_set_event_cb(tab4,my_test_event2);
    lv_tabview_set_anim_time(lt, 0);

    lv_obj_t* btnbig = lv_btn_create(tab1,NULL);
    lv_obj_set_pos(btnbig,0,30 - 30);
    lv_obj_set_size(btnbig,120,150);
    lv_obj_set_event_cb(btnbig,btn_event_big);

    lv_obj_t* btndown = lv_btn_create(tab2,NULL);
    lv_obj_set_pos(btndown,0,30 - 30);
    lv_obj_set_size(btndown,120,150);
    lv_obj_set_event_cb(btndown,btn_event_down);
#endif
#endif
    
    #if 0
    extern  void lv_demo_stress(void);
    lv_demo_stress();
    #endif
    //lv_btnmatrix_set_btn_ctrl(tab2, 5, LV_BTNMATRIX_CTRL_HIDDEN);

    //lv_page_set_scroll_propagation(tab1,false);
    
#if 0

    lv_obj_t * label = lv_label_create(tab1, NULL);
    lv_label_set_text(label, "This the first tab\n\n");
    lv_obj_t * label2 = lv_label_create(tab2, NULL);
    lv_label_set_text(label2, "This the second tab\n\n");
#endif

#endif

static void avmLtEvent(lv_obj_t* obj, lv_event_t event)
{
      printf("pss dx eventt  event = %d..............\n",event);
      if(event != LV_EVENT_VALUE_CHANGED) return;
      printf("pss dx eventt  event = %d############\n",event);
      lv_tabview_ext_t* ext = (lv_tabview_ext_t*) lv_obj_get_ext_attr(obj);
      //const char* tab_name = ext->tab_name_ptr[lv_tabview_get_tab_act(obj)]; 
      //printf("Current Active Tab : %s\n", tab_name);
      printf("Current : cur = %d, cnt = %d, pos = %d\n", 
      ext->tab_cur,
      ext->tab_cnt,
      ext->btns_pos);
      switch(ext->tab_cur)
      {
        case EN_BUTTON_CLOSE:
            avmCloseDeal();
            break;
        case EN_BUTTON_2D_VIEW:
            avm2DPageInit();
            break;
        case EN_BUTTON_3D_VIEW:
            avm3DPageInit();
            break;
        case EN_BUTTON_MORE:
            avmMorePageInit();
            break;
        case EN_BUTTON_SET:
            avmSetPageInit();
            break;
        default:
            break;
      }
}

lvgl lv_tabview tab透明设置

上面代码完成lv_tabview,的tab隐藏功能

你可能感兴趣的:(前端,javascript,html)