diff options
author | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-07-04 11:20:26 +0900 |
---|---|---|
committer | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-08-18 12:06:01 +0900 |
commit | d5dda644ecb7179de2f9407089ee81a47f6fded8 (patch) | |
tree | db7229743af5587eb4edd71f830fb2cd4b01c979 | |
parent | a2537545031f797f2b207b8e1db6ba458e3cdad4 (diff) | |
download | efl-d5dda644ecb7179de2f9407089ee81a47f6fded8.tar.gz |
efl_animation: Add sequential group animation and instance
Efl.Animation.Group.Sequential is a class for animations started in
sequence.
Efl.Animation.Instance.Group.Sequential is a class which provides
methods for an instance of Efl.Animation.Group.Sequential.
The instances added into the sequential group animation instance start
in sequence.
-rw-r--r-- | src/Makefile_Evas.am | 4 | ||||
-rw-r--r-- | src/lib/evas/Evas_Common.h | 14 | ||||
-rw-r--r-- | src/lib/evas/Evas_Eo.h | 2 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_group_sequential.c | 58 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_group_sequential.eo | 13 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_group_sequential.c | 229 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_group_sequential.eo | 13 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 2 |
8 files changed, 335 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 64e761a9c1..f8789a9c1f 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -57,6 +57,7 @@ evas_eolian_pub_files = \ lib/evas/canvas/efl_animation_translate.eo \ lib/evas/canvas/efl_animation_group.eo \ lib/evas/canvas/efl_animation_group_parallel.eo \ + lib/evas/canvas/efl_animation_group_sequential.eo \ lib/evas/canvas/efl_animation_instance.eo \ lib/evas/canvas/efl_animation_instance_alpha.eo \ lib/evas/canvas/efl_animation_instance_rotate.eo \ @@ -64,6 +65,7 @@ evas_eolian_pub_files = \ lib/evas/canvas/efl_animation_instance_translate.eo \ lib/evas/canvas/efl_animation_instance_group.eo \ lib/evas/canvas/efl_animation_instance_group_parallel.eo \ + lib/evas/canvas/efl_animation_instance_group_sequential.eo \ $(NULL) evas_eolian_legacy_files = \ @@ -235,6 +237,7 @@ lib/evas/canvas/efl_animation_scale.c \ lib/evas/canvas/efl_animation_translate.c \ lib/evas/canvas/efl_animation_group.c \ lib/evas/canvas/efl_animation_group_parallel.c \ +lib/evas/canvas/efl_animation_group_sequential.c \ lib/evas/canvas/efl_animation_instance.c \ lib/evas/canvas/efl_animation_instance_alpha.c \ lib/evas/canvas/efl_animation_instance_rotate.c \ @@ -242,6 +245,7 @@ lib/evas/canvas/efl_animation_instance_scale.c \ lib/evas/canvas/efl_animation_instance_translate.c \ lib/evas/canvas/efl_animation_instance_group.c \ lib/evas/canvas/efl_animation_instance_group_parallel.c \ +lib/evas/canvas/efl_animation_instance_group_sequential.c \ $(NULL) EXTRA_DIST2 += \ diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 57d426e024..fca130426c 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -3370,6 +3370,13 @@ typedef Eo Efl_Animation_Group_Parallel; #endif +#ifndef _EFL_ANIMATION_GROUP_SEQUENTIAL_EO_CLASS_TYPE +#define _EFL_ANIMATION_GROUP_SEQUENTIAL_EO_CLASS_TYPE + +typedef Eo Efl_Animation_Group_Sequential; + +#endif + #ifndef _EFL_ANIMATION_INSTANCE_EO_CLASS_TYPE #define _EFL_ANIMATION_INSTANCE_EO_CLASS_TYPE @@ -3419,6 +3426,13 @@ typedef Eo Efl_Animation_Instance_Group_Parallel; #endif +#ifndef _EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_EO_CLASS_TYPE +#define _EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_EO_CLASS_TYPE + +typedef Eo Efl_Animation_Instance_Group_Sequential; + +#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 fe809e93fe..226a01e031 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -73,6 +73,7 @@ #include "canvas/efl_animation_translate.eo.h" #include "canvas/efl_animation_group.eo.h" #include "canvas/efl_animation_group_parallel.eo.h" +#include "canvas/efl_animation_group_sequential.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" @@ -80,6 +81,7 @@ #include "canvas/efl_animation_instance_translate.eo.h" #include "canvas/efl_animation_instance_group.eo.h" #include "canvas/efl_animation_instance_group_parallel.eo.h" +#include "canvas/efl_animation_instance_group_sequential.eo.h" #endif /* EFL_EO_API_SUPPORT */ #if defined(EFL_BETA_API_SUPPORT) && defined(EFL_EO_API_SUPPORT) diff --git a/src/lib/evas/canvas/efl_animation_group_sequential.c b/src/lib/evas/canvas/efl_animation_group_sequential.c new file mode 100644 index 0000000000..076310c0fb --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_group_sequential.c @@ -0,0 +1,58 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#define MY_CLASS EFL_ANIMATION_GROUP_SEQUENTIAL_CLASS +#define MY_CLASS_NAME efl_class_name_get(MY_CLASS) + +#define EFL_ANIMATION_GROUP_SEQUENTIAL_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_GROUP_SEQUENTIAL_DATA_GET(o, pd) \ + Evas_Object_Animation_Group_Sequential_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_GROUP_SEQUENTIAL_CLASS) + +struct _Evas_Object_Animation_Group_Sequential_Data +{ +}; + +EOLIAN static Efl_Animation_Instance * +_efl_animation_group_sequential_efl_animation_instance_create(Eo *eo_obj, + Evas_Object_Animation_Group_Sequential_Data *pd EINA_UNUSED) +{ + EFL_ANIMATION_GROUP_SEQUENTIAL_CHECK_OR_RETURN(eo_obj, NULL); + + Efl_Animation_Instance_Group_Sequential *group_inst + = efl_add(EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CLASS, NULL); + + Eina_List *animations = efl_animation_group_animations_get(eo_obj); + Eina_List *l; + Efl_Animation *child_anim; + Efl_Animation_Instance *child_inst; + + EINA_LIST_FOREACH(animations, l, child_anim) + { + child_inst = efl_animation_instance_create(child_anim); + efl_animation_instance_group_instance_add(group_inst, child_inst); + } + + Efl_Canvas_Object *target = efl_animation_target_get(eo_obj); + efl_animation_instance_target_set(group_inst, target); + + Eina_Bool state_keep = efl_animation_final_state_keep_get(eo_obj); + efl_animation_instance_final_state_keep_set(group_inst, state_keep); + + double duration = efl_animation_duration_get(eo_obj); + efl_animation_instance_duration_set(group_inst, duration); + + return group_inst; +} + +#include "efl_animation_group_sequential.eo.c" diff --git a/src/lib/evas/canvas/efl_animation_group_sequential.eo b/src/lib/evas/canvas/efl_animation_group_sequential.eo new file mode 100644 index 0000000000..4d6694a678 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_group_sequential.eo @@ -0,0 +1,13 @@ +import efl_animation_types; + +class Efl.Animation.Group.Sequential (Efl.Animation.Group) +{ + [[Efl group sequential animation class]] + legacy_prefix: evas_object_animation; + data: Evas_Object_Animation_Group_Sequential_Data; + methods { + } + implements { + Efl.Animation.instance_create; + } +} diff --git a/src/lib/evas/canvas/efl_animation_instance_group_sequential.c b/src/lib/evas/canvas/efl_animation_instance_group_sequential.c new file mode 100644 index 0000000000..87eeee4ca9 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_instance_group_sequential.c @@ -0,0 +1,229 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#define MY_CLASS EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CLASS +#define MY_CLASS_NAME efl_class_name_get(MY_CLASS) + +#define EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_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_GROUP_SEQUENTIAL_DATA_GET(o, pd) \ + Evas_Object_Animation_Instance_Group_Sequential_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CLASS) + +struct _Evas_Object_Animation_Instance_Group_Sequential_Data +{ + unsigned int current_index; + + Eina_List *finished_inst_list; + + Eina_Bool is_group_member : 1; +}; + +static Eina_Bool _index_animation_start(Eo *eo_obj, int index); + +static void +_pre_animate_cb(void *data, const Efl_Event *event) +{ + Eo *eo_obj = data; + + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_DATA_GET(eo_obj, pd); + + //pre animate event is supported within class only (protected event) + efl_event_callback_call(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMATE, + event->info); + + if (!pd->is_group_member) + { + efl_animation_instance_map_reset(event->object); + + if (efl_animation_instance_final_state_keep_get(eo_obj)) + { + Eina_List *l; + Efl_Animation_Instance *inst; + + EINA_LIST_FOREACH(pd->finished_inst_list, l, inst) + { + efl_animation_instance_final_state_show(inst); + } + } + } +} + +static void +_post_end_cb(void *data, const Efl_Event *event) +{ + Eo *eo_obj = data; + + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_DATA_GET(eo_obj, pd); + + //Save finished instances + if (!eina_list_data_find(pd->finished_inst_list, event->object)) + { + pd->finished_inst_list + = eina_list_append(pd->finished_inst_list, event->object); + } + + //member post end event is supported within class only (protected event) + efl_event_callback_call(eo_obj, + EFL_ANIMATION_INSTANCE_GROUP_EVENT_MEMBER_POST_END, + NULL); + + pd->current_index++; + + Eina_List *animations = efl_animation_instance_group_instances_get(eo_obj); + if (eina_list_count(animations) == pd->current_index) + { + pd->current_index = 0; + + efl_event_callback_call(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_END, NULL); + //post end event is supported within class only (protected event) + efl_event_callback_call(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_POST_END, + NULL); + return; + } + + _index_animation_start(eo_obj, pd->current_index); +} + +static void +_member_post_end_cb(void *data, const Efl_Event *event) +{ + Eo *eo_obj = data; + + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_DATA_GET(eo_obj, pd); + + //Save finished instances + if (!eina_list_data_find(pd->finished_inst_list, event->object)) + { + pd->finished_inst_list + = eina_list_append(pd->finished_inst_list, event->object); + } + + //member post end event is supported within class only (protected event) + efl_event_callback_call(eo_obj, + EFL_ANIMATION_INSTANCE_GROUP_EVENT_MEMBER_POST_END, + NULL); +} + +static Eina_Bool +_index_animation_start(Eo *eo_obj, int index) +{ + Efl_Animation_Instance *anim = + eina_list_nth(efl_animation_instance_group_instances_get(eo_obj), index); + if (!anim || efl_animation_instance_is_deleted(anim)) + return EINA_FALSE; + + return efl_animation_instance_member_start(anim); +} + +static Eina_Bool +_start(Eo *eo_obj, Evas_Object_Animation_Instance_Group_Sequential_Data *pd) +{ + pd->current_index = 0; + + efl_event_callback_call(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_START, NULL); + + return _index_animation_start(eo_obj, pd->current_index); +} + +EOLIAN static Eina_Bool +_efl_animation_instance_group_sequential_efl_animation_instance_start(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Sequential_Data *pd) +{ + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CHECK_OR_RETURN(eo_obj, EINA_FALSE); + + pd->is_group_member = EINA_FALSE; + + return _start(eo_obj, pd); +} + +EOLIAN static Eina_Bool +_efl_animation_instance_group_sequential_efl_animation_instance_member_start(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Sequential_Data *pd) +{ + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CHECK_OR_RETURN(eo_obj, EINA_FALSE); + + pd->is_group_member = EINA_TRUE; + + return _start(eo_obj, pd); +} + +EOLIAN static void +_efl_animation_instance_group_sequential_efl_animation_instance_group_instance_add(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Sequential_Data *pd EINA_UNUSED, + Efl_Animation_Instance *instance) +{ + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CHECK_OR_RETURN(eo_obj); + + if (!instance) return; + + //pre animate event is supported within class only (protected event) + efl_event_callback_add(instance, EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMATE, + _pre_animate_cb, eo_obj); + + //post end event is supported within class only (protected event) + efl_event_callback_add(instance, EFL_ANIMATION_INSTANCE_EVENT_POST_END, + _post_end_cb, eo_obj); + + //member post end event is supported within class only (protected event) + efl_event_callback_add(instance, + EFL_ANIMATION_INSTANCE_GROUP_EVENT_MEMBER_POST_END, + _member_post_end_cb, eo_obj); + + efl_animation_instance_group_instance_add(efl_super(eo_obj, MY_CLASS), instance); +} + +EOLIAN static void +_efl_animation_instance_group_sequential_efl_animation_instance_group_instance_del(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Sequential_Data *pd EINA_UNUSED, + Efl_Animation_Instance *instance) +{ + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CHECK_OR_RETURN(eo_obj); + + if (!instance) return; + + efl_event_callback_del(instance, EFL_ANIMATION_INSTANCE_EVENT_PRE_ANIMATE, + _pre_animate_cb, eo_obj); + + efl_event_callback_del(instance, EFL_ANIMATION_INSTANCE_EVENT_POST_END, + _post_end_cb, eo_obj); + + efl_event_callback_del(instance, + EFL_ANIMATION_INSTANCE_GROUP_EVENT_MEMBER_POST_END, + _member_post_end_cb, eo_obj); + + efl_animation_instance_group_instance_del(efl_super(eo_obj, MY_CLASS), instance); +} + +EOLIAN static void +_efl_animation_instance_group_sequential_efl_animation_instance_final_state_show(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Sequential_Data *pd) +{ + EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_CHECK_OR_RETURN(eo_obj); + + Eina_List *l; + Efl_Animation *inst; + EINA_LIST_FOREACH(pd->finished_inst_list, l, inst) + { + efl_animation_instance_final_state_show(inst); + } +} + +/* Internal EO APIs */ + +#define EFL_ANIMATION_INSTANCE_GROUP_SEQUENTIAL_EXTRA_OPS \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_member_start, _efl_animation_instance_group_sequential_efl_animation_instance_member_start), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_final_state_show, _efl_animation_instance_group_sequential_efl_animation_instance_final_state_show), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_group_instance_add, _efl_animation_instance_group_sequential_efl_animation_instance_group_instance_add), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_group_instance_del, _efl_animation_instance_group_sequential_efl_animation_instance_group_instance_del) + +#include "efl_animation_instance_group_sequential.eo.c" diff --git a/src/lib/evas/canvas/efl_animation_instance_group_sequential.eo b/src/lib/evas/canvas/efl_animation_instance_group_sequential.eo new file mode 100644 index 0000000000..8f680c5fba --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_instance_group_sequential.eo @@ -0,0 +1,13 @@ +import efl_animation_types; + +class Efl.Animation.Instance.Group.Sequential (Efl.Animation.Instance.Group) +{ + [[Efl group sequential animation instance class]] + legacy_prefix: evas_object_animation_instance; + data: Evas_Object_Animation_Instance_Group_Sequential_Data; + methods { + } + implements { + Efl.Animation.Instance.start; + } +} diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 8b13da68bd..9998007046 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_Translate_Data Evas_Object_Animation_Translate_Data; typedef struct _Evas_Object_Animation_Group_Data Evas_Object_Animation_Group_Data; typedef struct _Evas_Object_Animation_Group_Parallel_Data Evas_Object_Animation_Group_Parallel_Data; +typedef struct _Evas_Object_Animation_Group_Sequential_Data Evas_Object_Animation_Group_Sequential_Data; 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; @@ -121,6 +122,7 @@ typedef struct _Evas_Object_Animation_Instance_Scale_Data Evas_Objec typedef struct _Evas_Object_Animation_Instance_Translate_Data Evas_Object_Animation_Instance_Translate_Data; typedef struct _Evas_Object_Animation_Instance_Group_Data Evas_Object_Animation_Instance_Group_Data; typedef struct _Evas_Object_Animation_Instance_Group_Parallel_Data Evas_Object_Animation_Instance_Group_Parallel_Data; +typedef struct _Evas_Object_Animation_Instance_Group_Sequential_Data Evas_Object_Animation_Instance_Group_Sequential_Data; typedef struct _Evas_Object_Animation_Instance_Data Evas_Object_Animation_Instance_Data; // 3D stuff |