mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
add lv_page/cont_fit_width/height functions
This commit is contained in:
parent
b6b77f4b45
commit
556306a269
@ -189,6 +189,30 @@ bool lv_cont_get_ver_fit(const lv_obj_t * cont)
|
||||
return ext->ver_fit == 0 ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get that width reduced by the horizontal padding. Useful if a layout is used.
|
||||
* @param cont pointer to a container object
|
||||
* @return the width which still fits into the container
|
||||
*/
|
||||
lv_coord_t lv_cont_get_fit_width(lv_obj_t * cont)
|
||||
{
|
||||
lv_style_t * style = lv_cont_get_style(cont);
|
||||
|
||||
return lv_obj_get_width(cont) - 2 * style->body.padding.hor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get that height reduced by the vertical padding. Useful if a layout is used.
|
||||
* @param cont pointer to a container object
|
||||
* @return the height which still fits into the container
|
||||
*/
|
||||
lv_coord_t lv_cont_get_fit_height(lv_obj_t * cont)
|
||||
{
|
||||
lv_style_t * style = lv_cont_get_style(cont);
|
||||
|
||||
return lv_obj_get_width(cont) - 2 * style->body.padding.hor;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -125,6 +125,21 @@ bool lv_cont_get_hor_fit(const lv_obj_t * cont);
|
||||
*/
|
||||
bool lv_cont_get_ver_fit(const lv_obj_t * cont);
|
||||
|
||||
|
||||
/**
|
||||
* Get that width reduced by the horizontal padding. Useful if a layout is used.
|
||||
* @param cont pointer to a container object
|
||||
* @return the width which still fits into the container
|
||||
*/
|
||||
lv_coord_t lv_cont_get_fit_width(lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get that height reduced by the vertical padding. Useful if a layout is used.
|
||||
* @param cont pointer to a container object
|
||||
* @return the height which still fits into the container
|
||||
*/
|
||||
lv_coord_t lv_cont_get_fit_height(lv_obj_t * cont);
|
||||
|
||||
/**
|
||||
* Get the style of a container
|
||||
* @param cont pointer to a container object
|
||||
|
@ -306,6 +306,32 @@ bool lv_page_get_arrow_scroll(const lv_obj_t * page)
|
||||
return ext->arrow_scroll ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get that width which can be set to the children to still not cause overflow (show scrollbars)
|
||||
* @param page pointer to a page object
|
||||
* @return the width which still fits into the page
|
||||
*/
|
||||
lv_coord_t lv_page_get_fit_width(lv_obj_t * page)
|
||||
{
|
||||
lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||
|
||||
return lv_obj_get_width(page) - 2 * (bg_style->body.padding.hor + scrl_style->body.padding.hor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get that height which can be set to the children to still not cause overflow (show scrollbars)
|
||||
* @param page pointer to a page object
|
||||
* @return the height which still fits into the page
|
||||
*/
|
||||
lv_coord_t lv_page_get_fit_height(lv_obj_t * page)
|
||||
{
|
||||
lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
||||
lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
||||
|
||||
return lv_obj_get_height(page) - 2 * (bg_style->body.padding.ver + scrl_style->body.padding.ver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a style of a page
|
||||
* @param page pointer to page object
|
||||
|
@ -217,6 +217,21 @@ lv_sb_mode_t lv_page_get_sb_mode(const lv_obj_t * page);
|
||||
*/
|
||||
bool lv_page_get_arrow_scroll(const lv_obj_t * page);
|
||||
|
||||
|
||||
/**
|
||||
* Get that width which can be set to the children to still not cause overflow (show scrollbars)
|
||||
* @param page pointer to a page object
|
||||
* @return the width which still fits into the page
|
||||
*/
|
||||
lv_coord_t lv_page_get_fit_width(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Get that height which can be set to the children to still not cause overflow (show scrollbars)
|
||||
* @param page pointer to a page object
|
||||
* @return the height which still fits into the page
|
||||
*/
|
||||
lv_coord_t lv_page_get_fit_height(lv_obj_t * page);
|
||||
|
||||
/**
|
||||
* Get width of the scrollable part of a page
|
||||
* @param page pointer to a page object
|
||||
|
@ -718,7 +718,7 @@ static void win_init(void)
|
||||
lv_style_copy(&header, &def);
|
||||
header.body.main_color = LV_COLOR_HEX3(0xccc);
|
||||
header.body.grad_color = header.body.main_color;
|
||||
header.body.radius = DEF_RADIUS;
|
||||
header.body.radius = 0;
|
||||
header.body.border.width = 1;
|
||||
header.body.border.color = LV_COLOR_HEX3(0xbbb);
|
||||
header.body.border.part = LV_BORDER_BOTTOM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user