diff options
author | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-08-30 20:20:15 +0900 |
---|---|---|
committer | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-09-27 11:25:42 +0900 |
commit | 6794abb06d5d526b29e1fb836a7232bf4661f274 (patch) | |
tree | 49f25464ed20439ec0f03fdd30ac336f08acb415 | |
parent | 66277bee12749f8d826f42cce167218f79ad1c8b (diff) | |
download | efl-6794abb06d5d526b29e1fb836a7232bf4661f274.tar.gz |
efl_animation: Add repeat_count property
-rw-r--r-- | src/lib/evas/Evas_Common.h | 3 | ||||
-rw-r--r-- | src/lib/evas/Evas_Internal.h | 3 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation.c | 26 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation.eo | 9 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_alpha.c | 3 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_group_parallel.c | 8 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_group_sequential.c | 11 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_object.c | 48 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_object_group_parallel.c | 124 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_object_group_parallel_private.h | 9 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_object_group_sequential.c | 122 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_object_group_sequential_private.h | 9 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_object_private.h | 3 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_private.h | 2 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_rotate.c | 3 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_scale.c | 3 | ||||
-rw-r--r-- | src/lib/evas/canvas/efl_animation_translate.c | 3 |
17 files changed, 383 insertions, 6 deletions
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 143926138f..a6de3a8797 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -3450,6 +3450,9 @@ struct _Efl_Animation_Object_Animate_Event_Info #define EFL_ANIMATION_GROUP_DURATION_NONE -1 #define EFL_ANIMATION_OBJECT_GROUP_DURATION_NONE -1 +#define EFL_ANIMATION_REPEAT_INFINITE -1 +#define EFL_ANIMATION_OBJECT_REPEAT_INFINITE -1 + /** * @} */ diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h index 3f5d79422e..e64a7db188 100644 --- a/src/lib/evas/Evas_Internal.h +++ b/src/lib/evas/Evas_Internal.h @@ -98,6 +98,9 @@ EOAPI void efl_animation_object_duration_only_set(Eo *obj, double duration); EOAPI void efl_animation_object_total_duration_set(Eo *obj, double total_duration); EOAPI double efl_animation_object_total_duration_get(const Eo *obj); +EOAPI void efl_animation_object_repeat_count_set(Eo *obj, int count); +EOAPI int efl_animation_object_repeat_count_get(const Eo *obj); + EWAPI extern const Efl_Event_Description _EFL_ANIMATION_OBJECT_EVENT_PRE_START; #define EFL_ANIMATION_OBJECT_EVENT_PRE_START (&(_EFL_ANIMATION_OBJECT_EVENT_PRE_START)) /* Efl.Animation.Object END */ diff --git a/src/lib/evas/canvas/efl_animation.c b/src/lib/evas/canvas/efl_animation.c index 22466848e7..3ab7434195 100644 --- a/src/lib/evas/canvas/efl_animation.c +++ b/src/lib/evas/canvas/efl_animation.c @@ -127,9 +127,33 @@ _efl_animation_object_create(Eo *eo_obj, Efl_Animation_Data *pd EINA_UNUSED) double total_duration = efl_animation_total_duration_get(eo_obj); efl_animation_object_total_duration_set(anim_obj, total_duration); + int repeat_count = efl_animation_repeat_count_get(eo_obj); + efl_animation_object_repeat_count_set(anim_obj, repeat_count); + return anim_obj; } +EOLIAN static void +_efl_animation_repeat_count_set(Eo *eo_obj, + Efl_Animation_Data *pd, + int count) +{ + EFL_ANIMATION_CHECK_OR_RETURN(eo_obj); + + //EFL_ANIMATION_REPEAT_INFINITE repeats animation infinitely + if ((count < 0) && (count != EFL_ANIMATION_REPEAT_INFINITE)) return; + + pd->repeat_count = count; +} + +EOLIAN static int +_efl_animation_repeat_count_get(Eo *eo_obj, Efl_Animation_Data *pd) +{ + EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, 0); + + return pd->repeat_count; +} + EOLIAN static Efl_Object * _efl_animation_efl_object_constructor(Eo *eo_obj, Efl_Animation_Data *pd) @@ -140,6 +164,8 @@ _efl_animation_efl_object_constructor(Eo *eo_obj, pd->duration = 0.0; + pd->repeat_count = 0; + 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 be899c4924..d071100dee 100644 --- a/src/lib/evas/canvas/efl_animation.eo +++ b/src/lib/evas/canvas/efl_animation.eo @@ -47,6 +47,15 @@ class Efl.Animation (Efl.Object) total_duration: double; [[Total duration value.]] } } + @property repeat_count { + set { + } + get { + } + values { + count: int; [[Repeat count. EFL_ANIMATION_REPEAT_INFINITE repeats animation infinitely.]] + } + } 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 deddafe194..763788d4bc 100644 --- a/src/lib/evas/canvas/efl_animation_alpha.c +++ b/src/lib/evas/canvas/efl_animation_alpha.c @@ -47,6 +47,9 @@ _efl_animation_alpha_efl_animation_object_create(Eo *eo_obj, double total_duration = efl_animation_total_duration_get(eo_obj); efl_animation_object_total_duration_set(anim_obj, total_duration); + int repeat_count = efl_animation_repeat_count_get(eo_obj); + efl_animation_object_repeat_count_set(anim_obj, repeat_count); + 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_group_parallel.c b/src/lib/evas/canvas/efl_animation_group_parallel.c index 93807311f8..9c02c8c907 100644 --- a/src/lib/evas/canvas/efl_animation_group_parallel.c +++ b/src/lib/evas/canvas/efl_animation_group_parallel.c @@ -58,6 +58,11 @@ _efl_animation_group_parallel_efl_animation_total_duration_get(Eo *eo_obj, EINA_LIST_FOREACH(animations, l, anim) { double child_total_duration = efl_animation_total_duration_get(anim); + + int child_repeat_count = efl_animation_repeat_count_get(anim); + if (child_repeat_count > 0) + child_total_duration *= (child_repeat_count + 1); + if (child_total_duration > total_duration) total_duration = child_total_duration; } @@ -97,6 +102,9 @@ _efl_animation_group_parallel_efl_animation_object_create(Eo *eo_obj, double total_duration = efl_animation_total_duration_get(eo_obj); efl_animation_object_total_duration_set(group_anim_obj, total_duration); + int repeat_count = efl_animation_repeat_count_get(eo_obj); + efl_animation_object_repeat_count_set(group_anim_obj, repeat_count); + return group_anim_obj; } diff --git a/src/lib/evas/canvas/efl_animation_group_sequential.c b/src/lib/evas/canvas/efl_animation_group_sequential.c index de09fcf703..b29599bd25 100644 --- a/src/lib/evas/canvas/efl_animation_group_sequential.c +++ b/src/lib/evas/canvas/efl_animation_group_sequential.c @@ -52,7 +52,13 @@ _efl_animation_group_sequential_efl_animation_total_duration_get(Eo *eo_obj, Efl_Animation *anim; EINA_LIST_FOREACH(animations, l, anim) { - total_duration += efl_animation_total_duration_get(anim); + double child_total_duration = efl_animation_total_duration_get(anim); + + int child_repeat_count = efl_animation_repeat_count_get(anim); + if (child_repeat_count > 0) + child_total_duration *= (child_repeat_count + 1); + + total_duration += child_total_duration; } return total_duration; } @@ -90,6 +96,9 @@ _efl_animation_group_sequential_efl_animation_object_create(Eo *eo_obj, double total_duration = efl_animation_total_duration_get(eo_obj); efl_animation_object_total_duration_set(group_anim_obj, total_duration); + int repeat_count = efl_animation_repeat_count_get(eo_obj); + efl_animation_object_repeat_count_set(group_anim_obj, repeat_count); + return group_anim_obj; } diff --git a/src/lib/evas/canvas/efl_animation_object.c b/src/lib/evas/canvas/efl_animation_object.c index 8c8a488715..1e77cc63d4 100644 --- a/src/lib/evas/canvas/efl_animation_object.c +++ b/src/lib/evas/canvas/efl_animation_object.c @@ -86,6 +86,28 @@ _efl_animation_object_total_duration_get(Eo *eo_obj, Efl_Animation_Object_Data * return pd->total_duration; } +EOLIAN static void +_efl_animation_object_repeat_count_set(Eo *eo_obj, + Efl_Animation_Object_Data *pd, + int count) +{ + EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj); + + //EFL_ANIMATION_OBJECT_REPEAT_INFINITE repeats animation infinitely + if ((count < 0) && (count != EFL_ANIMATION_OBJECT_REPEAT_INFINITE)) return; + + pd->repeat_count = count; +} + +EOLIAN static int +_efl_animation_object_repeat_count_get(const Eo *eo_obj, + Efl_Animation_Object_Data *pd) +{ + EFL_ANIMATION_OBJECT_CHECK_OR_RETURN((Eo *)eo_obj, 0); + + return pd->repeat_count; +} + EOLIAN static Eina_Bool _efl_animation_object_is_deleted(Eo *eo_obj, Efl_Animation_Object_Data *pd) @@ -243,6 +265,21 @@ _animator_cb(void *data) return ECORE_CALLBACK_RENEW; end: + //Repeat animation + if ((pd->repeat_count == EFL_ANIMATION_OBJECT_REPEAT_INFINITE) || + (pd->remaining_repeat_count > 0)) + { + if (pd->remaining_repeat_count > 0) + pd->remaining_repeat_count--; + + pd->time.begin = ecore_loop_time_get(); + pd->paused_time = 0.0; + + efl_animation_object_target_state_reset(eo_obj); + + return ECORE_CALLBACK_RENEW; + } + pd->is_ended = EINA_TRUE; pd->animator = NULL; @@ -271,6 +308,8 @@ _start(Eo *eo_obj, Efl_Animation_Object_Data *pd) pd->paused_time = 0.0; + pd->remaining_repeat_count = pd->repeat_count; + ecore_animator_del(pd->animator); pd->animator = NULL; @@ -388,6 +427,8 @@ _efl_animation_object_efl_object_constructor(Eo *eo_obj, pd->duration = 0.0; pd->total_duration = 0.0; + pd->repeat_count = 0; + pd->is_deleted = EINA_FALSE; pd->is_cancelled = EINA_FALSE; pd->keep_final_state = EINA_FALSE; @@ -438,6 +479,9 @@ EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_duration_only_set, EFL_FUNC_CALL( EOAPI EFL_VOID_FUNC_BODYV(efl_animation_object_total_duration_set, EFL_FUNC_CALL(total_duration), double total_duration); EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_total_duration_get, double, 0); +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); + #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), \ @@ -447,7 +491,9 @@ EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_total_duration_get, double, 0); EFL_OBJECT_OP_FUNC(efl_animation_object_duration_get, _efl_animation_object_duration_get), \ EFL_OBJECT_OP_FUNC(efl_animation_object_duration_only_set, _efl_animation_object_duration_only_set), \ EFL_OBJECT_OP_FUNC(efl_animation_object_total_duration_set, _efl_animation_object_total_duration_set), \ - EFL_OBJECT_OP_FUNC(efl_animation_object_total_duration_get, _efl_animation_object_total_duration_get) + EFL_OBJECT_OP_FUNC(efl_animation_object_total_duration_get, _efl_animation_object_total_duration_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) EWAPI const Efl_Event_Description _EFL_ANIMATION_OBJECT_EVENT_PRE_START = EFL_EVENT_DESCRIPTION("pre_start"); 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 1d2f38053e..f3eb3dcdff 100644 --- a/src/lib/evas/canvas/efl_animation_object_group_parallel.c +++ b/src/lib/evas/canvas/efl_animation_object_group_parallel.c @@ -1,8 +1,62 @@ #include "efl_animation_object_group_parallel_private.h" +/* Add member object data and append the data to the member object data list. + * The member object data contains the repeated count of the member object. + */ +static void +_member_anim_obj_data_add(Efl_Animation_Object_Group_Parallel_Data *pd, + Efl_Animation_Object *anim_obj, + int repeated_count) +{ + Member_Object_Data *member_anim_obj_data = + calloc(1, sizeof(Member_Object_Data)); + + if (!member_anim_obj_data) return; + + member_anim_obj_data->anim_obj = anim_obj; + member_anim_obj_data->repeated_count = repeated_count; + + pd->member_anim_obj_data_list = + eina_list_append(pd->member_anim_obj_data_list, member_anim_obj_data); +} + +/* Find the member object data which contains the repeated count of the member + * object. */ +static Member_Object_Data * +_member_anim_obj_data_find(Efl_Animation_Object_Group_Parallel_Data *pd, + Efl_Animation_Object *anim_obj) +{ + Eina_List *l; + Member_Object_Data *member_anim_obj_data = NULL; + EINA_LIST_FOREACH(pd->member_anim_obj_data_list, l, member_anim_obj_data) + { + if (member_anim_obj_data->anim_obj == anim_obj) + break; + } + + return member_anim_obj_data; +} + +/* Delete member object data and remove the data from the member object data + * list. + * The member object data contains the repeated count of the member object. + */ +static void +_member_anim_obj_data_del(Efl_Animation_Object_Group_Parallel_Data *pd, + Efl_Animation_Object *anim_obj) +{ + Member_Object_Data *member_anim_obj_data = _member_anim_obj_data_find(pd, anim_obj); + if (member_anim_obj_data) + { + pd->member_anim_obj_data_list = + eina_list_remove(pd->member_anim_obj_data_list, member_anim_obj_data); + free(member_anim_obj_data); + } +} + EOLIAN static void _efl_animation_object_group_parallel_efl_animation_object_group_object_add(Eo *eo_obj, - Efl_Animation_Object_Group_Parallel_Data *pd EINA_UNUSED, + Efl_Animation_Object_Group_Parallel_Data *pd, Efl_Animation_Object *anim_obj) { EFL_ANIMATION_OBJECT_GROUP_PARALLEL_CHECK_OR_RETURN(eo_obj); @@ -11,6 +65,10 @@ _efl_animation_object_group_parallel_efl_animation_object_group_object_add(Eo *e efl_animation_object_group_object_add(efl_super(eo_obj, MY_CLASS), anim_obj); + /* Add member object data and append the data to the member object data + * list. */ + _member_anim_obj_data_add(pd, anim_obj, 0); + /* Total duration is calculated in * efl_animation_object_total_duration_get() based on the current group * animation object list. @@ -31,6 +89,10 @@ _efl_animation_object_group_parallel_efl_animation_object_group_object_del(Eo *e efl_animation_object_group_object_del(efl_super(eo_obj, MY_CLASS), anim_obj); + /* Delete member object data and remove the data from the member object + * data list. */ + _member_anim_obj_data_del(pd, anim_obj); + /* Total duration is calculated in * efl_animation_object_total_duration_get() based on the current group * animation object list. @@ -56,15 +118,47 @@ _efl_animation_object_group_parallel_efl_animation_object_total_duration_get(Eo { double child_total_duration = efl_animation_object_total_duration_get(anim_obj); + + int child_repeat_count = + efl_animation_object_repeat_count_get(anim_obj); + if (child_repeat_count > 0) + child_total_duration *= (child_repeat_count + 1); + if (child_total_duration > total_duration) total_duration = child_total_duration; } return total_duration; } +//Set how many times the given object has been repeated. +static void +_repeated_count_set(Efl_Animation_Object_Group_Parallel_Data *pd, + Efl_Animation_Object *anim_obj, + int repeated_count) +{ + + Member_Object_Data *member_anim_obj_data = + _member_anim_obj_data_find(pd, anim_obj); + if (!member_anim_obj_data) return; + + member_anim_obj_data->repeated_count = repeated_count; +} + +//Get how many times the given object has been repeated. +static int +_repeated_count_get(Efl_Animation_Object_Group_Parallel_Data *pd, + Efl_Animation_Object *anim_obj) +{ + Member_Object_Data *member_anim_obj_data = + _member_anim_obj_data_find(pd, anim_obj); + if (!member_anim_obj_data) return 0; + + return member_anim_obj_data->repeated_count; +} + EOLIAN static void _efl_animation_object_group_parallel_efl_animation_object_progress_set(Eo *eo_obj, - Efl_Animation_Object_Group_Parallel_Data *pd EINA_UNUSED, + Efl_Animation_Object_Group_Parallel_Data *pd, double progress) { if ((progress < 0.0) || (progress > 1.0)) return; @@ -89,9 +183,33 @@ _efl_animation_object_group_parallel_efl_animation_object_progress_set(Eo *eo_ob anim_obj_progress = 1.0; else { - anim_obj_progress = elapsed_time / total_duration; + //If object is repeated, then recalculate progress. + int repeated_count = _repeated_count_get(pd, anim_obj); + if (repeated_count > 0) + anim_obj_progress = (elapsed_time - (total_duration * repeated_count)) / total_duration; + else + anim_obj_progress = elapsed_time / total_duration; + if (anim_obj_progress > 1.0) anim_obj_progress = 1.0; + + //Animation has been finished. + if (anim_obj_progress == 1.0) + { + /* If object is finished and it should be repeated, then + * increate the repeated count to recalculate progress. */ + int repeat_count = + efl_animation_object_repeat_count_get(anim_obj); + if (repeat_count > 0) + { + int repeated_count = _repeated_count_get(pd, anim_obj); + if (repeated_count < repeat_count) + { + repeated_count++; + _repeated_count_set(pd, anim_obj, repeated_count); + } + } + } } 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 85ab1f2dd0..8ccfe5d7e8 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 @@ -20,6 +20,15 @@ #define EFL_ANIMATION_OBJECT_GROUP_PARALLEL_DATA_GET(o, pd) \ Efl_Animation_Object_Group_Parallel_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_OBJECT_GROUP_PARALLEL_CLASS) +typedef struct _Member_Object_Data +{ + Efl_Animation_Object *anim_obj; + + int repeated_count; /* How many times object has been + * repeated. */ +} Member_Object_Data; + typedef struct _Efl_Animation_Object_Group_Parallel_Data { + Eina_List *member_anim_obj_data_list; //List of Member_Object_Data } Efl_Animation_Object_Group_Parallel_Data; 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 a0c004089e..0b8ef676be 100644 --- a/src/lib/evas/canvas/efl_animation_object_group_sequential.c +++ b/src/lib/evas/canvas/efl_animation_object_group_sequential.c @@ -1,5 +1,61 @@ #include "efl_animation_object_group_sequential_private.h" +/* Add member object data and append the data to the member object data list. + * The member object data contains the repeated count of the member object. + */ +static void +_member_anim_obj_data_add(Efl_Animation_Object_Group_Sequential_Data *pd, + Efl_Animation_Object *anim_obj, + int repeated_count) +{ + Member_Object_Data *member_anim_obj_data = + calloc(1, sizeof(Member_Object_Data)); + + if (!member_anim_obj_data) return; + + member_anim_obj_data->anim_obj = anim_obj; + member_anim_obj_data->repeated_count = repeated_count; + + pd->member_anim_obj_data_list = + eina_list_append(pd->member_anim_obj_data_list, member_anim_obj_data); +} + +/* Find the member object data which contains the repeated count of the member + * object. */ +static Member_Object_Data * +_member_anim_obj_data_find(Efl_Animation_Object_Group_Sequential_Data *pd, + Efl_Animation_Object *anim_obj) +{ + Eina_List *l; + Member_Object_Data *member_anim_obj_data = NULL; + EINA_LIST_FOREACH(pd->member_anim_obj_data_list, l, member_anim_obj_data) + { + if (member_anim_obj_data->anim_obj == anim_obj) + break; + } + + return member_anim_obj_data; +} + +/* Delete member object data and remove the data from the member object data + * list. + * The member object data contains the repeated count of the member object. + */ +static void +_member_anim_obj_data_del(Efl_Animation_Object_Group_Sequential_Data *pd, + Efl_Animation_Object *anim_obj) +{ + Member_Object_Data *member_anim_obj_data = + _member_anim_obj_data_find(pd, anim_obj); + if (member_anim_obj_data) + { + pd->member_anim_obj_data_list = + eina_list_remove(pd->member_anim_obj_data_list, + member_anim_obj_data); + free(member_anim_obj_data); + } +} + EOLIAN static void _efl_animation_object_group_sequential_efl_animation_object_group_object_add(Eo *eo_obj, Efl_Animation_Object_Group_Sequential_Data *pd EINA_UNUSED, @@ -11,6 +67,10 @@ _efl_animation_object_group_sequential_efl_animation_object_group_object_add(Eo efl_animation_object_group_object_add(efl_super(eo_obj, MY_CLASS), anim_obj); + /* Add member object data and append the data to the member object data + * list. */ + _member_anim_obj_data_add(pd, anim_obj, 0); + /* Total duration is calculated in * efl_animation_object_total_duration_get() based on the current group * animation object list. @@ -31,6 +91,10 @@ _efl_animation_object_group_sequential_efl_animation_object_group_object_del(Eo efl_animation_object_group_object_del(efl_super(eo_obj, MY_CLASS), anim_obj); + /* Delete member object data and remove the data from the member object + * data list. */ + _member_anim_obj_data_del(pd, anim_obj); + /* Total duration is calculated in * efl_animation_object_total_duration_get() based on the current group * animation object list. @@ -54,11 +118,44 @@ _efl_animation_object_group_sequential_efl_animation_object_total_duration_get(E Efl_Animation *anim_obj; EINA_LIST_FOREACH(anim_objs, l, anim_obj) { - total_duration += efl_animation_object_total_duration_get(anim_obj); + double child_total_duration = + efl_animation_object_total_duration_get(anim_obj); + + int child_repeat_count = + efl_animation_object_repeat_count_get(anim_obj); + if (child_repeat_count > 0) + child_total_duration *= (child_repeat_count + 1); + + total_duration += child_total_duration; } return total_duration; } +//Set how many times the given object has been repeated. +static void +_repeated_count_set(Efl_Animation_Object_Group_Sequential_Data *pd, + Efl_Animation_Object *anim_obj, + int repeated_count) +{ + + Member_Object_Data *member_anim_obj_data = _member_anim_obj_data_find(pd, anim_obj); + if (!member_anim_obj_data) return; + + member_anim_obj_data->repeated_count = repeated_count; +} + +//Get how many times the given object has been repeated. +static int +_repeated_count_get(Efl_Animation_Object_Group_Sequential_Data *pd, + Efl_Animation_Object *anim_obj) +{ + Member_Object_Data *member_anim_obj_data = + _member_anim_obj_data_find(pd, anim_obj); + if (!member_anim_obj_data) return 0; + + return member_anim_obj_data->repeated_count; +} + EOLIAN static void _efl_animation_object_group_sequential_efl_animation_object_progress_set(Eo *eo_obj, Efl_Animation_Object_Group_Sequential_Data *pd EINA_UNUSED, @@ -92,10 +189,33 @@ _efl_animation_object_group_sequential_efl_animation_object_progress_set(Eo *eo_ anim_obj_progress = 1.0; else { + //If object is repeated, then recalculate progress. + int repeated_count = _repeated_count_get(pd, anim_obj); + if (repeated_count > 0) + sum_prev_total_duration += (total_duration * repeated_count); + anim_obj_progress = (elapsed_time - sum_prev_total_duration) / total_duration; if (anim_obj_progress > 1.0) anim_obj_progress = 1.0; + + //Animation has been finished. + if (anim_obj_progress == 1.0) + { + /* If object is finished and it should be repeated, then + * increate the repeated count to recalculate progress. */ + int repeat_count = + efl_animation_object_repeat_count_get(anim_obj); + if (repeat_count > 0) + { + int repeated_count = _repeated_count_get(pd, anim_obj); + if (repeated_count < repeat_count) + { + repeated_count++; + _repeated_count_set(pd, anim_obj, repeated_count); + } + } + } } //Update the sum of the previous objects' total durations 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 fc68a14c0d..aa6f989acf 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 @@ -20,6 +20,15 @@ #define EFL_ANIMATION_OBJECT_GROUP_SEQUENTIAL_DATA_GET(o, pd) \ Efl_Animation_Object_Group_Sequential_Data *pd = efl_data_scope_get(o, EFL_ANIMATION_OBJECT_GROUP_SEQUENTIAL_CLASS) +typedef struct _Member_Object_Data +{ + Efl_Animation_Object *anim_obj; + + int repeated_count; /* How many times object has been + * repeated. */ +} Member_Object_Data; + typedef struct _Efl_Animation_Object_Group_Sequential_Data { + Eina_List *member_anim_obj_data_list; //List of Member_Object_Data } Efl_Animation_Object_Group_Sequential_Data; diff --git a/src/lib/evas/canvas/efl_animation_object_private.h b/src/lib/evas/canvas/efl_animation_object_private.h index df05bf622c..a708ac22c5 100644 --- a/src/lib/evas/canvas/efl_animation_object_private.h +++ b/src/lib/evas/canvas/efl_animation_object_private.h @@ -34,6 +34,9 @@ typedef struct _Efl_Animation_Object_Data double total_duration; double paused_time; + int repeat_count; + int remaining_repeat_count; + Eina_Bool is_deleted : 1; Eina_Bool is_started : 1; Eina_Bool is_cancelled : 1; diff --git a/src/lib/evas/canvas/efl_animation_private.h b/src/lib/evas/canvas/efl_animation_private.h index 0c3cea17c1..49e635c22a 100644 --- a/src/lib/evas/canvas/efl_animation_private.h +++ b/src/lib/evas/canvas/efl_animation_private.h @@ -12,6 +12,8 @@ typedef struct _Efl_Animation_Data double duration; double total_duration; + int repeat_count; + 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 2d6399f482..362464c917 100644 --- a/src/lib/evas/canvas/efl_animation_rotate.c +++ b/src/lib/evas/canvas/efl_animation_rotate.c @@ -195,6 +195,9 @@ _efl_animation_rotate_efl_animation_object_create(Eo *eo_obj, double total_duration = efl_animation_total_duration_get(eo_obj); efl_animation_object_total_duration_set(anim_obj, total_duration); + int repeat_count = efl_animation_repeat_count_get(eo_obj); + efl_animation_object_repeat_count_set(anim_obj, repeat_count); + if (pd->use_rel_pivot) { efl_animation_object_rotate_set(anim_obj, diff --git a/src/lib/evas/canvas/efl_animation_scale.c b/src/lib/evas/canvas/efl_animation_scale.c index ec04c45d3b..dad906e987 100644 --- a/src/lib/evas/canvas/efl_animation_scale.c +++ b/src/lib/evas/canvas/efl_animation_scale.c @@ -221,6 +221,9 @@ _efl_animation_scale_efl_animation_object_create(Eo *eo_obj, double total_duration = efl_animation_total_duration_get(eo_obj); efl_animation_object_total_duration_set(anim_obj, total_duration); + int repeat_count = efl_animation_repeat_count_get(eo_obj); + efl_animation_object_repeat_count_set(anim_obj, repeat_count); + if (pd->use_rel_pivot) { efl_animation_object_scale_set(anim_obj, diff --git a/src/lib/evas/canvas/efl_animation_translate.c b/src/lib/evas/canvas/efl_animation_translate.c index 1b0f0e340e..5623fb0e33 100644 --- a/src/lib/evas/canvas/efl_animation_translate.c +++ b/src/lib/evas/canvas/efl_animation_translate.c @@ -163,6 +163,9 @@ _efl_animation_translate_efl_animation_object_create(Eo *eo_obj, double total_duration = efl_animation_total_duration_get(eo_obj); efl_animation_object_total_duration_set(anim_obj, total_duration); + int repeat_count = efl_animation_repeat_count_get(eo_obj); + efl_animation_object_repeat_count_set(anim_obj, repeat_count); + if (pd->use_rel_move) { efl_animation_object_translate_set(anim_obj, |