jaehyun pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=39cc542d7f47436d84c3dfd5c1138f9610da3de2
commit 39cc542d7f47436d84c3dfd5c1138f9610da3de2 Author: Jaehyun Cho <jae_hyun....@samsung.com> Date: Wed Sep 13 14:59:22 2017 +0900 efl_animation: Add interpolator property Interpolator property is added to apply interpolation function. --- src/Makefile_Elementary.am | 1 + src/bin/elementary/Makefile.am | 1 + src/bin/elementary/test.c | 2 + src/bin/elementary/test_efl_anim_interpolator.c | 229 +++++++++++++++++++++ src/lib/evas/Evas_Internal.h | 3 + src/lib/evas/canvas/efl_animation.c | 21 ++ src/lib/evas/canvas/efl_animation.eo | 9 + src/lib/evas/canvas/efl_animation_alpha.c | 3 + src/lib/evas/canvas/efl_animation_alpha_private.h | 1 + src/lib/evas/canvas/efl_animation_group.c | 17 ++ src/lib/evas/canvas/efl_animation_group.eo | 1 + src/lib/evas/canvas/efl_animation_group_parallel.c | 3 + .../canvas/efl_animation_group_parallel_private.h | 1 + src/lib/evas/canvas/efl_animation_group_private.h | 1 + .../evas/canvas/efl_animation_group_sequential.c | 3 + .../efl_animation_group_sequential_private.h | 1 + src/lib/evas/canvas/efl_animation_object.c | 39 +++- src/lib/evas/canvas/efl_animation_object_group.c | 22 +- .../canvas/efl_animation_object_group_parallel.c | 18 ++ .../efl_animation_object_group_parallel_private.h | 1 + .../canvas/efl_animation_object_group_private.h | 1 + .../canvas/efl_animation_object_group_sequential.c | 18 ++ ...efl_animation_object_group_sequential_private.h | 1 + src/lib/evas/canvas/efl_animation_object_private.h | 2 + src/lib/evas/canvas/efl_animation_private.h | 3 + src/lib/evas/canvas/efl_animation_rotate.c | 3 + src/lib/evas/canvas/efl_animation_rotate_private.h | 1 + src/lib/evas/canvas/efl_animation_scale.c | 3 + src/lib/evas/canvas/efl_animation_scale_private.h | 1 + src/lib/evas/canvas/efl_animation_translate.c | 3 + .../evas/canvas/efl_animation_translate_private.h | 1 + 31 files changed, 412 insertions(+), 2 deletions(-) diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index bcf39cce8e..039f50b455 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -807,6 +807,7 @@ bin/elementary/test_efl_anim_event_anim.c \ bin/elementary/test_efl_anim_pause.c \ bin/elementary/test_efl_anim_repeat.c \ bin/elementary/test_efl_anim_start_delay.c \ +bin/elementary/test_efl_anim_interpolator.c \ bin/elementary/test_eio.c \ bin/elementary/test_entry.c \ bin/elementary/test_entry_anchor.c \ diff --git a/src/bin/elementary/Makefile.am b/src/bin/elementary/Makefile.am index ce87962c3c..63a0bf86b0 100644 --- a/src/bin/elementary/Makefile.am +++ b/src/bin/elementary/Makefile.am @@ -42,6 +42,7 @@ test_efl_anim_event_anim.c \ test_efl_anim_pause.c \ test_efl_anim_repeat.c \ test_efl_anim_start_delay.c \ +test_efl_anim_interpolator.c \ test_application_server.c \ test_bg.c \ test_box.c \ diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c index 095eee5186..754e0c75ea 100644 --- a/src/bin/elementary/test.c +++ b/src/bin/elementary/test.c @@ -337,6 +337,7 @@ void test_efl_anim_event_anim(void *data, Evas_Object *obj, void *event_info); void test_efl_anim_pause(void *data, Evas_Object *obj, void *event_info); void test_efl_anim_repeat(void *data, Evas_Object *obj, void *event_info); void test_efl_anim_start_delay(void *data, Evas_Object *obj, void *event_info); +void test_efl_anim_interpolator(void *data, Evas_Object *obj, void *event_info); Evas_Object *win, *tbx; // TODO: refactoring void *tt; @@ -821,6 +822,7 @@ add_tests: ADD_TEST(NULL, "Effects", "Efl Animation Pause", test_efl_anim_pause); ADD_TEST(NULL, "Effects", "Efl Animation Repeat", test_efl_anim_repeat); ADD_TEST(NULL, "Effects", "Efl Animation Start Delay", test_efl_anim_start_delay); + ADD_TEST(NULL, "Effects", "Efl Animation Interpolator", test_efl_anim_interpolator); //------------------------------// ADD_TEST(NULL, "Edje External", "ExtButton", test_external_button); diff --git a/src/bin/elementary/test_efl_anim_interpolator.c b/src/bin/elementary/test_efl_anim_interpolator.c new file mode 100644 index 0000000000..732d217e43 --- /dev/null +++ b/src/bin/elementary/test_efl_anim_interpolator.c @@ -0,0 +1,229 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif +#include <Elementary.h> + +#define INTERP_NUM 7 +#define BTN_NUM (INTERP_NUM + 1) +#define BTN_W 50 +#define BTN_H 50 +#define WIN_H (BTN_NUM * BTN_H) +#define WIN_W WIN_H + +typedef struct _App_Data +{ + Efl_Animation *anim[INTERP_NUM]; + Efl_Animation_Object *anim_obj[INTERP_NUM]; + + Evas_Object *btn[INTERP_NUM]; + Evas_Object *start_all_btn; + + Eina_Bool running_anim_cnt; +} App_Data; + +static Efl_Interpolator * +_interpolator_create(int index) +{ + Efl_Interpolator *interp = NULL; + + if (index == 0) + { + interp = efl_add(EFL_INTERPOLATOR_LINEAR_CLASS, NULL); + } + else if (index == 1) + { + interp = efl_add(EFL_INTERPOLATOR_SINUSOIDAL_CLASS, NULL); + efl_interpolator_sinusoidal_factor_set(interp, 1.0); + } + else if (index == 2) + { + interp = efl_add(EFL_INTERPOLATOR_DECELERATE_CLASS, NULL); + efl_interpolator_decelerate_factor_set(interp, 1.0); + } + else if (index == 3) + { + interp = efl_add(EFL_INTERPOLATOR_ACCELERATE_CLASS, NULL); + efl_interpolator_accelerate_factor_set(interp, 1.0); + } + else if (index == 4) + { + interp = efl_add(EFL_INTERPOLATOR_DIVISOR_CLASS, NULL); + efl_interpolator_divisor_factors_set(interp, 1.0, 1.0); + } + else if (index == 5) + { + interp = efl_add(EFL_INTERPOLATOR_BOUNCE_CLASS, NULL); + efl_interpolator_bounce_factors_set(interp, 1.0, 1.0); + } + else if (index == 6) + { + interp = efl_add(EFL_INTERPOLATOR_SPRING_CLASS, NULL); + efl_interpolator_spring_factors_set(interp, 1.0, 1.0); + } + + return interp; +} + +static void +_anim_started_cb(void *data, const Efl_Event *event EINA_UNUSED) +{ + App_Data *ad = data; + + printf("Animation has been started!\n"); + + ad->running_anim_cnt++; +} + +static void +_anim_ended_cb(void *data, const Efl_Event *event) +{ + App_Data *ad = data; + + printf("Animation has been ended!\n"); + + ad->running_anim_cnt--; + + int i; + for (i = 0; i < INTERP_NUM; i++) + { + if (ad->anim_obj[i] == event->object) + { + ad->anim_obj[i] = NULL; + elm_object_disabled_set(ad->btn[i], EINA_FALSE); + break; + } + } + + if (ad->running_anim_cnt == 0) + elm_object_disabled_set(ad->start_all_btn, EINA_FALSE); +} + +static void +_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event) +{ + Efl_Animation_Object_Running_Event_Info *event_info = event->info; + double progress = event_info->progress; + printf("Animation is running! Current progress(%lf)\n", progress); +} + +static void +_anim_start(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + App_Data *ad = data; + + int index = (uintptr_t)evas_object_data_get(obj, "index"); + + //Create Animation Object from Animation + Efl_Animation_Object *anim_obj = efl_animation_object_create(ad->anim[index]); + ad->anim_obj[index] = anim_obj; + + //Register callback called when animation starts + efl_event_callback_add(anim_obj, EFL_ANIMATION_OBJECT_EVENT_STARTED, _anim_started_cb, ad); + + //Register callback called when animation ends + efl_event_callback_add(anim_obj, EFL_ANIMATION_OBJECT_EVENT_ENDED, _anim_ended_cb, ad); + + //Register callback called while animation is executed + efl_event_callback_add(anim_obj, EFL_ANIMATION_OBJECT_EVENT_RUNNING, _anim_running_cb, NULL); + + //Let Animation Object start animation + efl_animation_object_start(anim_obj); + + elm_object_disabled_set(obj, EINA_TRUE); + elm_object_disabled_set(ad->start_all_btn, EINA_TRUE); +} + +static void +_anim_start_all(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) +{ + App_Data *ad = data; + + int i; + for (i = 0; i < INTERP_NUM; i++) + { + //Create Animation Object from Animation + Efl_Animation_Object *anim_obj = efl_animation_object_create(ad->anim[i]); + ad->anim_obj[i] = anim_obj; + + //Register callback called when animation starts + efl_event_callback_add(anim_obj, EFL_ANIMATION_OBJECT_EVENT_STARTED, _anim_started_cb, ad); + + //Register callback called when animation ends + efl_event_callback_add(anim_obj, EFL_ANIMATION_OBJECT_EVENT_ENDED, _anim_ended_cb, ad); + + //Register callback called while animation is executed + efl_event_callback_add(anim_obj, EFL_ANIMATION_OBJECT_EVENT_RUNNING, _anim_running_cb, NULL); + + //Let Animation Object start animation + efl_animation_object_start(anim_obj); + + elm_object_disabled_set(ad->btn[i], EINA_TRUE); + } + + elm_object_disabled_set(obj, EINA_TRUE); +} + +static void +_win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + App_Data *ad = data; + free(ad); +} + +void +test_efl_anim_interpolator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + App_Data *ad = calloc(1, sizeof(App_Data)); + if (!ad) return; + + const char *modes[] = {"LINEAR", "SINUSOIDAL", "DECELERATE", "ACCELERATE", + "DIVISOR_INTERP", "BOUNCE", "SPRING"}; + + Evas_Object *win = elm_win_add(NULL, "Efl Animation Interpolator", ELM_WIN_BASIC); + elm_win_title_set(win, "Efl Animation Interpolator"); + elm_win_autodel_set(win, EINA_TRUE); + evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad); + + //Button to start all animations + Evas_Object *start_all_btn = elm_button_add(win); + elm_object_text_set(start_all_btn, "Start All"); + evas_object_resize(start_all_btn, WIN_W, BTN_H); + evas_object_move(start_all_btn, 0, (WIN_H - BTN_H)); + evas_object_show(start_all_btn); + evas_object_smart_callback_add(start_all_btn, "clicked", _anim_start_all, ad); + ad->start_all_btn = start_all_btn; + + int i; + for (i = 0; i < INTERP_NUM; i++) + { + Evas_Object *label = elm_label_add(win); + elm_object_text_set(label, modes[i]); + evas_object_resize(label, WIN_W, BTN_H); + evas_object_move(label, 0, (i * BTN_H)); + evas_object_show(label); + + //Button to be animated + Evas_Object *btn = elm_button_add(win); + evas_object_data_set(btn, "index", (void *)(uintptr_t)i); + elm_object_text_set(btn, "Start"); + evas_object_resize(btn, BTN_W, BTN_H); + evas_object_move(btn, 0, (i * BTN_H)); + evas_object_show(btn); + evas_object_smart_callback_add(btn, "clicked", _anim_start, ad); + ad->btn[i] = btn; + + Efl_Animation *anim = efl_add(EFL_ANIMATION_TRANSLATE_CLASS, NULL); + efl_animation_translate_set(anim, 0, 0, (WIN_W - BTN_W), 0); + efl_animation_duration_set(anim, 2.0); + efl_animation_target_set(anim, btn); + + Efl_Interpolator *interp = _interpolator_create(i); + efl_animation_interpolator_set(anim, interp); + ad->anim[i] = anim; + } + + ad->running_anim_cnt = 0; + + evas_object_resize(win, WIN_W, WIN_H); + evas_object_show(win); +} diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h index d0eb810e04..0ce1d847ba 100644 --- a/src/lib/evas/Evas_Internal.h +++ b/src/lib/evas/Evas_Internal.h @@ -113,6 +113,9 @@ EOAPI Efl_Animation_Object_Repeat_Mode efl_animation_object_repeat_mode_get(cons EOAPI void efl_animation_object_repeat_count_set(Eo *obj, int count); EOAPI int efl_animation_object_repeat_count_get(const Eo *obj); +EOAPI void efl_animation_object_interpolator_set(Eo *obj, Efl_Object *interpolator); +EOAPI Efl_Object *efl_animation_object_interpolator_get(const Eo *obj); + EWAPI extern const Efl_Event_Description _EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED; #define EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED (&(_EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED)) /* Efl.Animation.Object END */ diff --git a/src/lib/evas/canvas/efl_animation.c b/src/lib/evas/canvas/efl_animation.c index f01a40ba67..874e4107dd 100644 --- a/src/lib/evas/canvas/efl_animation.c +++ b/src/lib/evas/canvas/efl_animation.c @@ -196,6 +196,25 @@ _efl_animation_start_delay_get(Eo *eo_obj, return pd->start_delay_time; } +EOLIAN static void +_efl_animation_interpolator_set(Eo *eo_obj, + Efl_Animation_Data *pd, + Efl_Interpolator *interpolator) +{ + EFL_ANIMATION_CHECK_OR_RETURN(eo_obj); + + pd->interpolator = interpolator; +} + +EOLIAN static Efl_Interpolator * +_efl_animation_interpolator_get(Eo *eo_obj, + Efl_Animation_Data *pd) +{ + EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, NULL); + + return pd->interpolator; +} + EOLIAN static Efl_Object * _efl_animation_efl_object_constructor(Eo *eo_obj, Efl_Animation_Data *pd) @@ -210,6 +229,8 @@ _efl_animation_efl_object_constructor(Eo *eo_obj, pd->repeat_count = 0; + pd->interpolator = NULL; + pd->is_deleted = EINA_FALSE; pd->keep_final_state = EINA_FALSE; diff --git a/src/lib/evas/canvas/efl_animation.eo b/src/lib/evas/canvas/efl_animation.eo index edcfec0d67..4dc169b0f8 100644 --- a/src/lib/evas/canvas/efl_animation.eo +++ b/src/lib/evas/canvas/efl_animation.eo @@ -74,6 +74,15 @@ class Efl.Animation (Efl.Object) delay_time: double; [[Delay time, in seconds, from when the animation starts until the animation is animated]] } } + @property interpolator { + set { + } + get { + } + values { + interpolator: Efl.Object; [[Interpolator which indicates interpolation fucntion. Efl_Interpolator is required.]] + } + } is_deleted @protected { return: bool; [[$true if animation is deleted, $false otherwise.]] } diff --git a/src/lib/evas/canvas/efl_animation_alpha.c b/src/lib/evas/canvas/efl_animation_alpha.c index 8dff1442ed..2e21e6a24b 100644 --- a/src/lib/evas/canvas/efl_animation_alpha.c +++ b/src/lib/evas/canvas/efl_animation_alpha.c @@ -57,6 +57,9 @@ _efl_animation_alpha_efl_animation_object_create(Eo *eo_obj, int repeat_count = efl_animation_repeat_count_get(eo_obj); efl_animation_object_repeat_count_set(anim_obj, repeat_count); + Efl_Interpolator *interpolator = efl_animation_interpolator_get(eo_obj); + efl_animation_object_interpolator_set(anim_obj, interpolator); + efl_animation_object_alpha_set(anim_obj, pd->from.alpha, pd->to.alpha); return anim_obj; diff --git a/src/lib/evas/canvas/efl_animation_alpha_private.h b/src/lib/evas/canvas/efl_animation_alpha_private.h index 58e429eb07..fc08be75bc 100644 --- a/src/lib/evas/canvas/efl_animation_alpha_private.h +++ b/src/lib/evas/canvas/efl_animation_alpha_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_ALPHA_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_group.c b/src/lib/evas/canvas/efl_animation_group.c index 750a69de9f..dd2b30a20e 100644 --- a/src/lib/evas/canvas/efl_animation_group.c +++ b/src/lib/evas/canvas/efl_animation_group.c @@ -106,6 +106,23 @@ _efl_animation_group_efl_animation_final_state_keep_set(Eo *eo_obj, efl_animation_final_state_keep_set(efl_super(eo_obj, MY_CLASS), keep_final_state); } +EOLIAN static void +_efl_animation_group_efl_animation_interpolator_set(Eo *eo_obj, + Efl_Animation_Group_Data *pd, + Efl_Interpolator *interpolator) +{ + EFL_ANIMATION_GROUP_CHECK_OR_RETURN(eo_obj); + + Eina_List *l; + Efl_Animation *anim; + EINA_LIST_FOREACH(pd->animations, l, anim) + { + efl_animation_interpolator_set(anim, interpolator); + } + + efl_animation_interpolator_set(efl_super(eo_obj, MY_CLASS), interpolator); +} + EOLIAN static Efl_Object * _efl_animation_group_efl_object_constructor(Eo *eo_obj, Efl_Animation_Group_Data *pd) diff --git a/src/lib/evas/canvas/efl_animation_group.eo b/src/lib/evas/canvas/efl_animation_group.eo index c287490907..a431e39737 100644 --- a/src/lib/evas/canvas/efl_animation_group.eo +++ b/src/lib/evas/canvas/efl_animation_group.eo @@ -28,5 +28,6 @@ abstract Efl.Animation.Group (Efl.Animation) Efl.Animation.target { set; } Efl.Animation.duration { set; } Efl.Animation.final_state_keep { set; } + Efl.Animation.interpolator { set; } } } diff --git a/src/lib/evas/canvas/efl_animation_group_parallel.c b/src/lib/evas/canvas/efl_animation_group_parallel.c index 36a2e0653b..1a0bb460ab 100644 --- a/src/lib/evas/canvas/efl_animation_group_parallel.c +++ b/src/lib/evas/canvas/efl_animation_group_parallel.c @@ -116,6 +116,9 @@ _efl_animation_group_parallel_efl_animation_object_create(Eo *eo_obj, int repeat_count = efl_animation_repeat_count_get(eo_obj); efl_animation_object_repeat_count_set(group_anim_obj, repeat_count); + Efl_Interpolator *interpolator = efl_animation_interpolator_get(eo_obj); + efl_animation_object_interpolator_set(group_anim_obj, interpolator); + return group_anim_obj; } diff --git a/src/lib/evas/canvas/efl_animation_group_parallel_private.h b/src/lib/evas/canvas/efl_animation_group_parallel_private.h index b425a1606e..a2f00cd3dd 100644 --- a/src/lib/evas/canvas/efl_animation_group_parallel_private.h +++ b/src/lib/evas/canvas/efl_animation_group_parallel_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_GROUP_PARALLEL_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_group_private.h b/src/lib/evas/canvas/efl_animation_group_private.h index 0ce4728bf2..c107828c74 100644 --- a/src/lib/evas/canvas/efl_animation_group_private.h +++ b/src/lib/evas/canvas/efl_animation_group_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_GROUP_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_group_sequential.c b/src/lib/evas/canvas/efl_animation_group_sequential.c index f40b769fdd..5f858586fc 100644 --- a/src/lib/evas/canvas/efl_animation_group_sequential.c +++ b/src/lib/evas/canvas/efl_animation_group_sequential.c @@ -110,6 +110,9 @@ _efl_animation_group_sequential_efl_animation_object_create(Eo *eo_obj, int repeat_count = efl_animation_repeat_count_get(eo_obj); efl_animation_object_repeat_count_set(group_anim_obj, repeat_count); + Efl_Interpolator *interpolator = efl_animation_interpolator_get(eo_obj); + efl_animation_object_interpolator_set(group_anim_obj, interpolator); + return group_anim_obj; } diff --git a/src/lib/evas/canvas/efl_animation_group_sequential_private.h b/src/lib/evas/canvas/efl_animation_group_sequential_private.h index e944ffdcb0..4fe4dc08d7 100644 --- a/src/lib/evas/canvas/efl_animation_group_sequential_private.h +++ b/src/lib/evas/canvas/efl_animation_group_sequential_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_GROUP_SEQUENTIAL_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_object.c b/src/lib/evas/canvas/efl_animation_object.c index b9c88f350b..37ec4fe53c 100644 --- a/src/lib/evas/canvas/efl_animation_object.c +++ b/src/lib/evas/canvas/efl_animation_object.c @@ -170,6 +170,24 @@ _efl_animation_object_start_delay_get(Eo *eo_obj, return pd->start_delay_time; } +EOLIAN static void +_efl_animation_object_interpolator_set(Eo *eo_obj, + Efl_Animation_Object_Data *pd, + Efl_Interpolator *interpolator) +{ + EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj); + + pd->interpolator = interpolator; +} + +EOLIAN static Efl_Interpolator * +_efl_animation_object_interpolator_get(Eo *eo_obj, + Efl_Animation_Object_Data *pd) +{ + EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj, NULL); + + return pd->interpolator; +} EOLIAN static Eina_Bool _efl_animation_object_is_deleted(Eo *eo_obj, @@ -327,6 +345,13 @@ _animator_cb(void *data) efl_animation_object_target_state_reset(eo_obj); } + //Apply interpolator + if (pd->interpolator) + { + pd->progress = efl_interpolator_interpolate(pd->interpolator, + pd->progress); + } + //Reset previous animation effect before applying animation effect /* FIXME: When the target state is saved, it may not be finished to calculate * target geometry. @@ -479,6 +504,13 @@ _efl_animation_object_progress_set(Eo *eo_obj, if (!pd->is_direction_forward) pd->progress = 1.0 - pd->progress; + //Apply interpolator + if (pd->interpolator) + { + pd->progress = efl_interpolator_interpolate(pd->interpolator, + pd->progress); + } + Efl_Animation_Object_Running_Event_Info event_info; event_info.progress = progress; @@ -607,6 +639,9 @@ EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_repeat_mode_get, Efl_Animation_Ob EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_repeat_count_set, EFL_FUNC_CALL(count), int count); EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_repeat_count_get, int, 0); +EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_interpolator_set, EFL_FUNC_CALL(interpolator), Efl_Interpolator *interpolator); +EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_interpolator_get, Efl_Interpolator *, NULL); + #define EFL_ANIMATION_OBJECT_EXTRA_OPS \ EFL_OBJECT_OP_FUNC(efl_animation_object_target_set, _efl_animation_object_target_set), \ EFL_OBJECT_OP_FUNC(efl_animation_object_target_get, _efl_animation_object_target_get), \ @@ -622,7 +657,9 @@ EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_repeat_count_get, int, 0); EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_mode_set, _efl_animation_object_repeat_mode_set), \ EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_mode_get, _efl_animation_object_repeat_mode_get), \ EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_count_set, _efl_animation_object_repeat_count_set), \ - EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_count_get, _efl_animation_object_repeat_count_get) + EFL_OBJECT_OP_FUNC(efl_animation_object_repeat_count_get, _efl_animation_object_repeat_count_get), \ + EFL_OBJECT_OP_FUNC(efl_animation_object_interpolator_set, _efl_animation_object_interpolator_set), \ + EFL_OBJECT_OP_FUNC(efl_animation_object_interpolator_get, _efl_animation_object_interpolator_get) EWAPI const Efl_Event_Description _EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED = EFL_EVENT_DESCRIPTION("pre_started"); diff --git a/src/lib/evas/canvas/efl_animation_object_group.c b/src/lib/evas/canvas/efl_animation_object_group.c index df3aca148c..6c8c1b2893 100644 --- a/src/lib/evas/canvas/efl_animation_object_group.c +++ b/src/lib/evas/canvas/efl_animation_object_group.c @@ -112,6 +112,25 @@ _efl_animation_object_group_efl_animation_object_final_state_keep_set(Eo *eo_obj state_keep); } +EOLIAN static void +_efl_animation_object_group_efl_animation_object_interpolator_set(Eo *eo_obj, + Efl_Animation_Object_Group_Data *pd, + Efl_Interpolator *interpolator) +{ + EFL_ANIMATION_OBJECT_GROUP_CHECK_OR_RETURN(eo_obj); + + Eina_List *l; + Efl_Animation_Object *anim_obj; + + EINA_LIST_FOREACH(pd->anim_objs, l, anim_obj) + { + efl_animation_object_interpolator_set(anim_obj, interpolator); + } + + efl_animation_object_interpolator_set(efl_super(eo_obj, MY_CLASS), + interpolator); +} + EOLIAN static Efl_Object * _efl_animation_object_group_efl_object_constructor(Eo *eo_obj, Efl_Animation_Object_Group_Data *pd) @@ -198,6 +217,7 @@ EOAPI EFL_FUNC_BODY(efl_animation_object_group_objects_get, Eina_List *, NULL); EFL_OBJECT_OP_FUNC(efl_animation_object_group_objects_get, _efl_animation_object_group_objects_get), \ EFL_OBJECT_OP_FUNC(efl_animation_object_target_set, _efl_animation_object_group_efl_animation_object_target_set), \ EFL_OBJECT_OP_FUNC(efl_animation_object_duration_set, _efl_animation_object_group_efl_animation_object_duration_set), \ - EFL_OBJECT_OP_FUNC(efl_animation_object_final_state_keep_set, _efl_animation_object_group_efl_animation_object_final_state_keep_set) + EFL_OBJECT_OP_FUNC(efl_animation_object_final_state_keep_set, _efl_animation_object_group_efl_animation_object_final_state_keep_set), \ + EFL_OBJECT_OP_FUNC(efl_animation_object_interpolator_set, _efl_animation_object_group_efl_animation_object_interpolator_set) #include "efl_animation_object_group.eo.c" diff --git a/src/lib/evas/canvas/efl_animation_object_group_parallel.c b/src/lib/evas/canvas/efl_animation_object_group_parallel.c index 2d551bf166..6c8a9aeac0 100644 --- a/src/lib/evas/canvas/efl_animation_object_group_parallel.c +++ b/src/lib/evas/canvas/efl_animation_object_group_parallel.c @@ -244,6 +244,24 @@ _efl_animation_object_group_parallel_efl_animation_object_progress_set(Eo *eo_ob } } + //Apply interpolator + Efl_Interpolator *group_interp = + efl_animation_object_interpolator_get(eo_obj); + + /* If group interpolator exists, then the group interpolator has been + * already applied. So it is not needed to apply interpolator again. */ + if (!group_interp) + { + Efl_Interpolator *interpolator = + efl_animation_object_interpolator_get(anim_obj); + if (interpolator) + { + anim_obj_progress = + efl_interpolator_interpolate(interpolator, + anim_obj_progress); + } + } + efl_animation_object_progress_set(anim_obj, anim_obj_progress); } diff --git a/src/lib/evas/canvas/efl_animation_object_group_parallel_private.h b/src/lib/evas/canvas/efl_animation_object_group_parallel_private.h index 8ccfe5d7e8..d6119623ba 100644 --- a/src/lib/evas/canvas/efl_animation_object_group_parallel_private.h +++ b/src/lib/evas/canvas/efl_animation_object_group_parallel_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_OBJECT_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_OBJECT_GROUP_PARALLEL_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_object_group_private.h b/src/lib/evas/canvas/efl_animation_object_group_private.h index a710b462e7..52456b3f89 100644 --- a/src/lib/evas/canvas/efl_animation_object_group_private.h +++ b/src/lib/evas/canvas/efl_animation_object_group_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_OBJECT_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_OBJECT_GROUP_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_object_group_sequential.c b/src/lib/evas/canvas/efl_animation_object_group_sequential.c index c83bb8852c..1f4dd7d9dd 100644 --- a/src/lib/evas/canvas/efl_animation_object_group_sequential.c +++ b/src/lib/evas/canvas/efl_animation_object_group_sequential.c @@ -257,6 +257,24 @@ _efl_animation_object_group_sequential_efl_animation_object_progress_set(Eo *eo_ } } + //Apply interpolator + Efl_Interpolator *group_interp = + efl_animation_object_interpolator_get(eo_obj); + + /* If group interpolator exists, then the group interpolator has been + * already applied. So it is not needed to apply interpolator again. */ + if (!group_interp) + { + Efl_Interpolator *interpolator = + efl_animation_object_interpolator_get(anim_obj); + if (interpolator) + { + anim_obj_progress = + efl_interpolator_interpolate(interpolator, + anim_obj_progress); + } + } + efl_animation_object_progress_set(anim_obj, anim_obj_progress); } diff --git a/src/lib/evas/canvas/efl_animation_object_group_sequential_private.h b/src/lib/evas/canvas/efl_animation_object_group_sequential_private.h index aa6f989acf..f0bbe8f7a1 100644 --- a/src/lib/evas/canvas/efl_animation_object_group_sequential_private.h +++ b/src/lib/evas/canvas/efl_animation_object_group_sequential_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_OBJECT_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_OBJECT_GROUP_SEQUENTIAL_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_object_private.h b/src/lib/evas/canvas/efl_animation_object_private.h index 9df8b4edca..f3cbecb159 100644 --- a/src/lib/evas/canvas/efl_animation_object_private.h +++ b/src/lib/evas/canvas/efl_animation_object_private.h @@ -41,6 +41,8 @@ typedef struct _Efl_Animation_Object_Data int repeat_count; int remaining_repeat_count; + Efl_Interpolator *interpolator; + Eina_Bool auto_del : 1; Eina_Bool is_deleted : 1; Eina_Bool is_started : 1; diff --git a/src/lib/evas/canvas/efl_animation_private.h b/src/lib/evas/canvas/efl_animation_private.h index 1cd84d2a59..466bbfdcf2 100644 --- a/src/lib/evas/canvas/efl_animation_private.h +++ b/src/lib/evas/canvas/efl_animation_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) @@ -17,6 +18,8 @@ typedef struct _Efl_Animation_Data Efl_Animation_Repeat_Mode repeat_mode; int repeat_count; + Efl_Interpolator *interpolator; + Eina_Bool is_deleted : 1; Eina_Bool keep_final_state : 1; } Efl_Animation_Data; diff --git a/src/lib/evas/canvas/efl_animation_rotate.c b/src/lib/evas/canvas/efl_animation_rotate.c index addfc2e9bf..53c7de7c72 100644 --- a/src/lib/evas/canvas/efl_animation_rotate.c +++ b/src/lib/evas/canvas/efl_animation_rotate.c @@ -205,6 +205,9 @@ _efl_animation_rotate_efl_animation_object_create(Eo *eo_obj, int repeat_count = efl_animation_repeat_count_get(eo_obj); efl_animation_object_repeat_count_set(anim_obj, repeat_count); + Efl_Interpolator *interpolator = efl_animation_interpolator_get(eo_obj); + efl_animation_object_interpolator_set(anim_obj, interpolator); + if (pd->use_rel_pivot) { efl_animation_object_rotate_set(anim_obj, diff --git a/src/lib/evas/canvas/efl_animation_rotate_private.h b/src/lib/evas/canvas/efl_animation_rotate_private.h index 58e7d12554..6dcda258cb 100644 --- a/src/lib/evas/canvas/efl_animation_rotate_private.h +++ b/src/lib/evas/canvas/efl_animation_rotate_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_ROTATE_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_scale.c b/src/lib/evas/canvas/efl_animation_scale.c index ed7ad3b142..11f27c211d 100644 --- a/src/lib/evas/canvas/efl_animation_scale.c +++ b/src/lib/evas/canvas/efl_animation_scale.c @@ -231,6 +231,9 @@ _efl_animation_scale_efl_animation_object_create(Eo *eo_obj, int repeat_count = efl_animation_repeat_count_get(eo_obj); efl_animation_object_repeat_count_set(anim_obj, repeat_count); + Efl_Interpolator *interpolator = efl_animation_interpolator_get(eo_obj); + efl_animation_object_interpolator_set(anim_obj, interpolator); + if (pd->use_rel_pivot) { efl_animation_object_scale_set(anim_obj, diff --git a/src/lib/evas/canvas/efl_animation_scale_private.h b/src/lib/evas/canvas/efl_animation_scale_private.h index 298097a64c..f9be19f3b7 100644 --- a/src/lib/evas/canvas/efl_animation_scale_private.h +++ b/src/lib/evas/canvas/efl_animation_scale_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_SCALE_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) diff --git a/src/lib/evas/canvas/efl_animation_translate.c b/src/lib/evas/canvas/efl_animation_translate.c index 622727697f..79cf8f131d 100644 --- a/src/lib/evas/canvas/efl_animation_translate.c +++ b/src/lib/evas/canvas/efl_animation_translate.c @@ -173,6 +173,9 @@ _efl_animation_translate_efl_animation_object_create(Eo *eo_obj, int repeat_count = efl_animation_repeat_count_get(eo_obj); efl_animation_object_repeat_count_set(anim_obj, repeat_count); + Efl_Interpolator *interpolator = efl_animation_interpolator_get(eo_obj); + efl_animation_object_interpolator_set(anim_obj, interpolator); + if (pd->use_rel_move) { efl_animation_object_translate_set(anim_obj, diff --git a/src/lib/evas/canvas/efl_animation_translate_private.h b/src/lib/evas/canvas/efl_animation_translate_private.h index 7428012e98..6b4a69c697 100644 --- a/src/lib/evas/canvas/efl_animation_translate_private.h +++ b/src/lib/evas/canvas/efl_animation_translate_private.h @@ -1,6 +1,7 @@ #define EFL_ANIMATION_PROTECTED #include "evas_common_private.h" +#include <Ecore.h> #define MY_CLASS EFL_ANIMATION_TRANSLATE_CLASS #define MY_CLASS_NAME efl_class_name_get(MY_CLASS) --