jaehyun pushed a commit to branch master.

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

commit f01c96e54292979b6c7d43f212413d2998b3dc4a
Author: Jaehyun Cho <jae_hyun....@samsung.com>
Date:   Fri Aug 25 13:37:12 2017 +0900

    efl_animation: Add translate animation
---
 src/Makefile_Evas.am                               |   3 +
 src/lib/evas/Evas_Common.h                         |   7 +
 src/lib/evas/Evas_Eo.h                             |   1 +
 src/lib/evas/canvas/efl_animation_translate.c      | 166 +++++++++++++++++++++
 src/lib/evas/canvas/efl_animation_translate.eo     |  36 +++++
 .../evas/canvas/efl_animation_translate_private.h  |  35 +++++
 6 files changed, 248 insertions(+)

diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 9af8fd173f..49843acd2f 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -48,6 +48,7 @@ evas_eolian_pub_files = \
        lib/evas/canvas/efl_animation_alpha.eo \
        lib/evas/canvas/efl_animation_rotate.eo \
        lib/evas/canvas/efl_animation_scale.eo \
+       lib/evas/canvas/efl_animation_translate.eo \
        lib/evas/canvas/efl_animation_object.eo \
        lib/evas/canvas/efl_animation_object_alpha.eo \
        lib/evas/canvas/efl_animation_object_rotate.eo \
@@ -134,6 +135,7 @@ lib/evas/canvas/efl_animation_private.h \
 lib/evas/canvas/efl_animation_alpha_private.h \
 lib/evas/canvas/efl_animation_rotate_private.h \
 lib/evas/canvas/efl_animation_scale_private.h \
+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 \
@@ -227,6 +229,7 @@ lib/evas/canvas/efl_animation.c \
 lib/evas/canvas/efl_animation_alpha.c \
 lib/evas/canvas/efl_animation_rotate.c \
 lib/evas/canvas/efl_animation_scale.c \
+lib/evas/canvas/efl_animation_translate.c \
 lib/evas/canvas/efl_animation_object.c \
 lib/evas/canvas/efl_animation_object_alpha.c \
 lib/evas/canvas/efl_animation_object_rotate.c \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index ddf731727b..1edc82aa77 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3358,6 +3358,13 @@ typedef Eo Efl_Animation_Scale;
 
 #endif
 
+#ifndef _EFL_ANIMATION_TRANSLATE_EO_CLASS_TYPE
+#define _EFL_ANIMATION_TRANSLATE_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Translate;
+
+#endif
+
 #ifndef _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
 #define _EFL_ANIMATION_OBJECT_EO_CLASS_TYPE
 
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index a923f3aace..51b1305a42 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -59,6 +59,7 @@
 #include "canvas/efl_animation_alpha.eo.h"
 #include "canvas/efl_animation_rotate.eo.h"
 #include "canvas/efl_animation_scale.eo.h"
+#include "canvas/efl_animation_translate.eo.h"
 #include "canvas/efl_animation_object.eo.h"
 #include "canvas/efl_animation_object_alpha.eo.h"
 #include "canvas/efl_animation_object_rotate.eo.h"
