From 0c3a18e1fef8861e964a205f05924b8d47f2d180 Mon Sep 17 00:00:00 2001 From: Themba Dube Date: Mon, 8 Apr 2019 08:38:25 -0400 Subject: [PATCH] Call lv_obj_set_pos if both drag directions are enabled --- src/lv_core/lv_indev.c | 16 ++++++++++------ src/lv_core/lv_obj.h | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 63f7d05c4..c62c4cbfb 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -1056,10 +1056,11 @@ static void indev_drag(lv_indev_proc_t * state) lv_coord_t act_x = lv_obj_get_x(drag_obj); lv_coord_t act_y = lv_obj_get_y(drag_obj); - if(allowed_dirs & LV_DRAG_DIR_HOR) + if(allowed_dirs == LV_DRAG_DIR_ALL) + lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x, act_y + state->types.pointer.vect.y); + else if(allowed_dirs & LV_DRAG_DIR_HOR) lv_obj_set_x(drag_obj, act_x + state->types.pointer.vect.x); - - if(allowed_dirs & LV_DRAG_DIR_VER) + else if(allowed_dirs & LV_DRAG_DIR_VER) lv_obj_set_y(drag_obj, act_y + state->types.pointer.vect.y); /*Set the drag in progress flag*/ @@ -1115,9 +1116,12 @@ static void indev_drag_throw(lv_indev_proc_t * proc) lv_coord_t act_x = lv_obj_get_x(drag_obj) + proc->types.pointer.drag_throw_vect.x; lv_coord_t act_y = lv_obj_get_y(drag_obj) + proc->types.pointer.drag_throw_vect.y; - if(allowed_dirs & LV_DRAG_DIR_HOR) lv_obj_set_x(drag_obj, act_x); - - if(allowed_dirs & LV_DRAG_DIR_VER) lv_obj_set_y(drag_obj, act_y); + if(allowed_dirs == LV_DRAG_DIR_ALL) + lv_obj_set_pos(drag_obj, act_x, act_y); + else if(allowed_dirs & LV_DRAG_DIR_HOR) + lv_obj_set_x(drag_obj, act_x); + else if(allowed_dirs & LV_DRAG_DIR_VER) + lv_obj_set_y(drag_obj, act_y); lv_area_t coord_new; lv_obj_get_coords(drag_obj, &coord_new); diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 6cc9a3275..10925e5c3 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -171,7 +171,8 @@ typedef struct enum { LV_DRAG_DIR_HOR = 0x1, - LV_DRAG_DIR_VER = 0x2 + LV_DRAG_DIR_VER = 0x2, + LV_DRAG_DIR_ALL = 0x3, /* Should be the bitwise OR of the above */ }; typedef uint8_t lv_drag_dir_t;