summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-05-26 15:02:54 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-05-26 15:02:54 +0900
commitafb4d42171f6e124bc418df445751976fe3fcf1b (patch)
tree3925bf08ec093ec90a6ba4ccd44e76e73241c9f5
parent7c8266c1396055bcc964d57dc962ad198099707a (diff)
downloadefl-afb4d42171f6e124bc418df445751976fe3fcf1b.tar.gz
efl_animation: Implement scale animation
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.c95
1 files changed, 94 insertions, 1 deletions
diff --git a/src/lib/evas/canvas/efl_animation_scale.c b/src/lib/evas/canvas/efl_animation_scale.c
index 36c2747d2b..97c2861b0a 100644
--- a/src/lib/evas/canvas/efl_animation_scale.c
+++ b/src/lib/evas/canvas/efl_animation_scale.c
@@ -30,6 +30,8 @@ struct _Evas_Object_Animation_Scale_Data
{
Evas_Object_Animation_Scale_Property from;
Evas_Object_Animation_Scale_Property to;
+
+ Evas_Map *map;
};
EOLIAN static void
@@ -153,10 +155,95 @@ _efl_animation_scale_efl_animation_dup(Eo *eo_obj, Evas_Object_Animation_Scale_D
return animation;
}
+static Evas_Map *
+_map_dup(Eo *target)
+{
+ if (!target) return NULL;
+
+ Evas_Map *map = NULL;
+
+ if (evas_object_map_enable_get(target) && evas_object_map_get(target))
+ {
+ map = evas_map_dup(evas_object_map_get(target));
+ if (!map) return NULL;
+ }
+ else
+ {
+ map = evas_map_new(4);
+ if (!map) return NULL;
+ evas_map_util_points_populate_from_object_full(map, target, 0);
+ }
+
+ return map;
+}
+
+static void
+_map_init(Evas_Map *map)
+{
+ evas_map_util_object_move_sync_set(map, EINA_TRUE);
+
+ //FIXME: Need to consider smooth of map
+}
+
static void
-_pre_animate_cb(void *data, const Efl_Event *event)
+_pre_start_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
+ EFL_ANIMATION_SCALE_DATA_GET(event->object, pd);
+
+ Eo *target = efl_animation_target_get(event->object);
+ if (!target) return;
+
+ pd->map = _map_dup(target);
+ if (!pd->map) return;
+
+ _map_init(pd->map);
+}
+
+static void
+_pre_animate_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+ EFL_ANIMATION_SCALE_DATA_GET(event->object, pd);
Efl_Animation_Animate_Event_Info *event_info = event->info;
+
+ double progress = event_info->progress;
+
+ Eo *target = efl_animation_target_get(event->object);
+ if (!target) return;
+
+ double scale_x =
+ (pd->from.scale_x * (1.0 - progress)) + (pd->to.scale_x * progress);
+
+ double scale_y =
+ (pd->from.scale_y * (1.0 - progress)) + (pd->to.scale_y * progress);
+
+ if (!pd->map)
+ {
+ pd->map = _map_dup(target);
+ if (!pd->map) return;
+
+ _map_init(pd->map);
+ }
+
+ Evas_Map *map = evas_map_dup(pd->map);
+
+ Evas_Coord x, y, w, h;
+ evas_object_geometry_get(target, &x, &y, &w, &h);
+
+ evas_map_util_zoom(map, scale_x, scale_y, x + (w / 2), y + (h / 2));
+
+ evas_object_map_set(target, map);
+ evas_object_map_enable_set(target, EINA_TRUE);
+
+ evas_map_free(map);
+}
+
+static void
+_pre_end_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+ EFL_ANIMATION_SCALE_DATA_GET(event->object, pd);
+
+ evas_map_free(pd->map);
+ pd->map = NULL;
}
EOLIAN static Efl_Object *
@@ -168,9 +255,15 @@ _efl_animation_scale_efl_object_constructor(Eo *eo_obj, Evas_Object_Animation_Sc
pd->from.scale_y = 1.0;
pd->from.scale_z = 1.0;
+ //pre start event is supported within class only (protected event)
+ efl_event_callback_add(eo_obj, EFL_ANIMATION_EVENT_PRE_START, _pre_start_cb, NULL);
+
//pre animate event is supported within class only (protected event)
efl_event_callback_add(eo_obj, EFL_ANIMATION_EVENT_PRE_ANIMATE, _pre_animate_cb, NULL);
+ //pre end event is supported within class only (protected event)
+ efl_event_callback_add(eo_obj, EFL_ANIMATION_EVENT_PRE_END, _pre_end_cb, NULL);
+
return eo_obj;
}