summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-07-03 19:52:02 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-18 12:06:01 +0900
commite597954263fd0ebc956c84d33c937c10e7637c9a (patch)
tree93c2d5116a8bc8348f8a870d70e792413b81e8d6
parent214d22e66b87891c5a40cd512ff10346efca701b (diff)
downloadefl-e597954263fd0ebc956c84d33c937c10e7637c9a.tar.gz
efl_animation: Add rotate 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_rotate.c251
-rw-r--r--src/lib/evas/canvas/efl_animation_rotate.eo39
-rw-r--r--src/lib/evas/include/evas_private.h1
6 files changed, 301 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 07bbca9eec..053eac4cb8 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -52,6 +52,7 @@ evas_eolian_pub_files = \
lib/evas/canvas/efl_gfx_map.eo \
lib/evas/canvas/efl_animation.eo \
lib/evas/canvas/efl_animation_alpha.eo \
+ lib/evas/canvas/efl_animation_rotate.eo \
lib/evas/canvas/efl_animation_instance.eo \
lib/evas/canvas/efl_animation_instance_alpha.eo \
$(NULL)
@@ -220,6 +221,7 @@ lib/evas/canvas/efl_input_hold.c \
lib/evas/canvas/efl_input_focus.c \
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_instance.c \
lib/evas/canvas/efl_animation_instance_alpha.c \
$(NULL)
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index 12775d01e9..843a95dd29 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3335,6 +3335,13 @@ typedef Eo Efl_Animation_Alpha;
#endif
+#ifndef _EFL_ANIMATION_ROTATE_EO_CLASS_TYPE
+#define _EFL_ANIMATION_ROTATE_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Rotate;
+
+#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 87e957eb18..a9eedc0513 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -68,6 +68,7 @@
#include "canvas/efl_animation.eo.h"
#include "canvas/efl_animation_alpha.eo.h"
+#include "canvas/efl_animation_rotate.eo.h"
#include "canvas/efl_animation_instance.eo.h"
#include "canvas/efl_animation_instance_alpha.eo.h"
#endif /* EFL_EO_API_SUPPORT */
diff --git a/src/lib/evas/canvas/efl_animation_rotate.c b/src/lib/evas/canvas/efl_animation_rotate.c
new file mode 100644
index 0000000000..0462b49f0c
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_rotate.c
@@ -0,0 +1,251 @@
+#include "evas_common_private.h"
+#include "evas_private.h"
+
+#define MY_CLASS EFL_ANIMATION_ROTATE_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_ROTATE_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_ROTATE_DATA_GET(o, pd) \
+ Evas_Object_Animation_Rotate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_ROTATE_CLASS)
+
+typedef struct _Evas_Object_Animation_Rotate_Property
+{
+ double degree;
+} Evas_Object_Animation_Rotate_Property;
+
+typedef struct _Evas_Object_Animation_Rotate_Absolute_Pivot
+{
+ Evas_Coord cx, cy;
+} Evas_Object_Animation_Rotate_Absolute_Pivot;
+
+typedef struct _Evas_Object_Animation_Rotate_Relative_Pivot
+{
+ Efl_Canvas_Object *obj;
+ double cx, cy;
+} Evas_Object_Animation_Rotate_Relative_Pivot;
+
+struct _Evas_Object_Animation_Rotate_Data
+{
+ Evas_Object_Animation_Rotate_Property from;
+ Evas_Object_Animation_Rotate_Property to;
+
+ Evas_Object_Animation_Rotate_Absolute_Pivot abs_pivot;
+ Evas_Object_Animation_Rotate_Relative_Pivot rel_pivot;
+
+ Eina_Bool use_rel_pivot;
+};
+
+EOLIAN static void
+_efl_animation_rotate_rotate_set(Eo *eo_obj,
+ Evas_Object_Animation_Rotate_Data *pd,
+ double from_degree,
+ double to_degree,
+ Efl_Canvas_Object *pivot,
+ double cx,
+ double cy)
+{
+ EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+ pd->from.degree = from_degree;
+ pd->to.degree = to_degree;
+
+ pd->rel_pivot.obj = pivot;
+ pd->rel_pivot.cx = cx;
+ pd->rel_pivot.cy = cy;
+
+ //Update absolute pivot based on relative pivot
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ if (pivot)
+ evas_object_geometry_get(pivot, &x, &y, &w, &h);
+ else
+ {
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ if (target)
+ evas_object_geometry_get(target, &x, &y, &w, &h);
+ }
+
+ pd->abs_pivot.cx = x + (w * cx);
+ pd->abs_pivot.cy = y + (h * cy);
+
+ pd->use_rel_pivot = EINA_TRUE;
+}
+
+EOLIAN static void
+_efl_animation_rotate_rotate_get(Eo *eo_obj,
+ Evas_Object_Animation_Rotate_Data *pd,
+ double *from_degree,
+ double *to_degree,
+ Efl_Canvas_Object **pivot,
+ double *cx,
+ double *cy)
+{
+ EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+ //Update relative pivot based on absolute pivot
+ if (!pd->use_rel_pivot)
+ {
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ if (target)
+ evas_object_geometry_get(target, &x, &y, &w, &h);
+
+ if (w != 0)
+ pd->rel_pivot.cx = (double)(pd->abs_pivot.cx - x) / w;
+ else
+ pd->rel_pivot.cx = 0.0;
+
+ if (h != 0)
+ pd->rel_pivot.cy = (double)(pd->abs_pivot.cy - y) / h;
+ else
+ pd->rel_pivot.cy = 0.0;
+ }
+
+ if (from_degree)
+ *from_degree = pd->from.degree;
+
+ if (to_degree)
+ *to_degree = pd->to.degree;
+
+ if (pivot)
+ *pivot = pd->rel_pivot.obj;
+
+ if (cx)
+ *cx = pd->rel_pivot.cx;
+
+ if (cy)
+ *cy = pd->rel_pivot.cy;
+}
+
+EOLIAN static void
+_efl_animation_rotate_rotate_absolute_set(Eo *eo_obj,
+ Evas_Object_Animation_Rotate_Data *pd,
+ double from_degree,
+ double to_degree,
+ Evas_Coord cx,
+ Evas_Coord cy)
+{
+ EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+ pd->from.degree = from_degree;
+ pd->to.degree = to_degree;
+
+ pd->abs_pivot.cx = cx;
+ pd->abs_pivot.cy = cy;
+
+ //Update relative pivot based on absolute pivot
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ if (target)
+ evas_object_geometry_get(target, &x, &y, &w, &h);
+
+ pd->rel_pivot.obj = NULL;
+
+ if (w != 0)
+ pd->rel_pivot.cx = (double)(cx - x) / w;
+ else
+ pd->rel_pivot.cx = 0.0;
+
+ if (h != 0)
+ pd->rel_pivot.cy = (double)(cy - y) / h;
+ else
+ pd->rel_pivot.cy = 0.0;
+
+ pd->use_rel_pivot = EINA_FALSE;
+}
+
+EOLIAN static void
+_efl_animation_rotate_rotate_absolute_get(Eo *eo_obj,
+ Evas_Object_Animation_Rotate_Data *pd,
+ double *from_degree,
+ double *to_degree,
+ Evas_Coord *cx,
+ Evas_Coord *cy)
+{
+ EFL_ANIMATION_ROTATE_CHECK_OR_RETURN(eo_obj);
+
+ //Update relative pivot based on absolute pivot
+ if (pd->use_rel_pivot)
+ {
+ Evas_Coord x = 0;
+ Evas_Coord y = 0;
+ Evas_Coord w = 0;
+ Evas_Coord h = 0;
+
+ if (pd->rel_pivot.obj)
+ evas_object_geometry_get(pd->rel_pivot.obj, &x, &y, &w, &h);
+ else
+ {
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ if (target)
+ evas_object_geometry_get(target, &x, &y, &w, &h);
+ }
+
+ pd->abs_pivot.cx = x + (w * pd->rel_pivot.cx);
+ pd->abs_pivot.cy = y + (h * pd->rel_pivot.cy);
+ }
+
+ if (from_degree)
+ *from_degree = pd->from.degree;
+
+ if (to_degree)
+ *to_degree = pd->to.degree;
+
+ if (cx)
+ *cx = pd->abs_pivot.cx;
+
+ if (cy)
+ *cy = pd->abs_pivot.cy;
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_rotate_efl_object_constructor(Eo *eo_obj,
+ Evas_Object_Animation_Rotate_Data *pd)
+{
+ eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
+
+ pd->from.degree = 0.0;
+ pd->to.degree = 0.0;
+
+ pd->rel_pivot.obj = NULL;
+ pd->rel_pivot.cx = 0.5;
+ pd->rel_pivot.cy = 0.5;
+
+ pd->abs_pivot.cx = 0;
+ pd->abs_pivot.cy = 0;
+
+ pd->use_rel_pivot = EINA_TRUE;
+
+ return eo_obj;
+}
+
+EOLIAN static void
+_efl_animation_rotate_efl_object_destructor(Eo *eo_obj,
+ Evas_Object_Animation_Rotate_Data *pd EINA_UNUSED)
+{
+ efl_destructor(efl_super(eo_obj, MY_CLASS));
+}
+
+#include "efl_animation_rotate.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_rotate.eo b/src/lib/evas/canvas/efl_animation_rotate.eo
new file mode 100644
index 0000000000..4f1429265a
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_rotate.eo
@@ -0,0 +1,39 @@
+import efl_animation_types;
+
+class Efl.Animation.Rotate (Efl.Animation)
+{
+ [[Efl rotate animation class]]
+ legacy_prefix: evas_object_animation;
+ data: Evas_Object_Animation_Rotate_Data;
+ methods {
+ @property rotate {
+ set {
+ }
+ get {
+ }
+ values {
+ from_degree: double; [[Rotation degree when animation starts]]
+ to_degree: double; [[Rotation degree when animation ends]]
+ pivot: Efl.Canvas.Object; [[Pivot object for the center point. If the pivot object is NULL, then the object is rotated on itself.]]
+ cx: double; [[X relative coordinate of the center point. The left end is 0.0 and the right end is 1.0 (the center is 0.5).]]
+ cy: double; [[Y relative coordinate of the center point. The top end is 0.0 and the bottom end is 1.0 (the center is 0.5).]]
+ }
+ }
+ @property rotate_absolute {
+ set {
+ }
+ get {
+ }
+ values {
+ from_degree: double; [[Rotation degree when animation starts]]
+ to_degree: double; [[Rotation degree when animation ends]]
+ cx: int; [[X absolute coordinate of the center point.]]
+ cy: int; [[Y absolute coordinate of the center point.]]
+ }
+ }
+ }
+ 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 e5f1ce5e2c..ca83e6b23e 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -109,6 +109,7 @@ typedef struct _Evas_Filter_Command Evas_Filter_Command;
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_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_Data Evas_Object_Animation_Instance_Data;