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
This commit is contained in:
Jaehyun Cho 2014-11-28 13:18:16 +09:00 committed by ChunEon Park
parent 5b9ece9c85
commit 30623aea9e
4 changed files with 118 additions and 0 deletions

View File

@ -2405,6 +2405,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.
*

View File

@ -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);
}

View File

@ -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);

View File

@ -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);