diff options
-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_parallel.c | 58 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_group_parallel.eo | 13 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_group_parallel.c | 245 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_instance_group_parallel.eo | 13 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 2 |
8 files changed, 351 insertions, 0 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 2171b0f0d5..64e761a9c1 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -56,12 +56,14 @@ evas_eolian_pub_files = \ lib/evas/canvas/efl_animation_scale.eo \ 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_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 \ 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 \ $(NULL) evas_eolian_legacy_files = \ @@ -232,12 +234,14 @@ 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_group.c \ +lib/evas/canvas/efl_animation_group_parallel.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 \ 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 \ $(NULL) EXTRA_DIST2 += \ diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index b4190bb1b9..57d426e024 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -3363,6 +3363,13 @@ typedef Eo Efl_Animation_Group; #endif +#ifndef _EFL_ANIMATION_GROUP_PARALLEL_EO_CLASS_TYPE +#define _EFL_ANIMATION_GROUP_PARALLEL_EO_CLASS_TYPE + +typedef Eo Efl_Animation_Group_Parallel; + +#endif + #ifndef _EFL_ANIMATION_INSTANCE_EO_CLASS_TYPE #define _EFL_ANIMATION_INSTANCE_EO_CLASS_TYPE @@ -3405,6 +3412,13 @@ typedef Eo Efl_Animation_Instance_Group; #endif +#ifndef _EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_EO_CLASS_TYPE +#define _EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_EO_CLASS_TYPE + +typedef Eo Efl_Animation_Instance_Group_Parallel; + +#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 975428bb7e..fe809e93fe 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -72,12 +72,14 @@ #include "canvas/efl_animation_scale.eo.h" #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_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" #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" #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_parallel.c b/src/lib/evas/canvas/efl_animation_group_parallel.c new file mode 100644 index 0000000000..a08d73afc1 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_group_parallel.c @@ -0,0 +1,58 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#define MY_CLASS EFL_ANIMATION_GROUP_PARALLEL_CLASS +#define MY_CLASS_NAME efl_class_name_get(MY_CLASS) + +#define EFL_ANIMATION_GROUP_PARALLEL_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_PARALLEL_DATA_GET(o, pd) \ + Evas_Object_Animation_Group_Parallel_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_GROUP_PARALLEL_CLASS) + +struct _Evas_Object_Animation_Group_Parallel_Data +{ +}; + +EOLIAN static Efl_Animation_Instance * +_efl_animation_group_parallel_efl_animation_instance_create(Eo *eo_obj, + Evas_Object_Animation_Group_Parallel_Data *pd EINA_UNUSED) +{ + EFL_ANIMATION_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj, NULL); + + Efl_Animation_Instance_Group_Parallel *group_inst + = efl_add(EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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_parallel.eo.c" diff --git a/src/lib/evas/canvas/efl_animation_group_parallel.eo b/src/lib/evas/canvas/efl_animation_group_parallel.eo new file mode 100644 index 0000000000..c7d03a809d --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_group_parallel.eo @@ -0,0 +1,13 @@ +import efl_animation_types; + +class Efl.Animation.Group.Parallel (Efl.Animation.Group) +{ + [[Efl group parallel animation class]] + legacy_prefix: evas_object_animation; + data: Evas_Object_Animation_Group_Parallel_Data; + methods { + } + implements { + Efl.Animation.instance_create; + } +} diff --git a/src/lib/evas/canvas/efl_animation_instance_group_parallel.c b/src/lib/evas/canvas/efl_animation_instance_group_parallel.c new file mode 100644 index 0000000000..933990b6f7 --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_instance_group_parallel.c @@ -0,0 +1,245 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#define MY_CLASS EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CLASS +#define MY_CLASS_NAME efl_class_name_get(MY_CLASS) + +#define EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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_PARALLEL_DATA_GET(o, pd) \ + Evas_Object_Animation_Instance_Group_Parallel_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_CLASS) + +struct _Evas_Object_Animation_Instance_Group_Parallel_Data +{ + int animate_inst_count; + int animate_inst_index; + + Eina_List *finished_inst_list; + + Eina_Bool is_group_member : 1; +}; + +static void +_pre_animate_cb(void *data, const Efl_Event *event) +{ + Eo *eo_obj = data; + + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_DATA_GET(eo_obj, pd); + + if (pd->animate_inst_index == 0) + { + //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) + { + Eina_List *insts + = efl_animation_instance_group_instances_get(eo_obj); + Eina_List *l; + Efl_Animation_Instance *inst; + + //Reset previous map effect of all instances + EINA_LIST_FOREACH(insts, l, inst) + { + efl_animation_instance_map_reset(inst); + } + + 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); + } + } + } + } + + pd->animate_inst_index++; + + if (pd->animate_inst_index >= pd->animate_inst_count) + pd->animate_inst_index = 0; +} + +static void +_post_end_cb(void *data, const Efl_Event *event) +{ + Eo *eo_obj = data; + + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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->animate_inst_count--; + + if (pd->animate_inst_count == 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); + } +} + +static void +_member_post_end_cb(void *data, const Efl_Event *event) +{ + Eo *eo_obj = data; + + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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 +_start(Eo *eo_obj, Evas_Object_Animation_Instance_Group_Parallel_Data *pd) +{ + pd->animate_inst_count = 0; + pd->animate_inst_index = 0; + + efl_event_callback_call(eo_obj, EFL_ANIMATION_INSTANCE_EVENT_START, NULL); + + Eina_Bool ret = EINA_FALSE; + + Eina_List *animations = efl_animation_instance_group_instances_get(eo_obj); + Eina_List *l; + Efl_Animation *anim; + EINA_LIST_FOREACH(animations, l, anim) + { + //Data should be registered before animation starts + if (efl_animation_instance_member_start(anim)) + { + pd->animate_inst_count++; + ret = EINA_TRUE; + } + } + + return ret; +} + +EOLIAN static Eina_Bool +_efl_animation_instance_group_parallel_efl_animation_instance_start(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Parallel_Data *pd) +{ + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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_parallel_efl_animation_instance_member_start(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Parallel_Data *pd) +{ + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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_parallel_efl_animation_instance_final_state_show(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Parallel_Data *pd) +{ + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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); + } +} + +EOLIAN static void +_efl_animation_instance_group_parallel_efl_animation_instance_group_instance_add(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Parallel_Data *pd EINA_UNUSED, + Efl_Animation_Instance *instance) +{ + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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_parallel_efl_animation_instance_group_instance_del(Eo *eo_obj, + Evas_Object_Animation_Instance_Group_Parallel_Data *pd EINA_UNUSED, + Efl_Animation_Instance *instance) +{ + EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_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); +} + +/* Internal EO APIs */ + +#define EFL_ANIMATION_INSTANCE_GROUP_PARALLEL_EXTRA_OPS \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_member_start, _efl_animation_instance_group_parallel_efl_animation_instance_member_start), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_final_state_show, _efl_animation_instance_group_parallel_efl_animation_instance_final_state_show), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_group_instance_add, _efl_animation_instance_group_parallel_efl_animation_instance_group_instance_add), \ + EFL_OBJECT_OP_FUNC(efl_animation_instance_group_instance_del, _efl_animation_instance_group_parallel_efl_animation_instance_group_instance_del) + +#include "efl_animation_instance_group_parallel.eo.c" diff --git a/src/lib/evas/canvas/efl_animation_instance_group_parallel.eo b/src/lib/evas/canvas/efl_animation_instance_group_parallel.eo new file mode 100644 index 0000000000..ac213a6a0a --- /dev/null +++ b/src/lib/evas/canvas/efl_animation_instance_group_parallel.eo @@ -0,0 +1,13 @@ +import efl_animation_types; + +class Efl.Animation.Instance.Group.Parallel (Efl.Animation.Instance.Group) +{ + [[Efl group parallel animation instance class]] + legacy_prefix: evas_object_animation_instance; + data: Evas_Object_Animation_Instance_Group_Parallel_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 391ce0feec..8b13da68bd 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -113,12 +113,14 @@ typedef struct _Evas_Object_Animation_Rotate_Data Evas_Objec typedef struct _Evas_Object_Animation_Scale_Data Evas_Object_Animation_Scale_Data; 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_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_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_Data Evas_Object_Animation_Instance_Data; // 3D stuff |