summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-07-03 22:03:06 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-18 12:06:01 +0900
commit062b7fe453ba371b4e2bd92b1eac11e116cefc23 (patch)
treeb984bf05a9530b18f611f61f13ee5902ade62c2a
parent9594cf4a0d32bc28b9c358aeab2b474d103910cd (diff)
downloadefl-062b7fe453ba371b4e2bd92b1eac11e116cefc23.tar.gz
efl_animation: Add scale 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_scale.c277
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.eo43
-rw-r--r--src/lib/evas/include/evas_private.h1
6 files changed, 331 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 2948371f1b..0fdf7f4f8b 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -53,6 +53,7 @@ evas_eolian_pub_files = \
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_scale.eo \
lib/evas/canvas/efl_animation_instance.eo \
lib/evas/canvas/efl_animation_instance_alpha.eo \
lib/evas/canvas/efl_animation_instance_rotate.eo \
@@ -223,6 +224,7 @@ 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_scale.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 6cd1319382..047c9d5833 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3342,6 +3342,13 @@ typedef Eo Efl_Animation_Rotate;
#endif
+#ifndef _EFL_ANIMATION_SCALE_EO_CLASS_TYPE
+#define _EFL_ANIMATION_SCALE_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Scale;
+
+#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 a4acac63dc..41ec8ab04a 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -69,6 +69,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_scale.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_scale.c b/src/lib/evas/canvas/efl_animation_scale.c
new file mode 100644
index 0000000000..6ffdc981d7
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale.c
@@ -0,0 +1,277 @@
+#include "evas_common_private.h"
+#include "evas_private.h"
+
+#define MY_CLASS EFL_ANIMATION_SCALE_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_SCALE_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_SCALE_DATA_GET(o, pd) \
+ Evas_Object_Animation_Scale_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_SCALE_CLASS)
+
+typedef struct _Evas_Object_Animation_Scale_Property
+{
+ double scale_x, scale_y;
+} Evas_Object_Animation_Scale_Property;
+
+typedef struct _Evas_Object_Animation_Scale_Absolute_Pivot
+{
+ Evas_Coord cx, cy;
+} Evas_Object_Animation_Scale_Absolute_Pivot;
+
+typedef struct _Evas_Object_Animation_Scale_Relative_Pivot
+{
+ Efl_Canvas_Object *obj;
+ double cx, cy;
+} Evas_Object_Animation_Scale_Relative_Pivot;
+
+struct _Evas_Object_Animation_Scale_Data
+{
+ Evas_Object_Animation_Scale_Property from;
+ Evas_Object_Animation_Scale_Property to;
+
+ Evas_Object_Animation_Scale_Absolute_Pivot abs_pivot;
+ Evas_Object_Animation_Scale_Relative_Pivot rel_pivot;
+
+ Eina_Bool use_rel_pivot;
+};
+
+EOLIAN static void
+_efl_animation_scale_scale_set(Eo *eo_obj,
+ Evas_Object_Animation_Scale_Data *pd,
+ double from_scale_x,
+ double from_scale_y,
+ double to_scale_x,
+ double to_scale_y,
+ Efl_Canvas_Object *pivot,
+ double cx,
+ double cy)
+{
+ EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
+
+ pd->from.scale_x = from_scale_x;
+ pd->from.scale_y = from_scale_y;
+
+ pd->to.scale_x = to_scale_x;
+ pd->to.scale_y = to_scale_y;
+
+ 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_scale_scale_get(Eo *eo_obj,
+ Evas_Object_Animation_Scale_Data *pd,
+ double *from_scale_x,
+ double *from_scale_y,
+ double *to_scale_x,
+ double *to_scale_y,
+ Efl_Canvas_Object **pivot,
+ double *cx,
+ double *cy)
+{
+ EFL_ANIMATION_SCALE_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_scale_x)
+ *from_scale_x = pd->from.scale_x;
+
+ if (from_scale_y)
+ *from_scale_y = pd->from.scale_y;
+
+ if (to_scale_x)
+ *to_scale_x = pd->to.scale_x;
+
+ if (to_scale_y)
+ *to_scale_y = pd->to.scale_y;
+
+ 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_scale_scale_absolute_set(Eo *eo_obj,
+ Evas_Object_Animation_Scale_Data *pd,
+ double from_scale_x,
+ double from_scale_y,
+ double to_scale_x,
+ double to_scale_y,
+ Evas_Coord cx,
+ Evas_Coord cy)
+{
+ EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
+
+ pd->from.scale_x = from_scale_x;
+ pd->from.scale_y = from_scale_y;
+
+ pd->to.scale_x = to_scale_x;
+ pd->to.scale_y = to_scale_y;
+
+ 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_scale_scale_absolute_get(Eo *eo_obj,
+ Evas_Object_Animation_Scale_Data *pd,
+ double *from_scale_x,
+ double *from_scale_y,
+ double *to_scale_x,
+ double *to_scale_y,
+ Evas_Coord *cx,
+ Evas_Coord *cy)
+{
+ EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
+
+ //Update absolute pivot based on relative 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_scale_x)
+ *from_scale_x = pd->from.scale_x;
+
+ if (from_scale_y)
+ *from_scale_y = pd->from.scale_y;
+
+ if (to_scale_x)
+ *to_scale_x = pd->to.scale_x;
+
+ if (to_scale_y)
+ *to_scale_y = pd->to.scale_y;
+
+ if (cx)
+ *cx = pd->abs_pivot.cx;
+
+ if (cy)
+ *cy = pd->abs_pivot.cy;
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_scale_efl_object_constructor(Eo *eo_obj,
+ Evas_Object_Animation_Scale_Data *pd)
+{
+ eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
+
+ pd->from.scale_x = 1.0;
+ pd->from.scale_y = 1.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_scale_efl_object_destructor(Eo *eo_obj,
+ Evas_Object_Animation_Scale_Data *pd EINA_UNUSED)
+{
+ efl_destructor(efl_super(eo_obj, MY_CLASS));
+}
+
+#include "efl_animation_scale.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_scale.eo b/src/lib/evas/canvas/efl_animation_scale.eo
new file mode 100644
index 0000000000..346af62c2a
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale.eo
@@ -0,0 +1,43 @@
+import efl_animation_types;
+
+class Efl.Animation.Scale (Efl.Animation)
+{
+ [[Efl scale animation class]]
+ legacy_prefix: evas_object_animation;
+ data: Evas_Object_Animation_Scale_Data;
+ methods {
+ @property scale {
+ set {
+ }
+ get {
+ }
+ values {
+ from_scale_x: double; [[Scale factor along x axis when animation starts]]
+ from_scale_y: double; [[Scale factor along y axis when animation starts]]
+ to_scale_x: double; [[Scale factor along x axis when animation ends]]
+ to_scale_y: double; [[Scale factor along y axis when animation ends]]
+ pivot: Efl.Canvas.Object; [[Pivot object for the center point. If the pivot object is NULL, then the object is scaled 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 scale_absolute {
+ set {
+ }
+ get {
+ }
+ values {
+ from_scale_x: double; [[Scale factor along x axis when animation starts]]
+ from_scale_y: double; [[Scale factor along y axis when animation starts]]
+ to_scale_x: double; [[Scale factor along x axis when animation ends]]
+ to_scale_y: double; [[Scale factor along y axis 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 eb6ca1ccf2..c4a897ea9d 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -110,6 +110,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_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;