mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
minor scroll improvements
This commit is contained in:
parent
e8aaaccc8e
commit
5dadb03ae6
@ -910,6 +910,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
proc->types.pointer.scroll_throw_vect.x += (proc->types.pointer.vect.x * 4) >> 3;
|
||||
proc->types.pointer.scroll_throw_vect.y += (proc->types.pointer.vect.y * 4) >> 3;
|
||||
|
||||
proc->types.pointer.scroll_throw_vect_ori = proc->types.pointer.scroll_throw_vect;
|
||||
|
||||
if(indev_obj_act) {
|
||||
lv_signal_send(indev_obj_act, LV_SIGNAL_PRESSING, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
|
@ -215,10 +215,10 @@ lv_coord_t _lv_scroll_throw_predict(lv_indev_t * indev, lv_dir_t dir)
|
||||
lv_coord_t v;
|
||||
switch(dir) {
|
||||
case LV_DIR_VER:
|
||||
v = indev->proc.types.pointer.scroll_throw_vect.y;
|
||||
v = indev->proc.types.pointer.scroll_throw_vect_ori.y;
|
||||
break;
|
||||
case LV_DIR_HOR:
|
||||
v = indev->proc.types.pointer.scroll_throw_vect.x;
|
||||
v = indev->proc.types.pointer.scroll_throw_vect_ori.x;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -158,8 +158,8 @@ void lv_obj_set_size(lv_obj_t * obj, lv_coord_t w, lv_coord_t h)
|
||||
if(parent) {
|
||||
lv_coord_t cont_w = lv_obj_get_width_fit(parent);
|
||||
lv_coord_t cont_h = lv_obj_get_height_fit(parent);
|
||||
if(pct_w) w = (LV_COORD_GET_PCT(obj->w_set) * cont_w) / 100;
|
||||
if(pct_h) h = (LV_COORD_GET_PCT(obj->h_set) * cont_h) / 100;
|
||||
if(pct_w) w = (_LV_COORD_GET_PCT(obj->w_set) * cont_w) / 100;
|
||||
if(pct_h) h = (_LV_COORD_GET_PCT(obj->h_set) * cont_h) / 100;
|
||||
}
|
||||
|
||||
refr_size(obj, w, h);
|
||||
|
@ -136,7 +136,8 @@ void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable
|
||||
*/
|
||||
void lv_obj_scroll_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim_en)
|
||||
{
|
||||
|
||||
lv_obj_scroll_to_x(obj, x, anim_en);
|
||||
lv_obj_scroll_to_y(obj, y, anim_en);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,6 +259,22 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj)
|
||||
return LV_MATH_MAX(child_res, self_w);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X and Y coordinates where the scrolling would end for this object if a scrolling animation is in progress.
|
||||
* In no scrolling animation give the current `left` or `top` scroll position.
|
||||
* @param obj pointer to an object
|
||||
* @param end poinr to point to store the result
|
||||
*/
|
||||
void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end)
|
||||
{
|
||||
lv_anim_t * a;
|
||||
a = lv_anim_get(obj, (lv_anim_exec_xcb_t)scroll_anim_x_cb);
|
||||
end->x = a ? -a->end : lv_obj_get_scroll_left(obj);
|
||||
|
||||
a = lv_anim_get(obj, (lv_anim_exec_xcb_t)scroll_anim_y_cb);
|
||||
end->y = a ? -a->end : lv_obj_get_scroll_top(obj);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -140,6 +140,13 @@ lv_coord_t lv_obj_get_scroll_left(const struct _lv_obj_t * obj);
|
||||
*/
|
||||
lv_coord_t lv_obj_get_scroll_right(struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the X and Y coordinates where the scrolling would end for this object if a scrolling animation is in progress.
|
||||
* In no scrolling animation give the current `left` or `top` scroll position.
|
||||
* @param obj pointer to an object
|
||||
* @param end poinr to point to store the result
|
||||
*/
|
||||
void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -134,6 +134,7 @@ typedef struct _lv_indev_proc_t {
|
||||
lv_point_t vect; /**< Difference between `act_point` and `last_point`. */
|
||||
lv_point_t scroll_sum; /*Count the dragged pixels to check LV_INDEV_DEF_DRAG_LIMIT*/
|
||||
lv_point_t scroll_throw_vect;
|
||||
lv_point_t scroll_throw_vect_ori;
|
||||
struct _lv_obj_t * act_obj; /*The object being pressed*/
|
||||
struct _lv_obj_t * last_obj; /*The last object which was pressed (used by drag_throw and
|
||||
other post-release event)*/
|
||||
|
@ -233,7 +233,7 @@ void _lv_area_align(const lv_area_t * base, const lv_area_t * to_align, lv_align
|
||||
/*Special coordinates*/
|
||||
#define LV_COORD_PCT(x) _LV_COORD_SPEC((x))
|
||||
#define LV_COORD_IS_PCT(x) ((LV_COORD_IS_SPEC(x) && LV_COORD_GET_SPEC(x) <= 1000) ? true : false)
|
||||
#define LV_COORD_GET_PCT(x) LV_COORD_GET_SPEC(x)
|
||||
#define _LV_COORD_GET_PCT(x) LV_COORD_GET_SPEC(x)
|
||||
#define LV_SIZE_AUTO _LV_COORD_SPEC(1001)
|
||||
#define LV_SIZE_STRETCH _LV_COORD_SPEC(1002)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user