efl_animation: Add translate animation object
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Fri, 25 Aug 2017 07:55:48 +0000 (16:55 +0900)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Thu, 12 Oct 2017 12:03:49 +0000 (21:03 +0900)
13 files changed:
src/Makefile_Elementary.am
src/Makefile_Evas.am
src/bin/elementary/Makefile.am
src/bin/elementary/test.c
src/bin/elementary/test_efl_anim_translate.c [new file with mode: 0644]
src/lib/evas/Evas_Common.h
src/lib/evas/Evas_Eo.h
src/lib/evas/Evas_Internal.h
src/lib/evas/canvas/efl_animation_object_translate.c [new file with mode: 0644]
src/lib/evas/canvas/efl_animation_object_translate.eo [new file with mode: 0644]
src/lib/evas/canvas/efl_animation_object_translate_private.h [new file with mode: 0644]
src/lib/evas/canvas/efl_animation_translate.c
src/lib/evas/canvas/efl_animation_translate.eo

index 8a6ced7..5a2d88c 100644 (file)
@@ -800,6 +800,7 @@ bin/elementary/test_dnd.c \
 bin/elementary/test_efl_anim_alpha.c \
 bin/elementary/test_efl_anim_rotate.c \
 bin/elementary/test_efl_anim_scale.c \
+bin/elementary/test_efl_anim_translate.c \
 bin/elementary/test_eio.c \
 bin/elementary/test_entry.c \
 bin/elementary/test_entry_anchor.c \
index 49843ac..ac64a88 100644 (file)
@@ -53,6 +53,7 @@ evas_eolian_pub_files = \
        lib/evas/canvas/efl_animation_object_alpha.eo \
        lib/evas/canvas/efl_animation_object_rotate.eo \
        lib/evas/canvas/efl_animation_object_scale.eo \
+       lib/evas/canvas/efl_animation_object_translate.eo \
        $(NULL)
 
 evas_eolian_legacy_files = \
@@ -139,7 +140,8 @@ lib/evas/canvas/efl_animation_translate_private.h \
 lib/evas/canvas/efl_animation_object_private.h \
 lib/evas/canvas/efl_animation_object_alpha_private.h \
 lib/evas/canvas/efl_animation_object_rotate_private.h \
-lib/evas/canvas/efl_animation_object_scale_private.h
+lib/evas/canvas/efl_animation_object_scale_private.h \
+lib/evas/canvas/efl_animation_object_translate_private.h
 
 # Linebreak
 
@@ -234,6 +236,7 @@ lib/evas/canvas/efl_animation_object.c \
 lib/evas/canvas/efl_animation_object_alpha.c \
 lib/evas/canvas/efl_animation_object_rotate.c \
 lib/evas/canvas/efl_animation_object_scale.c \
+lib/evas/canvas/efl_animation_object_translate.c \
 $(NULL)
 
 EXTRA_DIST2 += \
index 88c8ebe..7964b41 100644 (file)
@@ -35,6 +35,7 @@ test_anim.c \
 test_efl_anim_alpha.c \
 test_efl_anim_rotate.c \
 test_efl_anim_scale.c \
+test_efl_anim_translate.c \
 test_application_server.c \
 test_bg.c \
 test_box.c \
