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_eio.c \
bin/elementary/test_entry.c \
bin/elementary/test_entry_anchor.c \
test_efl_anim_event_anim.c \
test_efl_anim_pause.c \
test_efl_anim_repeat.c \
+test_efl_anim_start_delay.c \
test_application_server.c \
test_bg.c \
test_box.c \
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);
Evas_Object *win, *tbx; // TODO: refactoring
void *tt;
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, "Effects", "Efl Animation Start Delay", test_efl_anim_start_delay);
//------------------------------//
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 *start_delay_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->start_delay_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);
+
+ double start_delay = elm_spinner_value_get(ad->start_delay_spin);
+ elm_object_disabled_set(ad->start_delay_spin, EINA_TRUE);
+
+ if (ad->is_btn_visible)
+ {
+ //Set animation start delay
+ efl_animation_start_delay_set(ad->show_anim, start_delay);
+
+ //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 start delay
+ efl_animation_start_delay_set(ad->hide_anim, start_delay);
+
+ //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_start_delay(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 Start Delay", ELM_WIN_BASIC);
+ elm_win_title_set(win, "Efl Animation Start Delay");
+ 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 start delay
+ Evas_Object *start_delay_spin = elm_spinner_add(win);
+ elm_spinner_label_format_set(start_delay_spin, "Start Delay: %.1f second");
+ elm_spinner_editable_set(start_delay_spin, EINA_FALSE);
+ elm_spinner_min_max_set(start_delay_spin, 0.0, 10.0);
+ elm_spinner_step_set(start_delay_spin, 0.5);
+ elm_spinner_value_set(start_delay_spin, 0.0);
+ evas_object_resize(start_delay_spin, 200, 50);
+ evas_object_move(start_delay_spin, 100, 350);
+ evas_object_show(start_delay_spin);
+
+
+ //Initialize App Data
+ ad->show_anim = show_anim;
+ ad->hide_anim = hide_anim;
+ ad->anim_obj = NULL;
+ ad->start_delay_spin = start_delay_spin;
+ ad->is_btn_visible = EINA_TRUE;
+
+
+ evas_object_resize(win, 400, 450);
+ evas_object_show(win);
+}
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_start_delay_set(Eo *obj, double delay_time);
+EOAPI double efl_animation_object_start_delay_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);
return pd->repeat_count;
}
+EOLIAN static void
+_efl_animation_start_delay_set(Eo *eo_obj,
+ Efl_Animation_Data *pd,
+ double delay_time)
+{
+ EFL_ANIMATION_CHECK_OR_RETURN(eo_obj);
+
+ if (delay_time < 0.0) return;
+
+ pd->start_delay_time = delay_time;
+}
+
+EOLIAN static double
+_efl_animation_start_delay_get(Eo *eo_obj,
+ Efl_Animation_Data *pd)
+{
+ EFL_ANIMATION_CHECK_OR_RETURN(eo_obj, 0.0);
+
+ return pd->start_delay_time;
+}
+
EOLIAN static Efl_Object *
_efl_animation_efl_object_constructor(Eo *eo_obj,
Efl_Animation_Data *pd)
pd->duration = 0.0;
+ pd->start_delay_time = 0.0;
+
pd->repeat_count = 0;
pd->is_deleted = EINA_FALSE;
count: int; [[Repeat count. EFL_ANIMATION_REPEAT_INFINITE repeats animation infinitely.]]
}
}
+ @property start_delay {
+ set {
+ }
+ get {
+ }
+ values {
+ delay_time: double; [[Delay time, in seconds, from when the animation starts until the animation is animated]]
+ }
+ }
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);
+ double start_delay_time = efl_animation_start_delay_get(eo_obj);
+ efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);
{
double child_total_duration = efl_animation_total_duration_get(anim);
+ double start_delay = efl_animation_start_delay_get(anim);
+ if (start_delay > 0.0)
+ child_total_duration += start_delay;
+
int child_repeat_count = efl_animation_repeat_count_get(anim);
if (child_repeat_count > 0)
child_total_duration *= (child_repeat_count + 1);
double total_duration = efl_animation_total_duration_get(eo_obj);
efl_animation_object_total_duration_set(group_anim_obj, total_duration);
+ double start_delay_time = efl_animation_start_delay_get(eo_obj);
+ efl_animation_object_start_delay_set(group_anim_obj, start_delay_time);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(group_anim_obj, repeat_count);
{
double child_total_duration = efl_animation_total_duration_get(anim);
+ double start_delay = efl_animation_start_delay_get(anim);
+ if (start_delay > 0.0)
+ child_total_duration += start_delay;
+
int child_repeat_count = efl_animation_repeat_count_get(anim);
if (child_repeat_count > 0)
child_total_duration *= (child_repeat_count + 1);
double total_duration = efl_animation_total_duration_get(eo_obj);
efl_animation_object_total_duration_set(group_anim_obj, total_duration);
+ double start_delay_time = efl_animation_start_delay_get(eo_obj);
+ efl_animation_object_start_delay_set(group_anim_obj, start_delay_time);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(group_anim_obj, repeat_count);
return pd->repeat_count;
}
+EOLIAN static void
+_efl_animation_object_start_delay_set(Eo *eo_obj,
+ Efl_Animation_Object_Data *pd,
+ double delay_time)
+{
+ EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj);
+
+ if (delay_time < 0.0) return;
+
+ pd->start_delay_time = delay_time;
+}
+
+EOLIAN static double
+_efl_animation_object_start_delay_get(Eo *eo_obj,
+ Efl_Animation_Object_Data *pd)
+{
+ EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj, 0.0);
+
+ return pd->start_delay_time;
+}
+
+
EOLIAN static Eina_Bool
_efl_animation_object_is_deleted(Eo *eo_obj,
Efl_Animation_Object_Data *pd)
pd->is_started = EINA_TRUE;
pd->is_cancelled = EINA_FALSE;
pd->is_ended = EINA_FALSE;
- pd->is_paused = EINA_FALSE;
pd->paused_time = 0.0;
_animator_cb(eo_obj);
}
+static Eina_Bool
+_start_delay_timer_cb(void *data)
+{
+ Eo *eo_obj = data;
+ EFL_ANIMATION_OBJECT_DATA_GET(eo_obj, pd);
+
+ pd->start_delay_timer = NULL;
+
+ _start(eo_obj, pd);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
EOLIAN static void
_efl_animation_object_start(Eo *eo_obj,
Efl_Animation_Object_Data *pd)
{
EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj);
+ if (pd->start_delay_timer) return;
+
+ if (pd->start_delay_time > 0.0)
+ {
+ pd->start_delay_timer = ecore_timer_add(pd->start_delay_time,
+ _start_delay_timer_cb, eo_obj);
+ return;
+ }
+
_start(eo_obj, pd);
}
{
EFL_ANIMATION_OBJECT_CHECK_OR_RETURN(eo_obj);
+ ecore_timer_del(pd->start_delay_timer);
+ pd->start_delay_timer = NULL;
+
pd->is_cancelled = EINA_TRUE;
pd->is_ended = EINA_TRUE;
pd->is_paused = EINA_TRUE;
+ if (pd->start_delay_timer) return;
+
ecore_animator_del(pd->animator);
pd->animator = NULL;
pd->is_paused = EINA_FALSE;
+ if (pd->start_delay_timer) return;
+
pd->paused_time += (ecore_loop_time_get() - pd->time.pause_begin);
pd->animator = ecore_animator_add(_animator_cb, eo_obj);
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_start_delay_set, EFL_FUNC_CALL(delay_time), double delay_time);
+EOAPI EFL_FUNC_BODY_CONST(efl_animation_object_start_delay_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);
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_start_delay_set, _efl_animation_object_start_delay_set), \
+ EFL_OBJECT_OP_FUNC(efl_animation_object_start_delay_get, _efl_animation_object_start_delay_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)
double child_total_duration =
efl_animation_object_total_duration_get(anim_obj);
+ double start_delay = efl_animation_object_start_delay_get(anim_obj);
+ if (start_delay > 0.0)
+ child_total_duration += start_delay;
+
int child_repeat_count =
efl_animation_object_repeat_count_get(anim_obj);
if (child_repeat_count > 0)
{
double total_duration =
efl_animation_object_total_duration_get(anim_obj);
+ double start_delay = efl_animation_object_start_delay_get(anim_obj);
double anim_obj_progress;
if (total_duration == 0.0)
anim_obj_progress = 1.0;
else
{
+ double elapsed_time_without_delay;
+
//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;
+ elapsed_time_without_delay =
+ (elapsed_time - ((total_duration + start_delay) * repeated_count)) - start_delay;
else
- anim_obj_progress = elapsed_time / total_duration;
+ elapsed_time_without_delay = elapsed_time - start_delay;
+
+ //Object should not start to wait for start delay time.
+ if (elapsed_time_without_delay < 0.0) continue;
+
+ anim_obj_progress = elapsed_time_without_delay / total_duration;
if (anim_obj_progress > 1.0)
anim_obj_progress = 1.0;
double child_total_duration =
efl_animation_object_total_duration_get(anim_obj);
+ double start_delay = efl_animation_object_start_delay_get(anim_obj);
+ if (start_delay > 0.0)
+ child_total_duration += start_delay;
+
int child_repeat_count =
efl_animation_object_repeat_count_get(anim_obj);
if (child_repeat_count > 0)
//Sum the current total duration
double total_duration =
efl_animation_object_total_duration_get(anim_obj);
+ double start_delay = efl_animation_object_start_delay_get(anim_obj);
double anim_obj_progress;
if (total_duration == 0.0)
//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);
+ sum_prev_total_duration +=
+ ((total_duration + start_delay) * repeated_count);
+
+ double elapsed_time_without_delay =
+ elapsed_time - sum_prev_total_duration - start_delay;
+
+ //Object should not start to wait for start delay time.
+ if (elapsed_time_without_delay < 0.0) break;
+
+ anim_obj_progress = elapsed_time_without_delay / total_duration;
- anim_obj_progress =
- (elapsed_time - sum_prev_total_duration) / total_duration;
if (anim_obj_progress > 1.0)
anim_obj_progress = 1.0;
}
}
- //Update the sum of the previous objects' total durations
- sum_prev_total_duration += total_duration;
+ /* Update the sum of the previous objects' total durations and start
+ * delays */
+ sum_prev_total_duration += (total_duration + start_delay);
if ((anim_obj_progress == 1.0) &&
!efl_animation_object_final_state_keep_get(anim_obj))
{
Ecore_Animator *animator;
+ Ecore_Timer *start_delay_timer;
+ double start_delay_time;
+
struct {
double begin;
double current;
double duration;
double total_duration;
+ double start_delay_time;
+
int repeat_count;
Eina_Bool is_deleted : 1;
double total_duration = efl_animation_total_duration_get(eo_obj);
efl_animation_object_total_duration_set(anim_obj, total_duration);
+ double start_delay_time = efl_animation_start_delay_get(eo_obj);
+ efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);
double total_duration = efl_animation_total_duration_get(eo_obj);
efl_animation_object_total_duration_set(anim_obj, total_duration);
+ double start_delay_time = efl_animation_start_delay_get(eo_obj);
+ efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);
double total_duration = efl_animation_total_duration_get(eo_obj);
efl_animation_object_total_duration_set(anim_obj, total_duration);
+ double start_delay_time = efl_animation_start_delay_get(eo_obj);
+ efl_animation_object_start_delay_set(anim_obj, start_delay_time);
+
int repeat_count = efl_animation_repeat_count_get(eo_obj);
efl_animation_object_repeat_count_set(anim_obj, repeat_count);