bin/elementary/test_efl_anim_group_sequential.c \
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_eio.c \
bin/elementary/test_entry.c \
bin/elementary/test_entry_anchor.c \
test_efl_anim_group_sequential.c \
test_efl_anim_event_anim.c \
test_efl_anim_pause.c \
+test_efl_anim_repeat.c \
test_application_server.c \
test_bg.c \
test_box.c \
void test_efl_anim_group_sequential(void *data, Evas_Object *obj, void *event_info);
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);
Evas_Object *win, *tbx; // TODO: refactoring
void *tt;
ADD_TEST(NULL, "Effects", "Efl Animation Group Sequential", test_efl_anim_group_sequential);
ADD_TEST(NULL, "Effects", "Efl Animation Event Animation", test_efl_anim_event_anim);
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, "Edje External", "ExtButton", test_external_button);
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+#include <Elementary.h>
+
+typedef struct _App_Data
+{
+ Efl_Animation *show_anim;
+ Efl_Animation *hide_anim;
+ Efl_Animation_Object *anim_obj;
+
+ Evas_Object *repeat_count_spin;
+
+ Eina_Bool is_btn_visible;
+} App_Data;
+
+static void
+_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
+{
+ printf("Animation has been started!\n");
+}
+
+static void
+_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
+{
+ App_Data *ad = data;
+
+ printf("Animation has been ended!\n");
+
+ elm_object_disabled_set(ad->repeat_count_spin, EINA_FALSE);
+
+ ad->anim_obj = NULL;
+}
+
+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
+_start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+ App_Data *ad = data;
+
+ if (ad->anim_obj)
+ efl_animation_object_cancel(ad->anim_obj);
+
+ ad->is_btn_visible = !(ad->is_btn_visible);
+
+ int repeat_count = elm_spinner_value_get(ad->repeat_count_spin);
+ elm_object_disabled_set(ad->repeat_count_spin, EINA_TRUE);
+
+ if (ad->is_btn_visible)
+ {
+ //Set animation repeat count
+ efl_animation_repeat_count_set(ad->show_anim, repeat_count);
+
+ //Create Animation Object from Animation
+ ad->anim_obj = efl_animation_object_create(ad->show_anim);
+ elm_object_text_set(obj, "Start Alpha Animation from 1.0 to 0.0");
+ }
+ else
+ {
+ //Set animation repeat count
+ efl_animation_repeat_count_set(ad->hide_anim, repeat_count);
+
+ //Create Animation Object from Animation
+ ad->anim_obj = efl_animation_object_create(ad->hide_anim);
+ elm_object_text_set(obj, "Start Alpha Animation from 0.0 to 1.0");
+ }
+
+ //Register callback called when animation starts
+ efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_STARTED, _anim_started_cb, NULL);
+
+ //Register callback called when animation ends
+ efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_ENDED, _anim_ended_cb, ad);
+
+ //Register callback called while animation is executed
+ efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_OBJECT_EVENT_RUNNING, _anim_running_cb, NULL);
+
+ //Let Animation Object start animation
+ efl_animation_object_start(ad->anim_obj);
+}
+
+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_repeat(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;
+
+ Evas_Object *win = elm_win_add(NULL, "Efl Animation Repeat", ELM_WIN_BASIC);
+ elm_win_title_set(win, "Efl Animation Repeat");
+ elm_win_autodel_set(win, EINA_TRUE);
+ evas_object_smart_callback_add(win, "delete,request", _win_del_cb, ad);
+
+ //Button to be animated
+ Evas_Object *btn = elm_button_add(win);
+ elm_object_text_set(btn, "Button");
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_resize(btn, 200, 200);
+ evas_object_move(btn, 100, 50);
+ evas_object_show(btn);
+
+ //Show Animation
+ Efl_Animation *show_anim = efl_add(EFL_ANIMATION_ALPHA_CLASS, NULL);
+ efl_animation_alpha_set(show_anim, 0.0, 1.0);
+ efl_animation_duration_set(show_anim, 1.0);
+ efl_animation_target_set(show_anim, btn);
+ efl_animation_final_state_keep_set(show_anim, EINA_TRUE);
+
+ //Hide Animation
+ Efl_Animation *hide_anim = efl_add(EFL_ANIMATION_ALPHA_CLASS, NULL);
+ efl_animation_alpha_set(hide_anim, 1.0, 0.0);
+ efl_animation_duration_set(hide_anim, 1.0);
+ efl_animation_target_set(hide_anim, btn);
+ efl_animation_final_state_keep_set(hide_anim, EINA_TRUE);
+
+
+ //Button to start animation
+ Evas_Object *start_btn = elm_button_add(win);
+ elm_object_text_set(start_btn, "Start Alpha Animation from 1.0 to 0.0");
+ evas_object_smart_callback_add(start_btn, "clicked", _start_btn_clicked_cb, ad);
+ evas_object_size_hint_weight_set(start_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_resize(start_btn, 200, 50);
+ evas_object_move(start_btn, 100, 300);
+ evas_object_show(start_btn);
+
+ //Spinner to set animation repeat count
+ Evas_Object *repeat_count_spin = elm_spinner_add(win);
+ elm_spinner_label_format_set(repeat_count_spin, "Repeat Count: %d");
+ elm_spinner_editable_set(repeat_count_spin, EINA_FALSE);
+ elm_spinner_min_max_set(repeat_count_spin, 0, 3);
+ elm_spinner_value_set(repeat_count_spin, 0);
+ evas_object_resize(repeat_count_spin, 200, 50);
+ evas_object_move(repeat_count_spin, 100, 350);
+ evas_object_show(repeat_count_spin);
+
+
+ //Initialize App Data
+ ad->show_anim = show_anim;
+ ad->hide_anim = hide_anim;
+ ad->anim_obj = NULL;
+ ad->repeat_count_spin = repeat_count_spin;
+ ad->is_btn_visible = EINA_TRUE;
+
+
+ evas_object_resize(win, 400, 450);
+ evas_object_show(win);
+}
#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
+
/**
* @}
*/
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_STARTED;
#define EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED (&(_EFL_ANIMATION_OBJECT_EVENT_PRE_STARTED))
/* Efl.Animation.Object END */
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)
pd->duration = 0.0;
+ pd->repeat_count = 0;
+
pd->is_deleted = EINA_FALSE;
pd->keep_final_state = EINA_FALSE;
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.]]
}
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;
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;
}
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;
}
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;
}
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;
}
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)
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;
pd->paused_time = 0.0;
+ pd->remaining_repeat_count = pd->repeat_count;
+
ecore_animator_del(pd->animator);
pd->animator = NULL;
pd->duration = 0.0;
pd->total_duration = 0.0;
+ pd->repeat_count = 0;
+
pd->auto_del = EINA_TRUE;
pd->is_deleted = EINA_FALSE;
pd->is_cancelled = EINA_FALSE;
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), \
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_STARTED =
EFL_EVENT_DESCRIPTION("pre_started");
#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);
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.
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.
{
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;
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);
#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;
#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,
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.
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.
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,
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
#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;
double total_duration;
double paused_time;
+ int repeat_count;
+ int remaining_repeat_count;
+
Eina_Bool auto_del : 1;
Eina_Bool is_deleted : 1;
Eina_Bool is_started : 1;
double duration;
double total_duration;
+ int repeat_count;
+
Eina_Bool is_deleted : 1;
Eina_Bool keep_final_state : 1;
} Efl_Animation_Data;
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,
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,
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,