add lv_page/cont_fit_width/height functions
This commit is contained in:
@@ -189,6 +189,30 @@ bool lv_cont_get_ver_fit(const lv_obj_t * cont)
|
|||||||
return ext->ver_fit == 0 ? false : true;
|
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
|
* 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);
|
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
|
* Get the style of a container
|
||||||
* @param cont pointer to a container object
|
* @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;
|
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
|
* Get a style of a page
|
||||||
* @param page pointer to page object
|
* @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);
|
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
|
* Get width of the scrollable part of a page
|
||||||
* @param page pointer to a page object
|
* @param page pointer to a page object
|
||||||
|
|||||||
@@ -718,7 +718,7 @@ static void win_init(void)
|
|||||||
lv_style_copy(&header, &def);
|
lv_style_copy(&header, &def);
|
||||||
header.body.main_color = LV_COLOR_HEX3(0xccc);
|
header.body.main_color = LV_COLOR_HEX3(0xccc);
|
||||||
header.body.grad_color = header.body.main_color;
|
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.width = 1;
|
||||||
header.body.border.color = LV_COLOR_HEX3(0xbbb);
|
header.body.border.color = LV_COLOR_HEX3(0xbbb);
|
||||||
header.body.border.part = LV_BORDER_BOTTOM;
|
header.body.border.part = LV_BORDER_BOTTOM;
|
||||||
|
|||||||
Reference in New Issue
Block a user