Tabview button style wrong on startup when grouped


What MCU/Processor/Board and compiler are you using?

Simulator (Visual Studio)

What do you experience?

Upon start the button of the active tab is styled with “LV_TABVIEW_STYLE_BTN_TGL_PR” but the group is not in editing mode and therefore the button is not pressed.

What do you expect?

The button is styled with “LV_TABVIEW_STYLE_BTN_TGL_REL”.

Code to reproduce

mw_indev is the mouse wheel driver as encoder. Press the mouse wheel twice (long) to enter and then leave editing mode to get the expected style.

    lv_style_t btn_rel;
    lv_style_t btn_pr;
    lv_style_t btn_tgl_rel;
    lv_style_t btn_tgl_pr;

    lv_style_copy(&btn_rel, &lv_style_btn_rel);
    btn_rel.body.main_color = LV_COLOR_YELLOW;
    btn_rel.body.grad_color = LV_COLOR_YELLOW;

    lv_style_copy(&btn_pr, &lv_style_btn_pr);
    btn_pr.body.main_color = LV_COLOR_BLUE;
    btn_pr.body.grad_color = LV_COLOR_BLUE;

    lv_style_copy(&btn_tgl_rel, &lv_style_btn_tgl_rel);
    btn_tgl_rel.body.main_color = LV_COLOR_RED;
    btn_tgl_rel.body.grad_color = LV_COLOR_RED;

    lv_style_copy(&btn_tgl_pr, &lv_style_btn_tgl_pr);
    btn_tgl_pr.body.main_color = LV_COLOR_GREEN;
    btn_tgl_pr.body.grad_color = LV_COLOR_GREEN;

    lv_obj_t* tabview;
    tabview = lv_tabview_create(lv_scr_act(), NULL);
    lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_REL, &btn_rel);
    lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_PR, &btn_pr);
    lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, &btn_tgl_rel);
    lv_tabview_set_style(tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, &btn_tgl_pr);

    lv_obj_t* tab1 = lv_tabview_add_tab(tabview, "Tab 1");
    lv_obj_t* tab2 = lv_tabview_add_tab(tabview, "Tab 2");

    lv_group_t* g = lv_group_create();
    lv_group_add_obj(g, tabview);
    lv_indev_set_group(mw_indev, g);

Screenshot and/or video

Actual style after startup
Expected style after startup

I’ll investigate. Thanks you for the report!

I’ve examined this issue.

The tabview behaves differently if you focus on it with an ENCODER (set pressed state only in edit mode) or with a POINTER (there is no edit mode so set pressed state immediately.)

The problem is when you create the first object in the group, it will be focused automatically, not by an input device. So the library can’t decide how to behave therefore it chosen POINTER “mode”.

I’ve fixed it in dev-6.1 by assuming the lastly added input device if not focused by an input device.

Thanks for your reply and the quick fix. However I am not able to compile the latest dev-6.1 branch with the “LV_COLOR_16_SWAP” define set to 1. The problem lies in lv_draw_basic.c (line 346, 405 and 413) e.g.:

uint8_t txt_rgb[3] = {,,};

color is of type lv_color_t but this struct does not define the field when compiled with “LV_COLOR_16_SWAP” other then 0:

#if LV_COLOR_16_SWAP == 0
        uint16_t blue : 5;
        uint16_t green : 6;
        uint16_t red : 5;
        uint16_t green_h : 3;
        uint16_t red : 5;
        uint16_t blue : 5;
        uint16_t green_l : 3;

This of course is no problem with the simulator but the colors on my real hardware screen are messed up when this define is not set.

I made a quick dirty fix for my local project but this should be fixed.

I’ve fixed it. Can you confirm it’s working now?

1 Like

Thanks for the quick fix. Works as expected :+1:

1 Like

Great! Thanks for the feedback!