index b070384..7683ef3 100644 (file)
@@ -329,6 +329,8 @@ void test_efl_anim_rotate_absolute(void *data, Evas_Object *obj, void *event_inf
 void test_efl_anim_scale(void *data, Evas_Object *obj, void *event_info);
 void test_efl_anim_scale_relative(void *data, Evas_Object *obj, void *event_info);
 void test_efl_anim_scale_absolute(void *data, Evas_Object *obj, void *event_info);
+void test_efl_anim_translate(void *data, Evas_Object *obj, void *event_info);
+void test_efl_anim_translate_absolute(void *data, Evas_Object *obj, void *event_info);
 
 Evas_Object *win, *tbx; // TODO: refactoring
 void *tt;
@@ -805,6 +807,8 @@ add_tests:
    ADD_TEST(NULL, "Effects", "Efl Animation Scale", test_efl_anim_scale);
    ADD_TEST(NULL, "Effects", "Efl Animation Scale Relative", test_efl_anim_scale_relative);
    ADD_TEST(NULL, "Effects", "Efl Animation Scale Absolute", test_efl_anim_scale_absolute);
+   ADD_TEST(NULL, "Effects", "Efl Animation Translate", test_efl_anim_translate);
+   ADD_TEST(NULL, "Effects", "Efl Animation Translate Absolute", test_efl_anim_translate_absolute);
 
    //------------------------------//
    ADD_TEST(NULL, "Edje External", "ExtButton", test_external_button);
diff --git a/src/bin/elementary/test_efl_anim_translate.c b/src/bin/elementary/test_efl_anim_translate.c
new file mode 100644 (file)
index 0000000..d76e927
--- /dev/null
@@ -0,0 +1,192 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+#include <Elementary.h>
+
+typedef struct _App_Data
+{
+   Efl_Animation        *translate_rb_anim;
+   Efl_Animation        *translate_lt_anim;
+   Efl_Animation_Object *anim_obj;
+
+   Eina_Bool             is_btn_translated;
+} App_Data;
+
+static void
+_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
+{
+   printf("Animation has been started!\n");
+}
+
+static void
+_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
+{
+   App_Data *ad = data;
+
+   printf("Animation has been ended!\n");
+
+   ad->anim_obj = NULL;
+}
+
+static void
+_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+   Efl_Animation_Object_Running_Event_Info *event_info = event->info;
+   double progress = event_info->progress;
+   printf("Animation is running! Current progress(%lf)\n", progress);
+}
+
+static void
+_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = data;
+
+   if (ad->anim_obj)
+     efl_animation_object_cancel(ad->anim_obj);
+
+   ad->is_btn_translated = !(ad->is_btn_translated);
+
+   if (ad->is_btn_translated)
+     {
+        //Create Animation Object from Animation
+        ad->anim_obj = efl_animation_object_create(ad->translate_rb_anim);
+        elm_object_text_set(obj, "Start Translate Animation to left top");
+     }
+   else
+     {
+        //Create Animation Object from Animation
+        ad->anim_obj = efl_animation_object_create(ad->translate_lt_anim);
+        elm_object_text_set(obj, "Start Translate Animation to right bottom");
+     }
+
+   //Register callback called when animation starts
+   efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_STARTED, _anim_started_cb, NULL);
+
+   //Register callback called when animation ends
+   efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_ENDED, _anim_ended_cb, ad);
+
+   //Register callback called while animation is executed
+   efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_RUNNING, _anim_running_cb, NULL);
+
+   //Let Animation Object start animation
+   efl_animation_object_start(ad->anim_obj);
+}
+
+static void
+_win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = data;
+   free(ad);
+}
+
+void
+test_efl_anim_translate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = calloc(1, sizeof(App_Data));
+   if (!ad) return;
+
+   Evas_Object *win = elm_win_add(NULL, "Efl Animation Translate", ELM_WIN_BASIC);
+   elm_win_title_set(win, "Efl Animation Translate");
+   elm_win_autodel_set(win, EINA_TRUE);
+   evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
+
+   //Button to be animated
+   Evas_Object *btn = elm_button_add(win);
+   elm_object_text_set(btn, "Target");
+   evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn, 150, 150);
+   evas_object_move(btn, 125, 100);
+   evas_object_show(btn);
+
+   //Translate Animation to right bottom relatively
+   Efl_Animation *translate_rb_anim = efl_add(EFL_ANIMATION_TRANSLATE_CLASS, NULL);
+   efl_animation_translate_set(translate_rb_anim, 0, 0, 100, 100);
+   efl_animation_duration_set(translate_rb_anim, 1.0);
+   efl_animation_target_set(translate_rb_anim, btn);
+   efl_animation_final_state_keep_set(translate_rb_anim, EINA_TRUE);
+
+   //Translate Animation to left top relatively
+   Efl_Animation *translate_lt_anim = efl_add(EFL_ANIMATION_TRANSLATE_CLASS, NULL);
+   efl_animation_translate_set(translate_lt_anim, 100, 100, 0, 0);
+   efl_animation_duration_set(translate_lt_anim, 1.0);
+   efl_animation_target_set(translate_lt_anim, btn);
+   efl_animation_final_state_keep_set(translate_lt_anim, EINA_TRUE);
+
+   //Initialize App Data
+   ad->translate_rb_anim = translate_rb_anim;
+   ad->translate_lt_anim = translate_lt_anim;
+   ad->anim_obj = NULL;
+   ad->is_btn_translated = EINA_FALSE;
+
+   //Button to start animation
+   Evas_Object *btn2 = elm_button_add(win);
+   elm_object_text_set(btn2, "Start Translate Animation to right bottom");
+   evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
+   evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn2, 300, 50);
+   evas_object_move(btn2, 50, 300);
+   evas_object_show(btn2);
+
+   evas_object_resize(win, 400, 400);
+   evas_object_show(win);
+}
+
+void
+test_efl_anim_translate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   App_Data *ad = calloc(1, sizeof(App_Data));
+   if (!ad) return;
+
+   Evas_Object *win = elm_win_add(NULL, "Efl Animation Absolute Translate", ELM_WIN_BASIC);
+   elm_win_title_set(win, "Efl Animation Absolute Translate");
+   elm_win_autodel_set(win, EINA_TRUE);
+   evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
+
+   //Button to be animated
+   Evas_Object *btn = elm_button_add(win);
+   elm_object_text_set(btn, "Target");
+   evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn, 150, 150);
+   evas_object_move(btn, 125, 100);
+   evas_object_show(btn);
+
+   //Absolute coordinate (0, 0) for absolute translation
+   Evas_Object *abs_center = elm_button_add(win);
+   elm_object_text_set(abs_center, "(0, 0)");
+   evas_object_size_hint_weight_set(abs_center, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(abs_center, 50, 50);
+   evas_object_move(abs_center, 0, 0);
+   evas_object_show(abs_center);
+
+   //Translate Animation to right bottom absolutely
+   Efl_Animation *translate_rb_anim = efl_add(EFL_ANIMATION_TRANSLATE_CLASS, NULL);
+   efl_animation_translate_absolute_set(translate_rb_anim, 0, 0, 100, 100);
+   efl_animation_duration_set(translate_rb_anim, 1.0);
+   efl_animation_target_set(translate_rb_anim, btn);
+   efl_animation_final_state_keep_set(translate_rb_anim, EINA_TRUE);
+
+   //Translate Animation to left top absolutely
+   Efl_Animation *translate_lt_anim = efl_add(EFL_ANIMATION_TRANSLATE_CLASS, NULL);
+   efl_animation_translate_absolute_set(translate_lt_anim, 100, 100, 0, 0);
+   efl_animation_duration_set(translate_lt_anim, 1.0);
+   efl_animation_target_set(translate_lt_anim, btn);
+   efl_animation_final_state_keep_set(translate_lt_anim, EINA_TRUE);
+
+   //Initialize App Data
+   ad->translate_rb_anim = translate_rb_anim;
+   ad->translate_lt_anim = translate_lt_anim;
+   ad->anim_obj = NULL;
+   ad->is_btn_translated = EINA_FALSE;
+
+   //Button to start animation
+   Evas_Object *btn2 = elm_button_add(win);
+   elm_object_text_set(btn2, "Start Translate Animation to right bottom");
+   evas_object_smart_callback_add(btn2, "clicked", _btn_clicked_cb, ad);
+   evas_object_size_hint_weight_set(btn2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_resize(btn2, 300, 50);
+   evas_object_move(btn2, 50, 300);
+   evas_object_show(btn2);
+
+   evas_object_resize(win, 400, 400);
+   evas_object_show(win);
+}
index 1edc82a..5407b78 100644 (file)
@@ -3393,6 +3393,13 @@ typedef Eo Efl_Animation_Object_Scale;
 
 #endif
 
+#ifndef _EFL_ANIMATION_OBJECT_TRANSLATE_EO_CLASS_TYPE
+#define _EFL_ANIMATION_OBJECT_TRANSLATE_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Object_Translate;
+
+#endif
+
 struct _Efl_Animation_Object_Running_Event_Info
 {
    double progress;
index 51b1305..a2efd46 100644 (file)
@@ -64,6 +64,7 @@
 #include "canvas/efl_animation_object_alpha.eo.h"
 #include "canvas/efl_animation_object_rotate.eo.h"
 #include "canvas/efl_animation_object_scale.eo.h"
+#include "canvas/efl_animation_object_translate.eo.h"
 
 #endif /* EFL_EO_API_SUPPORT */
 
index 75e575e..b9b1ce7 100644 (file)
@@ -118,6 +118,14 @@ EOAPI void efl_animation_object_scale_absolute_set(Eo *obj, double from_scale_x,
 EOAPI void efl_animation_object_scale_absolute_get(const Eo *obj, double *from_scale_x, double *from_scale_y, double *to_scale_x, double *to_scale_y, int *cx, int *cy);
 /* Efl.Animation.Object.Scale END */
 
+/* Efl.Animation.Object.Translate */
+EOAPI void efl_animation_object_translate_set(Eo *obj, int from_x, int from_y, int to_x, int to_y);
+EOAPI void efl_animation_object_translate_get(const Eo *obj, int *from_x, int *from_y, int *to_x, int *to_y);
+
+EOAPI void efl_animation_object_translate_absolute_set(Eo *obj, int from_x, int from_y, int to_x, int to_y);
+EOAPI void efl_animation_object_translate_absolute_get(const Eo *obj, int *from_x, int *from_y, int *to_x, int *to_y);
+/* Efl.Animation.Object.Translate END */
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/lib/evas/canvas/efl_animation_object_translate.c b/src/lib/evas/canvas/efl_animation_object_translate.c
new file mode 100644 (file)
index 0000000..b159308
--- /dev/null
@@ -0,0 +1,250 @@
+#include "efl_animation_object_translate_private.h"
+
+EOLIAN static void
+_efl_animation_object_translate_translate_set(Eo *eo_obj,
+                                              Efl_Animation_Object_Translate_Data *pd,
+                                              Evas_Coord from_x,
+                                              Evas_Coord from_y,
+                                              Evas_Coord to_x,
+                                              Evas_Coord to_y)
+{
+   EFL_ANIMATION_OBJECT_TRANSLATE_CHECK_OR_RETURN(eo_obj);
+
+   pd->from.move_x = from_x;
+   pd->from.move_y = from_y;
+
+   pd->to.move_x = to_x;
+   pd->to.move_y = to_y;
+
+   //Update absolute coordinate based on relative move
+   Evas_Coord x = 0;
+   Evas_Coord y = 0;
+
+   Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+   if (target)
+     evas_object_geometry_get(target, &x, &y, NULL, NULL);
+
+   pd->from.x = pd->from.move_x + x;
+   pd->from.y = pd->from.move_y + y;
+
+   pd->to.x = pd->to.move_x + x;
+   pd->to.y = pd->to.move_y + y;
+
+   pd->use_rel_move = EINA_TRUE;
+}
+
+EOLIAN static void
+_efl_animation_object_translate_translate_get(Eo *eo_obj,
+                                              Efl_Animation_Object_Translate_Data *pd,
+                                              Evas_Coord *from_x,
+                                              Evas_Coord *from_y,
+                                              Evas_Coord *to_x,
+                                              Evas_Coord *to_y)
+{
+   EFL_ANIMATION_OBJECT_TRANSLATE_CHECK_OR_RETURN(eo_obj);
+
+   //Update relative move based on absolute coordinate
+   if (!pd->use_rel_move)
+     {
+        Evas_Coord x = 0;
+        Evas_Coord y = 0;
+
+        Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+        if (target)
+          evas_object_geometry_get(target, &x, &y, NULL, NULL);
+
+        pd->from.move_x = pd->from.x - x;
+        pd->from.move_y = pd->from.y - y;
+
+        pd->to.move_x = pd->to.x - x;
+        pd->to.move_y = pd->to.y - y;
+     }
+
+   if (from_x)
+     *from_x = pd->from.move_x;
+   if (from_y)
+     *from_y = pd->from.move_y;
+
+   if (to_x)
+     *to_x = pd->to.move_x;
+   if (to_y)
+     *to_y = pd->to.move_y;
+}
+
+EOLIAN static void
+_efl_animation_object_translate_translate_absolute_set(Eo *eo_obj,
+                                                       Efl_Animation_Object_Translate_Data *pd,
+                                                       Evas_Coord from_x,
+                                                       Evas_Coord from_y,
+                                                       Evas_Coord to_x,
+                                                       Evas_Coord to_y)
+{
+   EFL_ANIMATION_OBJECT_TRANSLATE_CHECK_OR_RETURN(eo_obj);
+
+   pd->from.x = from_x;
+   pd->from.y = from_y;
+
+   pd->to.x = to_x;
+   pd->to.y = to_y;
+
+   //Update relative move based on absolute coordinate
+   Evas_Coord x = 0;
+   Evas_Coord y = 0;
+
+   Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+   if (target)
+     evas_object_geometry_get(target, &x, &y, NULL, NULL);
+
+   pd->from.move_x = pd->from.x - x;
+   pd->from.move_y = pd->from.y - y;
+
+   pd->to.move_x = pd->to.x - x;
+   pd->to.move_y = pd->to.y - y;
+
+   pd->use_rel_move = EINA_FALSE;
+}
+
+EOLIAN static void
+_efl_animation_object_translate_translate_absolute_get(Eo *eo_obj,
+                                                       Efl_Animation_Object_Translate_Data *pd,
+                                                       Evas_Coord *from_x,
+                                                       Evas_Coord *from_y,
+                                                       Evas_Coord *to_x,
+                                                       Evas_Coord *to_y)
+{
+   EFL_ANIMATION_OBJECT_TRANSLATE_CHECK_OR_RETURN(eo_obj);
+
+   //Update absolute coordinate based on relative move
+   if (pd->use_rel_move)
+     {
+        Evas_Coord x = 0;
+        Evas_Coord y = 0;
+
+        Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+        if (target)
+          evas_object_geometry_get(target, &x, &y, NULL, NULL);
+
+        pd->from.x = pd->from.move_x + x;
+        pd->from.y = pd->from.move_y + y;
+
+        pd->to.x = pd->to.move_x + x;
+        pd->to.y = pd->to.move_y + y;
+     }
+
+   if (from_x)
+     *from_x = pd->from.x;
+   if (from_y)
+     *from_y = pd->from.y;
+
+   if (to_x)
+     *to_x = pd->to.x;
+   if (to_y)
+     *to_y = pd->to.y;
+}
+
+static void
+_pre_started_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+   EFL_ANIMATION_OBJECT_TRANSLATE_DATA_GET(event->object, pd);
+
+   pd->start_x = 0;
+   pd->start_y = 0;
+
+   Efl_Canvas_Object *target = efl_animation_object_target_get(event->object);
+   if (!target) return;
+
+   Evas_Coord x, y;
+   evas_object_geometry_get(target, &x, &y, NULL, NULL);
+
+   pd->start_x = x;
+   pd->start_y = y;
+}
+
+static void
+_progress_set(Eo *eo_obj, double progress)
+{
+   EFL_ANIMATION_OBJECT_TRANSLATE_DATA_GET(eo_obj, pd);
+
+   Efl_Canvas_Object *target = efl_animation_object_target_get(eo_obj);
+   if (!target) return;
+
+   Evas_Coord new_x = 0;
+   Evas_Coord new_y = 0;
+
+   if (pd->use_rel_move)
+     {
+        new_x =
+           (pd->from.move_x * (1.0 - progress)) + (pd->to.move_x * progress);
+        new_y =
+           (pd->from.move_y * (1.0 - progress)) + (pd->to.move_y * progress);
+     }
+   else
+     {
+        /* Since efl_gfx_map_translate() moves position relatively, the original
+         * position should be subtracted to move position absolutely. */
+        new_x =
+           (pd->from.x * (1.0 - progress)) + (pd->to.x * progress) - pd->start_x;
+        new_y =
+           (pd->from.y * (1.0 - progress)) + (pd->to.y * progress) - pd->start_y;
+     }
+
+   efl_gfx_map_translate(target, (double) new_x, (double) new_y, 0.0);
+}
+
+EOLIAN static void
+_efl_animation_object_translate_efl_animation_object_progress_set(Eo *eo_obj,
+                                                                  Efl_Animation_Object_Translate_Data *pd EINA_UNUSED,
+                                                                  double progress)
+{
+   EFL_ANIMATION_OBJECT_TRANSLATE_CHECK_OR_RETURN(eo_obj);
+
+   if ((progress < 0.0) || (progress > 1.0)) return;
+
+   _progress_set(eo_obj, progress);
+
+   efl_animation_object_progress_set(efl_super(eo_obj, MY_CLASS), progress);
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_object_translate_efl_object_constructor(Eo *eo_obj,
+                                                       Efl_Animation_Object_Translate_Data *pd)
+{
+   eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
+
+   pd->from.move_x = 0;
+   pd->from.move_y = 0;
+   pd->from.x = 0;
+   pd->from.y = 0;
+
+   pd->to.move_x = 0;
+   pd->to.move_y = 0;
+   pd->to.x = 0;
+   pd->to.y = 0;
+
+   pd->start_x = 0;
+   pd->start_y = 0;
+
+   pd->use_rel_move = EINA_TRUE;
+
+   //pre_started event is supported within class only (protected event)
+   efl_event_callback_add(eo_obj, EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED,
+                          _pre_started_cb, NULL);
+
+   return eo_obj;
+}
+
+/* Internal EO APIs */
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_translate_set, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int from_x, int from_y, int to_x, int to_y);
+EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_object_translate_get, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int *from_x, int *from_y, int *to_x, int *to_y);
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_translate_absolute_set, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int from_x, int from_y, int to_x, int to_y);
+EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_object_translate_absolute_get, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int *from_x, int *from_y, int *to_x, int *to_y);
+
+#define EFL_ANIMATION_OBJECT_TRANSLATE_EXTRA_OPS \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_translate_set, _efl_animation_object_translate_translate_set), \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_translate_get, _efl_animation_object_translate_translate_get), \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_translate_absolute_set, _efl_animation_object_translate_translate_absolute_set), \
+   EFL_OBJECT_OP_FUNC(efl_animation_object_translate_absolute_get, _efl_animation_object_translate_translate_absolute_get)
+
+#include "efl_animation_object_translate.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_object_translate.eo b/src/lib/evas/canvas/efl_animation_object_translate.eo
new file mode 100644 (file)
index 0000000..b3f778b
--- /dev/null
@@ -0,0 +1,11 @@
+import efl_animation_types;
+
+class Efl.Animation.Object.Translate (Efl.Animation.Object)
+{
+   [[Efl translate animation object class]]
+   data: Efl_Animation_Object_Translate_Data;
+   implements {
+      Efl.Object.constructor;
+      Efl.Animation.Object.progress_set;
+   }
+}
diff --git a/src/lib/evas/canvas/efl_animation_object_translate_private.h b/src/lib/evas/canvas/efl_animation_object_translate_private.h
new file mode 100644 (file)
index 0000000..99a57d9
--- /dev/null
@@ -0,0 +1,37 @@
+#define EFL_ANIMATION_OBJECT_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_OBJECT_TRANSLATE_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_OBJECT_TRANSLATE_CHECK_OR_RETURN(anim_obj, ...) \
+   do { \
+      if (!anim_obj) { \
+         CRI("Efl_Animation_Object " # anim_obj " is NULL!"); \
+         return __VA_ARGS__; \
+      } \
+      if (efl_animation_object_is_deleted(anim_obj)) { \
+         ERR("Efl_Animation_Object " # anim_obj " has already been deleted!"); \
+         return __VA_ARGS__; \
+      } \
+   } while (0)
+
+#define EFL_ANIMATION_OBJECT_TRANSLATE_DATA_GET(o, pd) \
+   Efl_Animation_Object_Translate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_OBJECT_TRANSLATE_CLASS)
+
+typedef struct _Efl_Animation_Object_Translate_Property
+{
+   Evas_Coord move_x, move_y;
+   Evas_Coord x, y;
+} Efl_Animation_Object_Translate_Property;
+
+typedef struct _Efl_Animation_Object_Translate_Data
+{
+   Efl_Animation_Object_Translate_Property from;
+   Efl_Animation_Object_Translate_Property to;
+
+   Evas_Coord start_x, start_y;
+
+   Eina_Bool use_rel_move;
+} Efl_Animation_Object_Translate_Data;
index 8ae7cec..a952a04 100644 (file)
@@ -142,6 +142,44 @@ _efl_animation_translate_translate_absolute_get(Eo *eo_obj,
      *to_y = pd->to.y;
 }
 
+EOLIAN static Efl_Animation_Object *
+_efl_animation_translate_efl_animation_object_create(Eo *eo_obj,
+                                                     Efl_Animation_Translate_Data *pd)
+{
+   EFL_ANIMATION_TRANSLATE_CHECK_OR_RETURN(eo_obj, NULL);
+
+   Efl_Animation_Object_Translate *anim_obj
+      = efl_add(EFL_ANIMATION_OBJECT_TRANSLATE_CLASS, NULL);
+
+   Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+   efl_animation_object_target_set(anim_obj, target);
+
+   Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
+   efl_animation_object_final_state_keep_set(anim_obj, state_keep);
+
+   double duration = efl_animation_duration_get(eo_obj);
+   efl_animation_object_duration_set(anim_obj, duration);
+
+   if (pd->use_rel_move)
+     {
+        efl_animation_object_translate_set(anim_obj,
+                                           pd->from.move_x,
+                                           pd->from.move_y,
+                                           pd->to.move_x,
+                                           pd->to.move_y);
+     }
+   else
+     {
+        efl_animation_object_translate_absolute_set(anim_obj,
+                                                    pd->from.x,
+                                                    pd->from.y,
+                                                    pd->to.x,
+                                                    pd->to.y);
+     }
+
+   return anim_obj;
+}
+
 EOLIAN static Efl_Object *
 _efl_animation_translate_efl_object_constructor(Eo *eo_obj,
                                                 Efl_Animation_Translate_Data *pd)
index b9d6ed3..d1265bb 100644 (file)
@@ -32,5 +32,6 @@ class Efl.Animation.Translate (Efl.Animation)
    }
    implements {
       Efl.Object.constructor;
+      Efl.Animation.object_create;
    }
 }