summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-07-03 22:24:53 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-18 12:06:01 +0900
commite56bd3656f310f63da019820a9d542f3d0bd58ca (patch)
treed376e89f35153197fce74f625d9fdd8e98330f3f
parent36c997b07c695489c75334d865bd185e8335e933 (diff)
downloadefl-e56bd3656f310f63da019820a9d542f3d0bd58ca.tar.gz
efl_animation: Add translate animation
-rw-r--r--src/Makefile_Evas.am2
-rw-r--r--src/lib/evas/Evas_Common.h7
-rw-r--r--src/lib/evas/Evas_Eo.h1
-rw-r--r--src/lib/evas/canvas/efl_animation_translate.c206
-rw-r--r--src/lib/evas/canvas/efl_animation_translate.eo38
-rw-r--r--src/lib/evas/include/evas_private.h1
6 files changed, 255 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 92a0f8e08a..7453745b64 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -54,6 +54,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_instance.eo \
lib/evas/canvas/efl_animation_instance_alpha.eo \
lib/evas/canvas/efl_animation_instance_rotate.eo \
@@ -226,6 +227,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_instance.c \
lib/evas/canvas/efl_animation_instance_alpha.c \
lib/evas/canvas/efl_animation_instance_rotate.c \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index c784d26511..153c40a648 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3349,6 +3349,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_INSTANCE_EO_CLASS_TYPE
#define _EFL_ANIMATION_INSTANCE_EO_CLASS_TYPE
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index d17aa5ae7a..3cee5ed83e 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -70,6 +70,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_instance.eo.h"
#include "canvas/efl_animation_instance_alpha.eo.h"
#include "canvas/efl_animation_instance_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..b093a2cbf8
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_translate.c
@@ -0,0 +1,206 @@
+#include "evas_common_private.h"
+#include "evas_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) \
+ Evas_Object_Animation_Translate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_TRANSLATE_CLASS)
+
+typedef struct _Evas_Object_Animation_Translate_Property
+{
+ Evas_Coord move_x, move_y;
+ Evas_Coord x, y;
+} Evas_Object_Animation_Translate_Property;
+
+struct _Evas_Object_Animation_Translate_Data
+{
+ Evas_Object_Animation_Translate_Property from;
+ Evas_Object_Animation_Translate_Property to;
+
+ Eina_Bool use_rel_move;
+};
+
+EOLIAN static void
+_efl_animation_translate_translate_set(Eo *eo_obj,
+ Evas_Object_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,
+ Evas_Object_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,
+ Evas_Object_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,
+ Evas_Object_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,
+ Evas_Object_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;
+}
+
+EOLIAN static void
+_efl_animation_translate_efl_object_destructor(Eo *eo_obj,
+ Evas_Object_Animation_Translate_Data *pd EINA_UNUSED)
+{
+ efl_destructor(efl_super(eo_obj, MY_CLASS));
+}
+
+#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..32e21614ca
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_translate.eo
@@ -0,0 +1,38 @@
+import efl_animation_types;
+
+class Efl.Animation.Translate (Efl.Animation)
+{
+ [[Efl translate animation class]]
+ legacy_prefix: evas_object_animation;
+ data: Evas_Object_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;
+ Efl.Object.destructor;
+ }
+}
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index bee422e758..c75446c286 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -111,6 +111,7 @@ typedef enum _Evas_Filter_Support Evas_Filter_Support;
typedef struct _Evas_Object_Animation_Alpha_Data Evas_Object_Animation_Alpha_Data;
typedef struct _Evas_Object_Animation_Rotate_Data Evas_Object_Animation_Rotate_Data;
typedef struct _Evas_Object_Animation_Scale_Data Evas_Object_Animation_Scale_Data;
+typedef struct _Evas_Object_Animation_Translate_Data Evas_Object_Animation_Translate_Data;
typedef struct _Evas_Object_Animation_Data Evas_Object_Animation_Data;
typedef struct _Evas_Object_Animation_Instance_Alpha_Data Evas_Object_Animation_Instance_Alpha_Data;
typedef struct _Evas_Object_Animation_Instance_Rotate_Data Evas_Object_Animation_Instance_Rotate_Data;