From 2ccceded2f7408c75c7fc840aa35f7198fc1b21d Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Sun, 24 May 2015 19:14:59 +0900 Subject: [PATCH] live_edit: improve grip control. --- src/bin/live_edit.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bin/live_edit.c b/src/bin/live_edit.c index 2ba302f..3c6df67 100644 --- a/src/bin/live_edit.c +++ b/src/bin/live_edit.c @@ -55,6 +55,7 @@ typedef struct live_editor_s Evas_Object *ctrl_pt[Ctrl_Pt_Cnt]; Evas_Object *align_line[Align_Line_Cnt]; Evas_Object *info_text[Info_Text_Cnt]; + Evas_Coord_Point move_delta; double half_ctrl_size; struct { @@ -701,11 +702,8 @@ layout_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, if (ev->cur.canvas.y > (y + h)) return; if (y > ev->cur.canvas.y) return; - double tmp; - tmp = ((double) (ev->cur.canvas.x - ev->prev.canvas.x) * 0.5); - x = round(((double) x) + tmp); - tmp = ((double) (ev->cur.canvas.y - ev->prev.canvas.y) * 0.5); - y = round(((double) y) + tmp); + x = ev->cur.canvas.x - ld->move_delta.x; + y = ev->cur.canvas.y - ld->move_delta.y; //limit to live view boundary if (lx > x) x = lx; @@ -766,6 +764,13 @@ layout_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, return; } + /* Store (cursor - obj position) distance. + And keep this distance while obj is moving. */ + Evas_Coord x, y; + evas_object_geometry_get(obj, &x, &y, NULL, NULL); + ld->move_delta.x = ev->canvas.x - x; + ld->move_delta.y = ev->canvas.y - y; + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, layout_mouse_move_cb, data);