summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-25 11:34:28 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-09-18 20:47:20 +0900
commit831437ecad63a59d31a039c21d449a150a24b32c (patch)
tree0c457df0dd3b171331736e0bf78a631a2dfd0f53
parente96f1418177b8205ee3b80b2ba3c8003659c35b4 (diff)
downloadefl-831437ecad63a59d31a039c21d449a150a24b32c.tar.gz
efl_animation: Add scale animation
-rw-r--r--src/Makefile_Evas.am3
-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.c240
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.eo42
-rw-r--r--src/lib/evas/canvas/efl_animation_scale_private.h48
6 files changed, 341 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 2cdda59bf6..76ffaf1d57 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -47,6 +47,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 \
@@ -131,6 +132,7 @@ lib/evas/common3d/primitives/primitive_common.h \
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_instance_private.h \
lib/evas/canvas/efl_animation_instance_alpha_private.h \
lib/evas/canvas/efl_animation_instance_rotate_private.h
@@ -222,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 7c7661852e..88807897f4 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3344,6 +3344,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 8254bb3c2b..b5c39dc6a9 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -58,6 +58,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..fa624ae83c
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale.c
@@ -0,0 +1,240 @@
+#include "efl_animation_scale_private.h"
+
+EOLIAN static void
+_efl_animation_scale_scale_set(Eo *eo_obj,
+ Efl_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,
+ Efl_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,
+ Efl_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,
+ Efl_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 void
+_efl_animation_scale_efl_animation_duration_set(Eo *eo_obj,
+ Efl_Animation_Scale_Data *pd EINA_UNUSED,
+ double duration)
+{
+ EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj);
+
+ //For a single animation, duration should be equal to or bigger than 0.0.
+ if (duration < 0.0) return;
+
+ //For a single animation, total duration is the same as duration.
+ efl_animation_total_duration_set(eo_obj, duration);
+
+ efl_animation_duration_set(efl_super(eo_obj, MY_CLASS), duration);
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_scale_efl_object_constructor(Eo *eo_obj,
+ Efl_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;
+}
+
+#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..7e3be30b57
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale.eo
@@ -0,0 +1,42 @@
+import efl_animation_types;
+
+class Efl.Animation.Scale (Efl.Animation)
+{
+ [[Efl scale animation class]]
+ data: Efl_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.Animation.duration { set; }
+ }
+}
diff --git a/src/lib/evas/canvas/efl_animation_scale_private.h b/src/lib/evas/canvas/efl_animation_scale_private.h
new file mode 100644
index 0000000000..298097a64c
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_scale_private.h
@@ -0,0 +1,48 @@
+#define EFL_ANIMATION_PROTECTED
+
+#include "evas_common_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) \
+ Efl_Animation_Scale_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_SCALE_CLASS)
+
+typedef struct _Efl_Animation_Scale_Property
+{
+ double scale_x, scale_y;
+} Efl_Animation_Scale_Property;
+
+typedef struct _Efl_Animation_Scale_Absolute_Pivot
+{
+ Evas_Coord cx, cy;
+} Efl_Animation_Scale_Absolute_Pivot;
+
+typedef struct _Efl_Animation_Scale_Relative_Pivot
+{
+ Efl_Canvas_Object *obj;
+ double cx, cy;
+} Efl_Animation_Scale_Relative_Pivot;
+
+typedef struct _Efl_Animation_Scale_Data
+{
+ Efl_Animation_Scale_Property from;
+ Efl_Animation_Scale_Property to;
+
+ Efl_Animation_Scale_Absolute_Pivot abs_pivot;
+ Efl_Animation_Scale_Relative_Pivot rel_pivot;
+
+ Eina_Bool use_rel_pivot;
+} Efl_Animation_Scale_Data;