diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 91e2f9636..8f454d2c5 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -1061,6 +1061,65 @@ void lv_obj_set_auto_realign(lv_obj_t * obj, bool en) #endif } +/** + * Moves all children with horizontally or vertically. + * It doesn't take into account any limits so any values are possible + * @param obj pointer to an object whose children should be moved + * @param x pixel to move horizontally + * @param y pixels to move vertically + */ +void lv_obj_scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) +{ + obj->scroll.x += x; + obj->scroll.y += y; + + refresh_children_position(obj, x, y); +} +/** + * Moves all children with horizontally or vertically. + * Limits the scroll to the bounding box of the children. + * @param obj pointer to an object whose children should be moved + * @param x pixel to move horizontally + * @param y pixels to move vertically + */ +void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en) +{ + obj->scroll.x += x; + obj->scroll.y += y; + + refresh_children_position(obj, x, y); +} + +/** + * Scroll the a given x coordinate to the left side of obj. + * @param obj pointer to an object which should be scrolled + * @param x the x coordinate to scroll to + * @param y the y coordinate to scroll to + */ +void lv_obj_scroll_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en) +{ + +} + +/** + * Scroll the a given x coordinate to the left side of obj. + * @param obj pointer to an object which should be scrolled + * @param x the x coordinate to scroll to + */ +void lv_obj_scroll_to_x(lv_obj_t * obj, lv_coord_t x, lv_anim_enable_t anim_en) +{ +// refresh_children_position(obj, x, y); +} + +/** + * Scroll the a given y coordinate to the top side of obj. + * @param obj pointer to an object which should be scrolled + * @param y the y coordinate to scroll to + */ +void lv_obj_scroll_to_y(lv_obj_t * obj, lv_coord_t y, lv_anim_enable_t anim_en) +{ +// refresh_children_position(obj, x, y); +} /** * Set the size of an extended clickable area diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index ad438c399..112959fe1 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -198,6 +198,7 @@ typedef struct _lv_obj_t { lv_ll_t child_ll; /**< Linked list to store the children objects*/ lv_area_t coords; /**< Coordinates of the object (x1, y1, x2, y2)*/ + lv_point_t scroll; /**< The current X/Y scroll offset*/ lv_event_cb_t event_cb; /**< Event callback function */ lv_signal_cb_t signal_cb; /**< Object type specific signal function*/