hermet pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=30623aea9ebb1b3923bed51a7c42c55cb8602ef0

commit 30623aea9ebb1b3923bed51a7c42c55cb8602ef0
Author: Jaehyun Cho <[email protected]>
Date:   Fri Nov 28 13:18:16 2014 +0900

    evas_object_main: Keep map effect after evas object move
    
    Summary:
    Keep map effect after evas object move
    @feature
    
    Reviewers: raster, cedric, Hermet
    
    Subscribers: raster, cedric
    
    Differential Revision: https://phab.enlightenment.org/D1678
---
 src/lib/evas/Evas_Common.h             | 27 ++++++++++++
 src/lib/evas/canvas/evas_map.c         | 77 ++++++++++++++++++++++++++++++++++
 src/lib/evas/canvas/evas_object_main.c |  8 ++++
 src/lib/evas/include/evas_private.h    |  6 +++
 4 files changed, 118 insertions(+)

diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index ed336c2..dfffa14 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -2406,6 +2406,33 @@ EAPI void            evas_map_alpha_set(Evas_Map *m, 
Eina_Bool enabled);
 EAPI Eina_Bool       evas_map_alpha_get(const Evas_Map *m);
 
 /**
+ * Set the flag of the object move synchronization for map rendering
+ *
+ * This sets the flag of the object move synchronization for map rendering.
+ * If the flag is set as enabled, the map will be moved as the object of the 
map
+ * is moved. By default, the flag of the object move synchronization is not
+ * enabled.
+ *
+ * @param m map to modify. Must not be NULL.
+ * @param enabled enable or disable the object move synchronization for map
+ *        rendering.
+ * @since 1.13
+ */
+EAPI void            evas_map_util_object_move_sync_set(Evas_Map *m, Eina_Bool 
enabled);
+
+/**
+ * Get the flag of the object move synchronization for map rendering
+ *
+ * This gets the flag of the object move synchronization for map rendering.
+ *
+ * @param m map to get the flag of the object move synchronization from. Must
+ * not be NULL.
+ * @return EINA_FALSE if map is NULL EINA_TRUE otherwise.
+ * @since 1.13
+ */
+EAPI Eina_Bool       evas_map_util_object_move_sync_get(const Evas_Map *m);
+
+/**
  * Copy a previously allocated map.
  *
  * This makes a duplicate of the @p m object and returns it.
diff --git a/src/lib/evas/canvas/evas_map.c b/src/lib/evas/canvas/evas_map.c
index 7b4f577..4680828 100644
--- a/src/lib/evas/canvas/evas_map.c
+++ b/src/lib/evas/canvas/evas_map.c
@@ -152,6 +152,7 @@ _evas_map_copy(Evas_Map *dst, const Evas_Map *src)
      memcpy(dst->points, src->points, src->count * sizeof(Evas_Map_Point));
    dst->smooth = src->smooth;
    dst->alpha = src->alpha;
+   dst->move_sync = src->move_sync;
    dst->persp = src->persp;
    return EINA_TRUE;
 }
@@ -164,6 +165,7 @@ _evas_map_dup(const Evas_Map *orig)
    memcpy(copy->points, orig->points, orig->count * sizeof(Evas_Map_Point));
    copy->smooth = orig->smooth;
    copy->alpha = orig->alpha;
+   copy->move_sync = orig->move_sync;
    copy->persp = orig->persp;
    return copy;
 }
@@ -650,6 +652,31 @@ evas_map_alpha_get(const Evas_Map *m)
    return m->alpha;
 }
 
+EAPI void
+evas_map_util_object_move_sync_set(Evas_Map *m, Eina_Bool enabled)
+{
+   MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
+   return;
+   MAGIC_CHECK_END();
+
+   if (!enabled)
+     {
+        m->move_sync.diff_x = 0;
+        m->move_sync.diff_y = 0;
+     }
+   m->move_sync.enabled = !!enabled;
+}
+
+EAPI Eina_Bool
+evas_map_util_object_move_sync_get(const Evas_Map *m)
+{
+   MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
+   return EINA_FALSE;
+   MAGIC_CHECK_END();
+
+   return m->move_sync.enabled;
+}
+
 EAPI Evas_Map *
 evas_map_dup(const Evas_Map *m)
 {
@@ -1199,6 +1226,8 @@ evas_object_map_update(Evas_Object *eo_obj,
         obj->changed_map = EINA_TRUE;
      }
 
+   evas_object_map_move_sync(eo_obj);
+
    if (!obj->changed_map) return EINA_FALSE;
 
    if (obj->map->cur.map && obj->map->spans && obj->map->cur.map->count != 
obj->map->spans->count)
@@ -1282,3 +1311,51 @@ evas_object_map_update(Evas_Object *eo_obj,
    return obj->changed_pchange;
 }
 
+void
+evas_map_object_move_diff_set(Evas_Map *m,
+                              Evas_Coord diff_x,
+                              Evas_Coord diff_y)
+{
+   MAGIC_CHECK(m, Evas_Map, MAGIC_MAP);
+   return;
+   MAGIC_CHECK_END();
+
+   m->move_sync.diff_x += diff_x;
+   m->move_sync.diff_y += diff_y;
+}
+
+void
+evas_object_map_move_sync(Evas_Object *eo_obj)
+{
+   Evas_Object_Protected_Data *obj;
+   Evas_Map *m;
+   Evas_Map_Point *p;
+   Evas_Coord diff_x, diff_y;
+   int i, count;
+
+   obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
+   if (!obj) return;
+
+   if ((!obj->map->cur.map->move_sync.enabled) ||
+       ((obj->map->cur.map->move_sync.diff_x == 0) &&
+        (obj->map->cur.map->move_sync.diff_y == 0)))
+     return;
+
+   m = obj->map->cur.map;
+   p = m->points;
+   count = m->count;
+   diff_x = m->move_sync.diff_x;
+   diff_y = m->move_sync.diff_y;
+
+   for (i = 0; i < count; i++, p++)
+     {
+        p->px += diff_x;
+        p->py += diff_y;
+        p->x += diff_x;
+        p->y += diff_y;
+     }
+   m->move_sync.diff_x = 0;
+   m->move_sync.diff_y = 0;
+
+   _evas_map_calc_map_geometry(eo_obj);
+}
diff --git a/src/lib/evas/canvas/evas_object_main.c 
b/src/lib/evas/canvas/evas_object_main.c
index ac1f53e..f1459f5 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -750,6 +750,14 @@ _evas_object_position_set(Eo *eo_obj, 
Evas_Object_Protected_Data *obj, Evas_Coor
 
    if ((obj->cur->geometry.x == x) && (obj->cur->geometry.y == y)) return;
 
+   Evas_Map *map = eo_do(eo_obj, evas_obj_map_get());
+   if (map && map->move_sync.enabled)
+     {
+        Evas_Coord diff_x = x - obj->cur->geometry.x;
+        Evas_Coord diff_y = y - obj->cur->geometry.y;
+        evas_map_object_move_diff_set(map, diff_x, diff_y);
+     }
+
    if (!(obj->layer->evas->is_frozen))
      {
         pass = evas_event_passes_through(eo_obj, obj);
diff --git a/src/lib/evas/include/evas_private.h 
b/src/lib/evas/include/evas_private.h
index aa9c852..50f9fa5 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -843,6 +843,10 @@ struct _Evas_Map
    } persp;
    Eina_Bool             alpha : 1;
    Eina_Bool             smooth : 1;
+   struct {
+      Eina_Bool          enabled : 1;
+      Evas_Coord         diff_x, diff_y;
+   } move_sync;
    Evas_Map_Point        points[]; // actual points
 };
 
@@ -1693,6 +1697,8 @@ void evas_render_proxy_subrender(Evas *eo_e, Evas_Object 
*eo_source, Evas_Object
 Eina_Bool evas_map_inside_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y);
 Eina_Bool evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y, 
Evas_Coord *mx, Evas_Coord *my, int grab);
 Eina_Bool evas_object_map_update(Evas_Object *obj, int x, int y, int imagew, 
int imageh, int uvw, int uvh);
+void evas_map_object_move_diff_set(Evas_Map *m, Evas_Coord diff_x, Evas_Coord 
diff_y);
+void evas_object_map_move_sync(Evas_Object *obj);
 
 Eina_List *evas_module_engine_list(void);
 

-- 


Reply via email to