Is it possible to get the height of the "drawable" part of a tabview


I would like to know the height “draw-able” part of the tabview:


is it posible?

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

Simulator and ESP32

What LVGL version are you using?

7.4.0 aka master

What do you want to achieve?

Know the height of the drawable part of the tabview so I can place two containers inside without triggering the sliders on the tabview.

What have you tried so far?

When I use lv_obj_get_height_fit(tabview) I get the height of the whole tabview.

Code to reproduce

The code block(s) should be formatted like:

/* This gets the whole tabview height */
lv_coord_t tb_drawable_height = lv_obj_get_width_fit(tabview);

Screenshot and/or video


Subtract the title height

Indeed, seems like I need to subtract the LV_TABVIEW_PART_TAB_BTN part height. When adding a tab into the tabview a button is added into the internal button matrix, so I think I need to find the button matrix height set by the style?

I think I found a way to do it, I’m getting the size of the title height and the “drawable” part (the drawable part is a lv_page).

lv_tabview_ext_t *tabview_ext = lv_obj_get_ext_attr(tabview);
lv_coord_t tb_btn_h = lv_obj_get_height(tabview_ext->btns);
lv_coord_t tb_content_h = lv_obj_get_height(tabview_ext->content);

/* tb_btn_h is 46, tb_content_h is 194 */

Both heights summed up gives 240, which is the height of my display.

I think if you get the height of a tab returned by lv_tabview_add_tab, it should be the same as tabview_ext->content, unless there’s padding I’m not thinking of.



You are right, both tab_height and tab_height_fit returns 194.

lv_obj_t *tab = lv_tabview_add_tab(tabview, "About");
lv_coord_t tab_height = lv_obj_get_height(tab);
lv_coord_t tab_height_fit = lv_obj_get_height_fit(tab);

We were talking about how padding is handled in the github thread I don’t remember how he ended up doing it but I had suggested that HTML/CSS doesn’t count padding as part of the object. This is probably why, so that when you get the size of an area you don’t include the padding. Makes sense that padding wouldn’t be included because padding is outside or around an area while margin is insides.

Hmm; the CSS box model suggests the opposite (padding on the inside, margin on the outside). In our case, I think we chose to go with the border-box model, which means that everything inside and including the border counts as part of the size. Did I miss something?

I think I mixed it up. I posted that after pulling an all night coding session :smiley: