summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-07-03 22:17:09 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-08-18 12:06:01 +0900
commit36c997b07c695489c75334d865bd185e8335e933 (patch)
tree5c6aaa355705a4a68af8d57248edc2eb5e16890c
parent062b7fe453ba371b4e2bd92b1eac11e116cefc23 (diff)
downloadefl-36c997b07c695489c75334d865bd185e8335e933.tar.gz
efl_animation: Add scale animation instance
-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/Evas_Internal.h6
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_scale.c342
-rw-r--r--src/lib/evas/canvas/efl_animation_instance_scale.eo12
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.c37
-rw-r--r--src/lib/evas/canvas/efl_animation_scale.eo1
-rw-r--r--src/lib/evas/include/evas_private.h1
9 files changed, 409 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 0fdf7f4f8b..92a0f8e08a 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -57,6 +57,7 @@ evas_eolian_pub_files = \
lib/evas/canvas/efl_animation_instance.eo \
lib/evas/canvas/efl_animation_instance_alpha.eo \
lib/evas/canvas/efl_animation_instance_rotate.eo \
+ lib/evas/canvas/efl_animation_instance_scale.eo \
$(NULL)
evas_eolian_legacy_files = \
@@ -228,6 +229,7 @@ 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 \
+lib/evas/canvas/efl_animation_instance_scale.c \
$(NULL)
EXTRA_DIST2 += \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index 047c9d5833..c784d26511 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3370,6 +3370,13 @@ typedef Eo Efl_Animation_Instance_Rotate;
#endif
+#ifndef _EFL_ANIMATION_INSTANCE_SCALE_EO_CLASS_TYPE
+#define _EFL_ANIMATION_INSTANCE_SCALE_EO_CLASS_TYPE
+
+typedef Eo Efl_Animation_Instance_Scale;
+
+#endif
+
struct _Efl_Animation_Instance_Animate_Event_Info
{
double progress;
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 41ec8ab04a..d17aa5ae7a 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -73,6 +73,7 @@
#include "canvas/efl_animation_instance.eo.h"
#include "canvas/efl_animation_instance_alpha.eo.h"
#include "canvas/efl_animation_instance_rotate.eo.h"
+#include "canvas/efl_animation_instance_scale.eo.h"
#endif /* EFL_EO_API_SUPPORT */
#if defined(EFL_BETA_API_SUPPORT) && defined(EFL_EO_API_SUPPORT)
diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h
index 4c53466009..ff28607a80 100644
--- a/src/lib/evas/Evas_Internal.h
+++ b/src/lib/evas/Evas_Internal.h
@@ -109,6 +109,12 @@ EOAPI void efl_animation_instance_rotate_get(const Eo *obj, double *from_degree,
EOAPI void efl_animation_instance_rotate_absolute_set(Eo *obj, double from_degree, double to_degree, int cx, int cy);
EOAPI void efl_animation_instance_rotate_absolute_get(const Eo *obj, double *from_degree, double *to_degree, int *cx, int *cy);
+EOAPI void efl_animation_instance_scale_set(Eo *obj, double from_scale_x, double from_scale_y, double to_scale_x, double to_scale_y, Efl_Canvas_Object *pivot, double cx, double cy);
+EOAPI void efl_animation_instance_scale_get(const Eo *obj, double *from_scale_x, double *from_scale_y, double *to_scale_x, double *to_scale_y, Efl_Canvas_Object **pivot, double *cx, double *cy);
+
+EOAPI void efl_animation_instance_scale_absolute_set(Eo *obj, double from_scale_x, double from_scale_y, double to_scale_x, double to_scale_y, int cx, int cy);
+EOAPI void efl_animation_instance_scale_absolute_get(const Eo *obj, double *from_scale_x, double *from_scale_y, double *to_scale_x, double *to_scale_y, int *cx, int *cy);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/evas/canvas/efl_animation_instance_scale.c b/src/lib/evas/canvas/efl_animation_instance_scale.c
new file mode 100644
index 0000000000..d250d52fc3
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_scale.c
@@ -0,0 +1,342 @@
+#include "evas_common_private.h"
+#include "evas_private.h"
+
+#define MY_CLASS EFL_ANIMATION_INSTANCE_SCALE_CLASS
+#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
+
+#define EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(anim, ...) \
+ do { \
+ if (!anim) { \
+ CRI("Efl_Animation_Instance " # anim " is NULL!"); \
+ return __VA_ARGS__; \
+ } \
+ if (efl_animation_instance_is_deleted(anim)) { \
+ ERR("Efl_Animation_Instance " # anim " has already been deleted!"); \
+ return __VA_ARGS__; \
+ } \
+ } while (0)
+
+#define EFL_ANIMATION_INSTANCE_SCALE_DATA_GET(o, pd) \
+ Evas_Object_Animation_Instance_Scale_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_INSTANCE_SCALE_CLASS)
+
+typedef struct _Evas_Object_Animation_Instance_Scale_Property
+{
+ double scale_x, scale_y;
+} Evas_Object_Animation_Instance_Scale_Property;
+
+typedef struct _Evas_Object_Animation_Instance_Scale_Absolute_Pivot
+{
+ Evas_Coord cx, cy;
+} Evas_Object_Animation_Instance_Scale_Absolute_Pivot;
+
+typedef struct _Evas_Object_Animation_Instance_Scale_Relative_Pivot
+{
+ Efl_Canvas_Object *obj;
+ double cx, cy;
+} Evas_Object_Animation_Instance_Scale_Relative_Pivot;
+
+struct _Evas_Object_Animation_Instance_Scale_Data
+{
+ Evas_Object_Animation_Instance_Scale_Property from;
+ Evas_Object_Animation_Instance_Scale_Property to;
+
+ Evas_Object_Animation_Instance_Scale_Absolute_Pivot abs_pivot;
+ Evas_Object_Animation_Instance_Scale_Relative_Pivot rel_pivot;
+
+ Eina_Bool use_rel_pivot;
+};
+
+EOLIAN static void
+_efl_animation_instance_scale_scale_set(Eo *eo_obj,
+ Evas_Object_Animation_Instance_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_INSTANCE_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_instance_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_instance_scale_scale_get(Eo *eo_obj,
+ Evas_Object_Animation_Instance_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_INSTANCE_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_instance_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_instance_scale_scale_absolute_set(Eo *eo_obj,
+ Evas_Object_Animation_Instance_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_INSTANCE_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_instance_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_instance_scale_scale_absolute_get(Eo *eo_obj,
+ Evas_Object_Animation_Instance_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_INSTANCE_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_instance_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;
+}
+
+static void
+_progress_set(Eo *eo_obj, double progress)
+{
+ EFL_ANIMATION_INSTANCE_SCALE_DATA_GET(eo_obj, pd);
+
+ Efl_Canvas_Object *target = efl_animation_instance_target_get(eo_obj);
+ if (!target) return;
+
+ double scale_x =
+ (pd->from.scale_x * (1.0 - progress)) + (pd->to.scale_x * progress);
+
+ double scale_y =
+ (pd->from.scale_y * (1.0 - progress)) + (pd->to.scale_y * progress);
+
+ if (pd->use_rel_pivot)
+ {
+ efl_gfx_map_zoom(target,
+ scale_x, scale_y,
+ pd->rel_pivot.obj,
+ pd->rel_pivot.cx, pd->rel_pivot.cy);
+ }
+ else
+ {
+ efl_gfx_map_zoom_absolute(target,
+ scale_x, scale_y,
+ pd->abs_pivot.cx, pd->abs_pivot.cy);
+ }
+}
+
+static void
+_pre_animate_cb(void *data EINA_UNUSED, const Efl_Event *event)
+{
+ Efl_Animation_Instance_Animate_Event_Info *event_info = event->info;
+
+ _progress_set(event->object, event_info->progress);
+}
+
+EOLIAN static Efl_Object *
+_efl_animation_instance_scale_efl_object_constructor(Eo *eo_obj,
+ Evas_Object_Animation_Instance_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;
+
+ //pre animate event is supported within class only (protected event)
+ efl_event_callback_add(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMATE, _pre_animate_cb, NULL);
+
+ return eo_obj;
+}
+
+EOLIAN static void
+_efl_animation_instance_scale_efl_object_destructor(Eo *eo_obj,
+ Evas_Object_Animation_Instance_Scale_Data *pd EINA_UNUSED)
+{
+ efl_destructor(efl_super(eo_obj, MY_CLASS));
+}
+
+EOLIAN static void
+_efl_animation_instance_scale_efl_animation_instance_final_state_show(Eo *eo_obj,
+ Evas_Object_Animation_Instance_Scale_Data *pd EINA_UNUSED)
+{
+ EFL_ANIMATION_INSTANCE_SCALE_CHECK_OR_RETURN(eo_obj);
+
+ _progress_set(eo_obj, 1.0);
+}
+
+/* Internal EO APIs */
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_scale_set, EFL_FUNC_CALL(from_scale_x, from_scale_y, to_scale_x, to_scale_y, pivot, cx, cy), double from_scale_x, double from_scale_y, double to_scale_x, double to_scale_y, Efl_Canvas_Object *pivot, double cx, double cy);
+EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_instance_scale_get, EFL_FUNC_CALL(from_scale_x, from_scale_y, to_scale_x, to_scale_y, pivot, cx, cy), double *from_scale_x, double *from_scale_y, double *to_scale_x, double *to_scale_y, Efl_Canvas_Object **pivot, double *cx, double *cy);
+
+EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_scale_absolute_set, EFL_FUNC_CALL(from_scale_x, from_scale_y, to_scale_x, to_scale_y, cx, cy), double from_scale_x, double from_scale_y, double to_scale_x, double to_scale_y, int cx, int cy);
+EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_instance_scale_absolute_get, EFL_FUNC_CALL(from_scale_x, from_scale_y, to_scale_x, to_scale_y, cx, cy), double *from_scale_x, double *from_scale_y, double *to_scale_x, double *to_scale_y, int *cx, int *cy);
+
+#define EFL_ANIMATION_INSTANCE_SCALE_EXTRA_OPS \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_scale_set, _efl_animation_instance_scale_scale_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_scale_get, _efl_animation_instance_scale_scale_get), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_scale_absolute_set, _efl_animation_instance_scale_scale_absolute_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_scale_absolute_get, _efl_animation_instance_scale_scale_absolute_get), \
+ EFL_OBJECT_OP_FUNC(efl_animation_instance_final_state_show, _efl_animation_instance_scale_efl_animation_instance_final_state_show)
+
+#include "efl_animation_instance_scale.eo.c"
diff --git a/src/lib/evas/canvas/efl_animation_instance_scale.eo b/src/lib/evas/canvas/efl_animation_instance_scale.eo
new file mode 100644
index 0000000000..48904f0215
--- /dev/null
+++ b/src/lib/evas/canvas/efl_animation_instance_scale.eo
@@ -0,0 +1,12 @@
+import efl_animation_types;
+
+class Efl.Animation.Instance.Scale (Efl.Animation.Instance)
+{
+ [[Efl scale animation instance class]]
+ legacy_prefix: evas_object_animation_instance;
+ data: Evas_Object_Animation_Instance_Scale_Data;
+ implements {
+ Efl.Object.constructor;
+ Efl.Object.destructor;
+ }
+}
diff --git a/src/lib/evas/canvas/efl_animation_scale.c b/src/lib/evas/canvas/efl_animation_scale.c
index 6ffdc981d7..dce4ddc868 100644
--- a/src/lib/evas/canvas/efl_animation_scale.c
+++ b/src/lib/evas/canvas/efl_animation_scale.c
@@ -246,6 +246,43 @@ _efl_animation_scale_scale_absolute_get(Eo *eo_obj,
*cy = pd->abs_pivot.cy;
}
+EOLIAN static Efl_Animation_Instance *
+_efl_animation_scale_efl_animation_instance_create(Eo *eo_obj,
+ Evas_Object_Animation_Scale_Data *pd)
+{
+ EFL_ANIMATION_SCALE_CHECK_OR_RETURN(eo_obj, NULL);
+
+ Efl_Animation_Instance_Scale *instance
+ = efl_add(EFL_ANIMATION_INSTANCE_SCALE_CLASS, NULL);
+
+ Efl_Canvas_Object *target = efl_animation_target_get(eo_obj);
+ efl_animation_instance_target_set(instance, target);
+
+ Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj);
+ efl_animation_instance_final_state_keep_set(instance, state_keep);
+
+ double duration = efl_animation_duration_get(eo_obj);
+ efl_animation_instance_duration_set(instance, duration);
+
+ if (pd->use_rel_pivot)
+ {
+ efl_animation_instance_scale_set(instance,
+ pd->from.scale_x, pd->from.scale_y,
+ pd->to.scale_x, pd->to.scale_y,
+ pd->rel_pivot.obj,
+ pd->rel_pivot.cx, pd->rel_pivot.cy);
+ }
+ else
+ {
+ efl_animation_instance_scale_absolute_set(instance,
+ pd->from.scale_x, pd->from.scale_y,
+ pd->to.scale_x, pd->to.scale_y,
+ pd->abs_pivot.cx, pd->abs_pivot.cy);
+ }
+
+ return instance;
+}
+
EOLIAN static Efl_Object *
_efl_animation_scale_efl_object_constructor(Eo *eo_obj,
Evas_Object_Animation_Scale_Data *pd)
diff --git a/src/lib/evas/canvas/efl_animation_scale.eo b/src/lib/evas/canvas/efl_animation_scale.eo
index 346af62c2a..80c7d79e57 100644
--- a/src/lib/evas/canvas/efl_animation_scale.eo
+++ b/src/lib/evas/canvas/efl_animation_scale.eo
@@ -39,5 +39,6 @@ class Efl.Animation.Scale (Efl.Animation)
implements {
Efl.Object.constructor;
Efl.Object.destructor;
+ Efl.Animation.instance_create;
}
}
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index c4a897ea9d..bee422e758 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -114,6 +114,7 @@ typedef struct _Evas_Object_Animation_Scale_Data Evas_Objec
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;
+typedef struct _Evas_Object_Animation_Instance_Scale_Data Evas_Object_Animation_Instance_Scale_Data;
typedef struct _Evas_Object_Animation_Instance_Data Evas_Object_Animation_Instance_Data;
// 3D stuff