e_pointer: move the pointer in calc with hot spot 71/84171/1
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 17 Aug 2016 05:33:20 +0000 (14:33 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 17 Aug 2016 05:54:00 +0000 (14:54 +0900)
Change-Id: I34ae7177934389a7ceccbbe698c6e7e0d1736216

src/bin/e_pointer.c
src/bin/e_pointer.h

index a35d05f..4d125ed 100644 (file)
@@ -4,6 +4,18 @@
 static Eina_List *_ptrs = NULL;
 static Eina_Bool _initted = EINA_FALSE;
 
+/* move the cursor image with the calcaultion of the hot spot */
+static void
+_e_pointer_move(E_Pointer *ptr, int x, int y)
+{
+   int nx, ny;
+
+   nx = ptr->x - ptr->hot.x;
+   ny = ptr->y - ptr->hot.y;
+
+   evas_object_move(ptr->o_ptr, nx, ny);
+}
+
 static void
 _e_pointer_map_transform(int width, int height, uint32_t transform,
                          int sx, int sy, int *dx, int *dy)
@@ -26,6 +38,7 @@ _e_pointer_map_transform(int width, int height, uint32_t transform,
      }
 }
 
+// TODO: transform the cursor position with hot spot...!!!!!!
 static void
 _e_pointer_rotation_apply(E_Pointer *ptr)
 {
@@ -56,7 +69,7 @@ _e_pointer_rotation_apply(E_Pointer *ptr)
      {
         evas_object_map_set(ec->frame, NULL);
         evas_object_map_enable_set(ec->frame, EINA_FALSE);
-        evas_object_move(ec->frame, x, y);
+        _e_pointer_move(ptr, x, y);
         return;
      }
 
@@ -216,6 +229,10 @@ e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y)
         ptr->device = E_POINTER_NONE;
      }
 
+   /* update the hot spot of the cursor */
+   ptr->hot.x = x;
+   ptr->hot.y = y;
+
    /* if obj is not null, set the obj to ptr->o_ptr */
    if (obj)
      {
@@ -232,7 +249,7 @@ e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y)
         _e_pointer_rotation_apply(ptr);
 
         /* move the pointer to the current position */
-        evas_object_move(obj, ptr->x, ptr->y);
+        _e_pointer_move(ptr, ptr->x, ptr->y);
 
         /* show cursor object */
         evas_object_show(obj);
@@ -256,7 +273,7 @@ e_pointer_touch_move(E_Pointer *ptr, int x, int y)
    if (ptr->device != E_POINTER_TOUCH) ptr->device = E_POINTER_TOUCH;
 
    _e_pointer_rotation_apply(ptr);
-   evas_object_move(ptr->o_ptr, ptr->x, ptr->y);
+   _e_pointer_move(ptr, ptr->x, ptr->y);
 }
 
 EINTERN void
@@ -275,7 +292,7 @@ e_pointer_mouse_move(E_Pointer *ptr, int x, int y)
    if (ptr->device != E_POINTER_MOUSE) ptr->device = E_POINTER_MOUSE;
 
    _e_pointer_rotation_apply(ptr);
-   evas_object_move(ptr->o_ptr, ptr->x, ptr->y);
+   _e_pointer_move(ptr, ptr->x, ptr->y);
 }
 
 E_API void
@@ -304,7 +321,7 @@ e_pointer_rotation_set(E_Pointer *ptr, int rotation)
    ptr->rotation = rotation;
 
    _e_pointer_rotation_apply(ptr);
-   evas_object_move(ptr->o_ptr, ptr->x, ptr->y);
+   _e_pointer_move(ptr, ptr->x, ptr->y);
 }
 
 E_API void
index 3ce1989..f1fd286 100644 (file)
@@ -41,6 +41,12 @@ struct _E_Pointer
    int x, y, w, h;
    int rotation;
 
+   struct
+     {
+        int x, y;
+        Eina_Bool update : 1;
+     } hot;
+
    E_Pointer_Device device;
 
    Eina_Bool e_cursor : 1;