diff --git a/src/lib/evas/canvas/efl_animation_translate.c 
b/src/lib/evas/canvas/efl_animation_translate.c
new file mode 100644
index 0000000000..8ae7cec3f5
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_translate.c
@@ -0,0 +1,166 @@
+#include "efl_animation_translate_private.h"
+
+EOLIAN static void
+_efl_animation_translate_translate_set(Eo *eo_obj,
+                                       Efl_Animation_Translate_Data *pd,
+                                       Evas_Coord from_x,
+                                       Evas_Coord from_y,
+                                       Evas_Coord to_x,
+                                       Evas_Coord to_y)
+{
+   EFL_ANIMATION_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_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_translate_translate_get(Eo *eo_obj,
+                                       Efl_Animation_Translate_Data *pd,
+                                       Evas_Coord *from_x,
+                                       Evas_Coord *from_y,
+                                       Evas_Coord *to_x,
+                                       Evas_Coord *to_y)
+{
+   EFL_ANIMATION_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_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_translate_translate_absolute_set(Eo *eo_obj,
+                                                Efl_Animation_Translate_Data 
*pd,
+                                                Evas_Coord from_x,
+                                                Evas_Coord from_y,
+                                                Evas_Coord to_x,
+                                                Evas_Coord to_y)
+{
+   EFL_ANIMATION_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_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_translate_translate_absolute_get(Eo *eo_obj,
+                                                Efl_Animation_Translate_Data 
*pd,
+                                                Evas_Coord *from_x,
+                                                Evas_Coord *from_y,
+                                                Evas_Coord *to_x,
+                                                Evas_Coord *to_y)
+{
+   EFL_ANIMATION_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_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;
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_translate_efl_object_constructor(Eo *eo_obj,
+                                                Efl_Animation_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->use_rel_move = EINA_TRUE;
+
+   return eo_obj;
+}
+
+#include "efl_animation_translate.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_translate.eo 
b/src/lib/evas/canvas/efl_animation_translate.eo
new file mode 100644
index 0000000000..b9d6ed3dc7
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_translate.eo
@@ -0,0 +1,36 @@
+import efl_animation_types;
+
+class Efl.Animation.Translate (Efl.Animation)
+{
+   [[Efl translate animation class]]
+   data: Efl_Animation_Translate_Data;
+   methods {
+      @property translate {
+         set {
+         }
+         get {
+         }
+         values {
+            from_x: int; [[Distance moved along x axis when animation starts]]
+            from_y: int; [[Distance moved along y axis when animation starts]]
+            to_x: int; [[Distance moved along x axis when animation ends]]
+            to_y: int; [[Distance moved along y axis when animation ends]]
+         }
+      }
+      @property translate_absolute {
+         set {
+         }
+         get {
+         }
+         values {
+            from_x: int; [[X coordinate when animation starts]]
+            from_y: int; [[Y coordinate when animation starts]]
+            to_x: int; [[X coordinate when animation ends]]
+            to_y: int; [[Y coordinate when animation ends]]
+         }
+      }
+   }
+   implements {
+      Efl.Object.constructor;
+   }
+}
diff --git a/src/lib/evas/canvas/efl_animation_translate_private.h 
b/src/lib/evas/canvas/efl_animation_translate_private.h
new file mode 100644
index 0000000000..7428012e98
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_translate_private.h
@@ -0,0 +1,35 @@
+#define EFL_ANIMATION_PROTECTED
+
+#include "evas_common_private.h"
+
+#define MY_CLASS EFL_ANIMATION_TRANSLATE_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_TRANSLATE_CHECK_OR_RETURN(anim, ...) \
+   do { \
+      if (!anim) { \
+         CRI("Efl_Animation " # anim " is NULL!"); \
+         return __VA_ARGS__; \
+      } \
+      if (efl_animation_is_deleted(anim)) { \
+         ERR("Efl_Animation " # anim " has already been deleted!"); \
+         return __VA_ARGS__; \
+      } \
+   } while (0)
+
+#define EFL_ANIMATION_TRANSLATE_DATA_GET(o, pd) \
+   Efl_Animation_Translate_Data *pd = efl_data_scope_get(o, 
EFL_ANIMATION_TRANSLATE_CLASS)
+
+typedef struct _Efl_Animation_Translate_Property
+{
+   Evas_Coord move_x, move_y;
+   Evas_Coord x, y;
+} Efl_Animation_Translate_Property;
+
+typedef struct _Efl_Animation_Translate_Data
+{
+   Efl_Animation_Translate_Property from;
+   Efl_Animation_Translate_Property to;
+
+   Eina_Bool use_rel_move;
+} Efl_Animation_Translate_Data;

-- 


Reply via email to