diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index 4a8f23459d..196847e3ad 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -538,6 +538,17 @@ lv_coord_t lv_obj_get_y2(const lv_obj_t * obj) return lv_obj_get_y(obj) + lv_obj_get_height(obj); } +lv_coord_t lv_obj_get_x_aligned(const lv_obj_t * obj) +{ + return lv_obj_get_style_x(obj, LV_PART_MAIN); +} + +lv_coord_t lv_obj_get_y_aligned(const lv_obj_t * obj) +{ + return lv_obj_get_style_y(obj, LV_PART_MAIN); +} + + lv_coord_t lv_obj_get_width(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); diff --git a/src/core/lv_obj_pos.h b/src/core/lv_obj_pos.h index c73159ffd7..9fe7817928 100644 --- a/src/core/lv_obj_pos.h +++ b/src/core/lv_obj_pos.h @@ -35,24 +35,36 @@ typedef struct { **********************/ /** - * Set the relative the position of an object (relative to the parent's top left corner) + * Set the the position of an object relative to the set alignment. * @param obj pointer to an object - * @param x new distance from the left side of the parent plus the parent's left padding - * @param y new distance from the top side of the parent plus the parent's right padding + * @param x new x coordinate + * @param y new y coordinate + * @note With default alignment it's the distance from the top left corner + * @note E.g. LV_ALIGN_CENTER alignment it's the offset from the center of the parent + * @note The position is interpreted on the content area of the parent + * @note The values can be set in pixel or in percentage of parent size with `lv_pct(v)` */ void lv_obj_set_pos(struct _lv_obj_t * obj, lv_coord_t x, lv_coord_t y); /** * Set the x coordinate of a object * @param obj pointer to an object - * @param x new distance from the left side from the parent plus the parent's left padding + * @param x new x coordinate + * @note With default alignment it's the distance from the top left corner + * @note E.g. LV_ALIGN_CENTER alignment it's the offset from the center of the parent + * @note The position is interpreted on the content area of the parent + * @note The values can be set in pixel or in percentage of parent size with `lv_pct(v)` */ void lv_obj_set_x(struct _lv_obj_t * obj, lv_coord_t x); /** * Set the y coordinate of a object * @param obj pointer to an object - * @param y new distance from the top of the parent plus the parent's top padding + * @param y new y coordinate + * @note With default alignment it's the distance from the top left corner + * @note E.g. LV_ALIGN_CENTER alignment it's the offset from the center of the parent + * @note The position is interpreted on the content area of the parent + * @note The values can be set in pixel or in percentage of parent size with `lv_pct(v)` */ void lv_obj_set_y(struct _lv_obj_t * obj, lv_coord_t y); @@ -245,6 +257,20 @@ lv_coord_t lv_obj_get_y(const struct _lv_obj_t * obj); */ lv_coord_t lv_obj_get_y2(const struct _lv_obj_t * obj); +/** + * Get the actually set x coordinate of object, i.e. the offset form the set alignment + * @param obj pointer to an object + * @return the set x coordinate + */ +lv_coord_t lv_obj_get_x_aligned(const struct _lv_obj_t * obj); + +/** + * Get the actually set y coordinate of object, i.e. the offset form the set alignment + * @param obj pointer to an object + * @return the set y coordinate + */ +lv_coord_t lv_obj_get_y_aligned(const struct _lv_obj_t * obj); + /** * Get the width of an object * @param obj pointer to an object diff --git a/src/core/lv_obj_style.h b/src/core/lv_obj_style.h index d21f40cec6..b1d041481c 100644 --- a/src/core/lv_obj_style.h +++ b/src/core/lv_obj_style.h @@ -230,15 +230,6 @@ static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t val lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, lv_part_t part, const char * txt); -static inline lv_coord_t lv_obj_get_x_aligned(const struct _lv_obj_t * obj) -{ - return lv_obj_get_style_x(obj, LV_PART_MAIN); -} - -static inline lv_coord_t lv_obj_get_y_aligned(const struct _lv_obj_t * obj) -{ - return lv_obj_get_style_y(obj, LV_PART_MAIN); -} /********************** * MACROS