diff options
author | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-08-25 13:37:12 +0900 |
---|---|---|
committer | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-09-18 20:47:24 +0900 |
commit | 384bfb252454a6e38e681e1d9728a5d1502e86ec (patch) | |
tree | 9d0fae10c189590ea753d9c14b2b4be4fad6c85c | |
parent | aa91ad31c12f4b91a9bfbce33ad3989d5ebbd7b9 (diff) | |
download | efl-384bfb252454a6e38e681e1d9728a5d1502e86ec.tar.gz |
efl_animation: Add translate animation
-rw-r--r-- | src/Makefile_Evas.am | 3 | ||||
-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/canvas/efl_animation_translate.c | 182 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_translate.eo | 37 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_translate_private.h | 35 |
6 files changed, 265 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 536d412783..2c7119275c 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -48,6 +48,7 @@ evas_eolian_pub_files = \ 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_translate.eo \ lib/evas/canvas/efl_animation_instance.eo \ lib/evas/canvas/efl_animation_instance_alpha.eo \ lib/evas/canvas/efl_animation_instance_rotate.eo \ @@ -134,6 +135,7 @@ 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_translate_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 \ @@ -227,6 +229,7 @@ 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_translate.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 c87fa3ce63..9dccb99082 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -3351,6 +3351,13 @@ typedef Eo Efl_Animation_Scale; #endif +#ifndef _EFL_ANIMATION_TRANSLATE_EO_CLASS_TYPE +#define _EFL_ANIMATION_TRANSLATE_EO_CLASS_TYPE + +typedef Eo Efl_Animation_Translate; + +#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 ac367aac35..f2f0d79783 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -59,6 +59,7 @@ #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_translate.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_translate.c b/src/lib/evas/canvas/efl_animation_translate.c new file mode 100644 index 0000000000..8b1b123fc4 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_translate.c @@ -0,0 +1,182 @@ +#include "efl_animation_translate_private.h" + +EOLIAN static void +_efl_animation_translate_translate_set(Eo *eo_obj, + Efl_Animation_Translate_Data *pd, + Evas_Coord from_x, + Evas_Coord from_y, + Evas_Coord to_x, + Evas_Coord to_y) +{ + EFL_ANIMATION_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_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_translate_translate_get(Eo *eo_obj, + Efl_Animation_Translate_Data *pd, + Evas_Coord *from_x, + Evas_Coord *from_y, + Evas_Coord *to_x, + Evas_Coord *to_y) +{ + EFL_ANIMATION_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_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_translate_translate_absolute_set(Eo *eo_obj, + Efl_Animation_Translate_Data *pd, + Evas_Coord from_x, + Evas_Coord from_y, + Evas_Coord to_x, + Evas_Coord to_y) +{ + EFL_ANIMATION_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_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_translate_translate_absolute_get(Eo *eo_obj, + Efl_Animation_Translate_Data *pd, + Evas_Coord *from_x, + Evas_Coord *from_y, + Evas_Coord *to_x, + Evas_Coord *to_y) +{ + EFL_ANIMATION_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_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; +} + +EOLIAN static void +_efl_animation_translate_efl_animation_duration_set(Eo *eo_obj, + Efl_Animation_Translate_Data *pd EINA_UNUSED, + double duration) +{ + EFL_ANIMATION_TRANSLATE_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_translate_efl_object_constructor(Eo *eo_obj, + Efl_Animation_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->use_rel_move = EINA_TRUE; + + return eo_obj; +} + +#include "efl_animation_translate.eo.c" diff --git a/src/lib/evas/canvas/efl_animation_translate.eo b/src/lib/evas/canvas/efl_animation_translate.eo new file mode 100644 index 0000000000..e589d05fce --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_translate.eo @@ -0,0 +1,37 @@ +import efl_animation_types; + +class Efl.Animation.Translate (Efl.Animation) +{ + [[Efl translate animation class]] + data: Efl_Animation_Translate_Data; + methods { + @property translate { + set { + } + get { + } + values { + from_x: int; [[Distance moved along x axis when animation starts]] + from_y: int; [[Distance moved along y axis when animation starts]] + to_x: int; [[Distance moved along x axis when animation ends]] + to_y: int; [[Distance moved along y axis when animation ends]] + } + } + @property translate_absolute { + set { + } + get { + } + values { + from_x: int; [[X coordinate when animation starts]] + from_y: int; [[Y coordinate when animation starts]] + to_x: int; [[X coordinate when animation ends]] + to_y: int; [[Y coordinate when animation ends]] + } + } + } + implements { + Efl.Object.constructor; + Efl.Animation.duration { set; } + } +} diff --git a/src/lib/evas/canvas/efl_animation_translate_private.h b/src/lib/evas/canvas/efl_animation_translate_private.h new file mode 100644 index 0000000000..7428012e98 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_translate_private.h @@ -0,0 +1,35 @@ +#define EFL_ANIMATION_PROTECTED + +#include "evas_common_private.h" + +#define MY_CLASS EFL_ANIMATION_TRANSLATE_CLASS +#define MY_CLASS_NAME efl_class_name_get(MY_CLASS) + +#define EFL_ANIMATION_TRANSLATE_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_TRANSLATE_DATA_GET(o, pd) \ + Efl_Animation_Translate_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_TRANSLATE_CLASS) + +typedef struct _Efl_Animation_Translate_Property +{ + Evas_Coord move_x, move_y; + Evas_Coord x, y; +} Efl_Animation_Translate_Property; + +typedef struct _Efl_Animation_Translate_Data +{ + Efl_Animation_Translate_Property from; + Efl_Animation_Translate_Property to; + + Eina_Bool use_rel_move; +} Efl_Animation_Translate_Data; |