diff options
author | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-07-03 22:30:31 +0900 |
---|---|---|
committer | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-08-18 12:06:01 +0900 |
commit | f595a5fa9b13ac21f53533d126f327f16af25a9d (patch) | |
tree | 49cffe7584e38a26daaf5c90ba64b405f7a2682c /src | |
parent | e56bd3656f310f63da019820a9d542f3d0bd58ca (diff) | |
download | efl-f595a5fa9b13ac21f53533d126f327f16af25a9d.tar.gz |
efl_animation: Add translate animation instance
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile_Evas.am | 2 | ||||
-rw-r--r-- | src/lib/evas/Evas_Common.h | 7 | ||||
-rw-r--r-- | src/lib/evas/Evas_Eo.h | 1 | ||||
-rw-r--r-- | src/lib/evas/Evas_Internal.h | 6 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_translate.c | 301 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_translate.eo | 12 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_translate.c | 38 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_translate.eo | 1 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 1 |
9 files changed, 369 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 7453745b64..fc00548acc 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -59,6 +59,7 @@ evas_eolian_pub_files = \ lib/evas/canvas/efl_animation_instance_alpha.eo \ lib/evas/canvas/efl_animation_instance_rotate.eo \ lib/evas/canvas/efl_animation_instance_scale.eo \ + lib/evas/canvas/efl_animation_instance_translate.eo \ $(NULL) evas_eolian_legacy_files = \ @@ -232,6 +233,7 @@ 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 \ +lib/evas/canvas/efl_animation_instance_translate.c \ $(NULL) EXTRA_DIST2 += \ diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 153c40a648..e343361144 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -3384,6 +3384,13 @@ typedef Eo Efl_Animation_Instance_Scale; #endif +#ifndef _EFL_ANIMATION_INSTANCE_TRANSLATE_EO_CLASS_TYPE +#define _EFL_ANIMATION_INSTANCE_TRANSLATE_EO_CLASS_TYPE + +typedef Eo Efl_Animation_Instance_Translate; + +#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 3cee5ed83e..5ab13172e9 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -75,6 +75,7 @@ #include "canvas/efl_animation_instance_alpha.eo.h" #include "canvas/efl_animation_instance_rotate.eo.h" #include "canvas/efl_animation_instance_scale.eo.h" +#include "canvas/efl_animation_instance_translate.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 ff28607a80..acdc90771a 100644 --- a/src/lib/evas/Evas_Internal.h +++ b/src/lib/evas/Evas_Internal.h @@ -115,6 +115,12 @@ EOAPI void efl_animation_instance_scale_get(const Eo *obj, double *from_scale_x, 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); +EOAPI void efl_animation_instance_translate_set(Eo *obj, int from_x, int from_y, int to_x, int to_y); +EOAPI void efl_animation_instance_translate_get(const Eo *obj, int *from_x, int *from_y, int *to_x, int *to_y); + +EOAPI void efl_animation_instance_translate_absolute_set(Eo *obj, int from_x, int from_y, int to_x, int to_y); +EOAPI void efl_animation_instance_translate_absolute_get(const Eo *obj, int *from_x, int *from_y, int *to_x, int *to_y); + #ifdef __cplusplus } #endif diff --git a/src/lib/evas/canvas/efl_animation_instance_translate.c b/src/lib/evas/canvas/efl_animation_instance_translate.c new file mode 100644 index 0000000000..f4f3348b25 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_instance_translate.c @@ -0,0 +1,301 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#define MY_CLASS EFL_ANIMATION_INSTANCE_TRANSLATE_CLASS +#define MY_CLASS_NAME efl_class_name_get(MY_CLASS) + +#define EFL_ANIMATION_INSTANCE_TRANSLATE_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_TRANSLATE_DATA_GET(o, pd) \ + Evas_Object_Animation_Instance_Translate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_INSTANCE_TRANSLATE_CLASS) + +typedef struct _Evas_Object_Animation_Instance_Translate_Property +{ + Evas_Coord move_x, move_y; + Evas_Coord x, y; +} Evas_Object_Animation_Instance_Translate_Property; + +struct _Evas_Object_Animation_Instance_Translate_Data +{ + Evas_Object_Animation_Instance_Translate_Property from; + Evas_Object_Animation_Instance_Translate_Property to; + + Evas_Coord start_x, start_y; + + Eina_Bool use_rel_move; +}; + +EOLIAN static void +_efl_animation_instance_translate_translate_set(Eo *eo_obj, + Evas_Object_Animation_Instance_Translate_Data *pd, + Evas_Coord from_x, + Evas_Coord from_y, + Evas_Coord to_x, + Evas_Coord to_y) +{ + EFL_ANIMATION_INSTANCE_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_instance_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_instance_translate_translate_get(Eo *eo_obj, + Evas_Object_Animation_Instance_Translate_Data *pd, + Evas_Coord *from_x, + Evas_Coord *from_y, + Evas_Coord *to_x, + Evas_Coord *to_y) +{ + EFL_ANIMATION_INSTANCE_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_instance_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_instance_translate_translate_absolute_set(Eo *eo_obj, + Evas_Object_Animation_Instance_Translate_Data *pd, + Evas_Coord from_x, + Evas_Coord from_y, + Evas_Coord to_x, + Evas_Coord to_y) +{ + EFL_ANIMATION_INSTANCE_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_instance_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_instance_translate_translate_absolute_get(Eo *eo_obj, + Evas_Object_Animation_Instance_Translate_Data *pd, + Evas_Coord *from_x, + Evas_Coord *from_y, + Evas_Coord *to_x, + Evas_Coord *to_y) +{ + EFL_ANIMATION_INSTANCE_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_instance_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; +} + +static void +_pre_start_cb(void *data EINA_UNUSED, const Efl_Event *event) +{ + EFL_ANIMATION_INSTANCE_TRANSLATE_DATA_GET(event->object, pd); + + pd->start_x = 0; + pd->start_y = 0; + + Efl_Canvas_Object *target = efl_animation_instance_target_get(event->object); + if (!target) return; + + Evas_Coord x, y; + evas_object_geometry_get(target, &x, &y, NULL, NULL); + + pd->start_x = x; + pd->start_y = y; +} + +static void +_progress_set(Eo *eo_obj, double progress) +{ + EFL_ANIMATION_INSTANCE_TRANSLATE_DATA_GET(eo_obj, pd); + + Efl_Canvas_Object *target = efl_animation_instance_target_get(eo_obj); + if (!target) return; + + Evas_Coord new_x = 0; + Evas_Coord new_y = 0; + + if (pd->use_rel_move) + { + Evas_Coord move_x, move_y; + + move_x + = (pd->from.move_x * (1.0 - progress)) + (pd->to.move_x * progress); + move_y + = (pd->from.move_y * (1.0 - progress)) + (pd->to.move_y * progress); + + new_x = pd->start_x + move_x; + new_y = pd->start_y + move_y; + } + else + { + new_x = (pd->from.x * (1.0 - progress)) + (pd->to.x * progress); + new_y = (pd->from.y * (1.0 - progress)) + (pd->to.y * progress); + } + + evas_object_move(target, new_x, new_y); +} + +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_translate_efl_object_constructor(Eo *eo_obj, + Evas_Object_Animation_Instance_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->start_x = 0; + pd->start_y = 0; + + pd->use_rel_move = EINA_TRUE; + + //pre start event is supported within class only (protected event) + efl_event_callback_add(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_PRE_START, + _pre_start_cb, NULL); + + //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_translate_efl_object_destructor(Eo *eo_obj, + Evas_Object_Animation_Instance_Translate_Data *pd EINA_UNUSED) +{ + efl_destructor(efl_super(eo_obj, MY_CLASS)); +} + +EOLIAN static void +_efl_animation_instance_translate_efl_animation_instance_final_state_show(Eo *eo_obj, + Evas_Object_Animation_Instance_Translate_Data *pd EINA_UNUSED) +{ + EFL_ANIMATION_INSTANCE_TRANSLATE_CHECK_OR_RETURN(eo_obj); + + _progress_set(eo_obj, 1.0); +} + +/* Internal EO APIs */ + +EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_translate_set, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int from_x, int from_y, int to_x, int to_y); +EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_instance_translate_get, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int *from_x, int *from_y, int *to_x, int *to_y); + +EOAPI EFL_VOID_FUNC_BODYV(efl_animation_instance_translate_absolute_set, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int from_x, int from_y, int to_x, int to_y); +EOAPI EFL_VOID_FUNC_BODYV_CONST(efl_animation_instance_translate_absolute_get, EFL_FUNC_CALL(from_x, from_y, to_x, to_y), int *from_x, int *from_y, int *to_x, int *to_y); + +#define EFL_ANIMATION_INSTANCE_TRANSLATE_EXTRA_OPS \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_translate_set, _efl_animation_instance_translate_translate_set), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_translate_get, _efl_animation_instance_translate_translate_get), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_translate_absolute_set, _efl_animation_instance_translate_translate_absolute_set), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_translate_absolute_get, _efl_animation_instance_translate_translate_absolute_get), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_final_state_show, _efl_animation_instance_translate_efl_animation_instance_final_state_show) + +#include "efl_animation_instance_translate.eo.c" diff --git a/src/lib/evas/canvas/efl_animation_instance_translate.eo b/src/lib/evas/canvas/efl_animation_instance_translate.eo new file mode 100644 index 0000000000..20bea45286 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_instance_translate.eo @@ -0,0 +1,12 @@ +import efl_animation_types; + +class Efl.Animation.Instance.Translate (Efl.Animation.Instance) +{ + [[Efl translate animation instance class]] + legacy_prefix: evas_object_animation_instance; + data: Evas_Object_Animation_Instance_Translate_Data; + implements { + Efl.Object.constructor; + Efl.Object.destructor; + } +} diff --git a/src/lib/evas/canvas/efl_animation_translate.c b/src/lib/evas/canvas/efl_animation_translate.c index b093a2cbf8..fe0e48ff83 100644 --- a/src/lib/evas/canvas/efl_animation_translate.c +++ b/src/lib/evas/canvas/efl_animation_translate.c @@ -175,6 +175,44 @@ _efl_animation_translate_translate_absolute_get(Eo *eo_obj, *to_y = pd->to.y; } +EOLIAN static Efl_Animation_Instance * +_efl_animation_translate_efl_animation_instance_create(Eo *eo_obj, + Evas_Object_Animation_Translate_Data *pd) +{ + EFL_ANIMATION_TRANSLATE_CHECK_OR_RETURN(eo_obj, NULL); + + Efl_Animation_Instance_Translate *instance + = efl_add(EFL_ANIMATION_INSTANCE_TRANSLATE_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_move) + { + efl_animation_instance_translate_set(instance, + pd->from.move_x, + pd->from.move_y, + pd->to.move_x, + pd->to.move_y); + } + else + { + efl_animation_instance_translate_absolute_set(instance, + pd->from.x, + pd->from.y, + pd->to.x, + pd->to.y); + } + + return instance; +} + EOLIAN static Efl_Object * _efl_animation_translate_efl_object_constructor(Eo *eo_obj, Evas_Object_Animation_Translate_Data *pd) diff --git a/src/lib/evas/canvas/efl_animation_translate.eo b/src/lib/evas/canvas/efl_animation_translate.eo index 32e21614ca..6fc297a2f9 100644 --- a/src/lib/evas/canvas/efl_animation_translate.eo +++ b/src/lib/evas/canvas/efl_animation_translate.eo @@ -34,5 +34,6 @@ class Efl.Animation.Translate (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 c75446c286..3cb1d6adaf 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -116,6 +116,7 @@ typedef struct _Evas_Object_Animation_Data Evas_Objec 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_Translate_Data Evas_Object_Animation_Instance_Translate_Data; typedef struct _Evas_Object_Animation_Instance_Data Evas_Object_Animation_Instance_Data; // 3D stuff |