From c9703af47eef8ae76230934a87af367c317692ce Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 15 Mar 2019 07:27:58 +0100 Subject: [PATCH] to lv_cont_get_fit_width/height to lv_obj --- lv_core/lv_obj.c | 23 +++++++++++++++++++++++ lv_core/lv_obj.h | 14 ++++++++++++++ lv_objx/lv_cont.c | 24 ------------------------ lv_objx/lv_cont.h | 15 --------------- 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/lv_core/lv_obj.c b/lv_core/lv_obj.c index c14cea6fb..0d3444ff8 100644 --- a/lv_core/lv_obj.c +++ b/lv_core/lv_obj.c @@ -1517,6 +1517,29 @@ lv_coord_t lv_obj_get_height(const lv_obj_t * obj) return lv_area_get_height(&obj->coords); } +/** + * Get that width reduced by the left and right padding. + * @param obj pointer to an object + * @return the width which still fits into the container + */ +lv_coord_t lv_obj_get_width_fit(lv_obj_t * cont) +{ + lv_style_t * style = lv_cont_get_style(cont); + + return lv_obj_get_width(cont) - style->body.padding.left - style->body.padding.right; +} + +/** + * Get that height reduced by the top an bottom padding. + * @param obj pointer to an object + * @return the height which still fits into the container + */ +lv_coord_t lv_obj_get_height_fit(lv_obj_t * cont) +{ + lv_style_t * style = lv_cont_get_style(cont); + + return lv_obj_get_width(cont) - style->body.padding.top - style->body.padding.bottom; +} /** * Get the extended size attribute of an object * @param obj pointer to an object diff --git a/lv_core/lv_obj.h b/lv_core/lv_obj.h index 7bd61feca..897db7c2e 100644 --- a/lv_core/lv_obj.h +++ b/lv_core/lv_obj.h @@ -649,6 +649,20 @@ lv_coord_t lv_obj_get_width(const lv_obj_t * obj); */ lv_coord_t lv_obj_get_height(const lv_obj_t * obj); +/** + * Get that width reduced by the left and right padding. + * @param obj pointer to an object + * @return the width which still fits into the container + */ +lv_coord_t lv_obj_get_width_fit(lv_obj_t * cont); + +/** + * Get that height reduced by the top an bottom padding. + * @param obj pointer to an object + * @return the height which still fits into the container + */ +lv_coord_t lv_obj_get_height_fit(lv_obj_t * cont); + /** * Get the extended size attribute of an object * @param obj pointer to an object diff --git a/lv_objx/lv_cont.c b/lv_objx/lv_cont.c index 4b030bf4b..20037a7c4 100644 --- a/lv_objx/lv_cont.c +++ b/lv_objx/lv_cont.c @@ -223,30 +223,6 @@ lv_fit_t lv_cont_get_fit_bottom(const lv_obj_t * cont) return ext->fit_bottom; } -/** - * 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) - style->body.padding.left - style->body.padding.right; -} - -/** - * 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) - style->body.padding.top - style->body.padding.bottom; -} - /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_objx/lv_cont.h b/lv_objx/lv_cont.h index 6f24056e0..cf09e1740 100644 --- a/lv_objx/lv_cont.h +++ b/lv_objx/lv_cont.h @@ -175,21 +175,6 @@ lv_fit_t lv_cont_get_fit_top(const lv_obj_t * cont); */ lv_fit_t lv_cont_get_fit_bottom(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