Compare commits

...

6 Commits

Author SHA1 Message Date
Marcel Hollerbach b5967a9fce remove efl_canvas_animation_player
this now all migrated to Efl.Canvas.Object.Animation

Differential Revision: https://phab.enlightenment.org/D10667
2019-11-18 14:53:03 +01:00
Marcel Hollerbach 7645bd7213 evas: migrate the vg json example
Summary:
i was not able to run the example before this commit, nor after this
commit. However, i had to migrate this, as i want to remove the player
object.
Depends on D10637

Reviewers: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10666
2019-11-18 14:53:03 +01:00
Marcel Hollerbach 1b0ccf5056 efl_ui_spotlight_manager stack: move away from player object
with this commit we move from using the player object to using the mixin
that was introduced a few commits before. The new mixin is way easier to
use here, we safe a lot of code, we also only need 1 object instead of
4. (And overall, everything just gets sooooo much more easier).

Differential Revision: https://phab.enlightenment.org/D10637
2019-11-18 14:53:03 +01:00
Marcel Hollerbach d37acfd77b elementary: move away from normal player to the new animation mixin
the mixin can handle the same things as the player. Additionally, the
usage of the mixin simplifies the animation usage alot.

Differential Revision: https://phab.enlightenment.org/D10636
2019-11-18 14:53:03 +01:00
Marcel Hollerbach b525ca1d75 introduce efl_canvas_object_animation
this brings the animation to the canvas object. All the controls of the
animation now do now require a player object anymore, you can just use
the API that is directly on the Efl.Canvas.Object object.

wip animation player replacement

Differential Revision: https://phab.enlightenment.org/D10615
2019-11-18 14:53:01 +01:00
Xavi Artigas 7fc52c6361 Unify "animated" flags
There exist several flags to indicate whether an object should be animated, with inconsistent names:
Efl.Canvas.Layout.animation: bool indicating if Edje animations should be played
Efl.Ui.Spotlight_Manager.animation_enabled: bool indicating if page transitions should be animated
Efl.Canvas.Animation_Player.animation: Efl.Canvas.Animation object

This commit unifies all of them: "animated" is now a flag, and "animation" is an object.

Note: Animation_Player is in the process of being replaced by an "animation" property in the
Efl.Canvas.Object, hence the need for non-clashing animation flags.
Differential Revision: https://phab.enlightenment.org/D10645
2019-11-18 14:40:46 +01:00
37 changed files with 934 additions and 1082 deletions

View File

@ -7,31 +7,38 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *show_anim;
Efl_Canvas_Animation *hide_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Eina_Bool is_btn_visible;
} App_Data;
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been started!\n");
}
Eo *anim = event->info;
static void
_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been ended!\n");
if (anim)
{
printf("Animation has been started!\n");
}
else
{
printf("Animation has been ended!\n");
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -42,18 +49,17 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
if (ad->is_btn_visible)
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->show_anim);
efl_canvas_object_animation_start(ad->button, ad->show_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 1.0 to 0.0");
}
else
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->hide_anim);
efl_canvas_object_animation_start(ad->button, ad->hide_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 0.0 to 1.0");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -81,6 +87,7 @@ test_efl_anim_alpha(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
evas_object_resize(btn, 200, 200);
evas_object_move(btn, 100, 50);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Show Animation
Efl_Canvas_Animation *show_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
@ -97,16 +104,8 @@ test_efl_anim_alpha(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
//Initialize App Data
ad->show_anim = show_anim;
ad->hide_anim = hide_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->is_btn_visible = EINA_TRUE;
ad->button = btn;
//Button to start animation
Evas_Object *btn2 = elm_button_add(win);

View File

@ -7,32 +7,38 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *parallel_show_anim;
Efl_Canvas_Animation *parallel_hide_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Eina_Bool is_btn_visible;
} App_Data;
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been started!\n");
}
static void
_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been ended!\n");
Eo *anim = event->info;
if (anim)
{
printf("Animation has been started!\n");
}
else
{
printf("Animation has been ended!\n");
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -43,18 +49,16 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
if (ad->is_btn_visible)
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->parallel_show_anim);
efl_canvas_object_animation_start(ad->button, ad->parallel_show_anim, 1.0, 0.0);
efl_text_set(obj, "Start Parallel Group Animation to hide button");
}
else
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->parallel_hide_anim);
efl_canvas_object_animation_start(ad->button, ad->parallel_hide_anim, 1.0, 0.0);
efl_text_set(obj, "Start Parallel Group Animation to show button");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -82,7 +86,7 @@ test_efl_anim_group_parallel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Show Animation
Efl_Canvas_Animation *show_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
@ -133,15 +137,7 @@ test_efl_anim_group_parallel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
//Initialize App Data
ad->parallel_show_anim = parallel_show_anim;
ad->parallel_hide_anim = parallel_hide_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
ad->is_btn_visible = EINA_TRUE;

View File

@ -7,31 +7,38 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *sequential_show_anim;
Efl_Canvas_Animation *sequential_hide_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Eina_Bool is_btn_visible;
} App_Data;
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been started!\n");
}
Eo *anim = event->info;
static void
_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been ended!\n");
if (anim)
{
printf("Animation has been started!\n");
}
else
{
printf("Animation has been ended!\n");
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -42,18 +49,15 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
if (ad->is_btn_visible)
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->sequential_show_anim);
efl_canvas_object_animation_start(ad->button, ad->sequential_show_anim, 1.0, 0.0);
efl_text_set(obj, "Start Sequential Group Animation to hide button");
}
else
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->sequential_hide_anim);
efl_canvas_object_animation_start(ad->button, ad->sequential_hide_anim, 1.0, 0.0);
efl_text_set(obj, "Start Sequential Group Animation to show button");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -81,6 +85,7 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
/* Animations to hide button */
@ -138,15 +143,7 @@ test_efl_anim_group_sequential(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
//Initialize App Data
ad->sequential_show_anim = sequential_show_anim;
ad->sequential_hide_anim = sequential_hide_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
ad->is_btn_visible = EINA_TRUE;

View File

@ -13,7 +13,7 @@
typedef struct _App_Data
{
Efl_Canvas_Animation *anim[INTERP_NUM];
Efl_Canvas_Animation_Player *anim_obj[INTERP_NUM];
Efl_Ui_Button *btns[INTERP_NUM];
Evas_Object *btn[INTERP_NUM];
Evas_Object *start_all_btn;
@ -68,46 +68,49 @@ _interpolator_create(int index, Evas_Object *win)
}
static void
_anim_started_cb(void *data, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
Eo *anim = event->info;
App_Data *ad = data;
printf("Animation has been started!\n");
ad->running_anim_cnt++;
}
static void
_anim_ended_cb(void *data, const Efl_Event *event)
{
App_Data *ad = data;
int i;
printf("Animation has been ended!\n");
ad->running_anim_cnt--;
for (i = 0; i < INTERP_NUM; i++)
if (anim)
{
if (ad->anim_obj[i] == event->object)
{
elm_object_disabled_set(ad->btn[i], EINA_FALSE);
break;
}
printf("Animation has been started!\n");
ad->running_anim_cnt++;
}
else
{
int i;
if (ad->running_anim_cnt == 0)
elm_object_disabled_set(ad->start_all_btn, EINA_FALSE);
printf("Animation has been ended!\n");
ad->running_anim_cnt--;
for (i = 0; i < INTERP_NUM; i++)
{
if (ad->btns[i] == event->object)
{
elm_object_disabled_set(ad->btn[i], EINA_FALSE);
break;
}
}
if (ad->running_anim_cnt == 0)
elm_object_disabled_set(ad->start_all_btn, EINA_FALSE);
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_anim_start(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -116,7 +119,7 @@ _anim_start(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
int index = (uintptr_t)evas_object_data_get(obj, "index");
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj[index], EINA_TRUE);
efl_canvas_object_animation_start(ad->btns[index], ad->anim[index], 1.0, 0.0);
elm_object_disabled_set(obj, EINA_TRUE);
elm_object_disabled_set(ad->start_all_btn, EINA_TRUE);
@ -131,7 +134,7 @@ _anim_start_all(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
for (i = 0; i < INTERP_NUM; i++)
{
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj[i], EINA_TRUE);
efl_canvas_object_animation_start(ad->btns[i], ad->anim[i], 1.0, 0.0);
elm_object_disabled_set(ad->btn[i], EINA_TRUE);
}
@ -147,9 +150,7 @@ _win_del_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
for (i = 0; i < INTERP_NUM; i++)
{
//Unregister callback called when window deletes
efl_event_callback_del(ad->anim_obj[i],
EFL_ANIMATION_PLAYER_EVENT_ENDED,
_anim_ended_cb, ad);
efl_event_callback_array_del(ad->btns[i], animation_stats_cb(), ad);
}
free(ad);
@ -211,23 +212,8 @@ test_efl_anim_interpolator(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
ad->anim[i] = anim;
//Create Animation Object from Animation
Efl_Canvas_Animation_Player *anim_obj =
efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_animation_set(efl_added, anim),
efl_animation_player_target_set(efl_added, btn));
ad->anim_obj[i] = anim_obj;
//Register callback called when animation starts
efl_event_callback_add(anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED,
_anim_started_cb, ad);
//Register callback called when animation ends
efl_event_callback_add(anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED,
_anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING,
_anim_running_cb, NULL);
ad->btns[i] = btn;
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
}
ad->running_anim_cnt = 0;

View File

@ -7,7 +7,7 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *show_anim;
Efl_Canvas_Animation *hide_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Evas_Object *pause_btn;
@ -16,60 +16,54 @@ typedef struct _App_Data
} App_Data;
static void
_anim_started_cb(void *data, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *anim = event->info;
App_Data *ad = data;
printf("Animation has been started!\n");
elm_object_disabled_set(ad->pause_btn, EINA_FALSE);
}
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->pause_btn, EINA_TRUE);
if (anim)
{
printf("Animation has been started!\n");
elm_object_disabled_set(ad->pause_btn, EINA_FALSE);
}
else
{
printf("Animation has been ended!\n");
elm_object_disabled_set(ad->pause_btn, EINA_TRUE);
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
App_Data *ad = data;
if (ad->anim_obj)
{
ad->is_anim_paused = EINA_FALSE;
elm_object_text_set(ad->pause_btn, "Pause Animation");
}
ad->is_btn_visible = !(ad->is_btn_visible);
if (ad->is_btn_visible)
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->show_anim);
efl_canvas_object_animation_start(ad->button, ad->show_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 1.0 to 0.0");
}
else
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->hide_anim);
efl_canvas_object_animation_start(ad->button, ad->hide_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 0.0 to 1.0");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -82,13 +76,13 @@ _pause_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
if (ad->is_anim_paused)
{
//Pause animation
efl_player_paused_set(ad->anim_obj, EINA_TRUE);
efl_canvas_object_animation_pause_set(ad->button, EINA_TRUE);
elm_object_text_set(obj, "Resume Animation");
}
else
{
//Resume animation
efl_player_paused_set(ad->anim_obj, EINA_FALSE);
efl_canvas_object_animation_pause_set(ad->button, EINA_FALSE);
elm_object_text_set(obj, "Pause Animation");
}
}
@ -118,6 +112,7 @@ test_efl_anim_pause(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
evas_object_resize(btn, 200, 200);
evas_object_move(btn, 100, 50);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Show Animation
Efl_Canvas_Animation *show_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
@ -152,25 +147,14 @@ test_efl_anim_pause(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
//Pause button becomes enabled only if the animation is started
elm_object_disabled_set(pause_btn, EINA_TRUE);
//Initialize App Data
ad->show_anim = show_anim;
ad->hide_anim = hide_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, ad);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
ad->pause_btn = pause_btn;
ad->is_btn_visible = EINA_TRUE;
ad->is_anim_paused = EINA_FALSE;
evas_object_resize(win, 400, 450);
evas_object_show(win);
}

View File

@ -7,7 +7,7 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *show_anim;
Efl_Canvas_Animation *hide_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Evas_Object *start_btn;
Evas_Object *repeat_count_spin;
@ -27,46 +27,50 @@ _anim_repeat_mode_get(Evas_Object *spinner)
return EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE;
}
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)
_anim_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *anim = event->info;
App_Data *ad = data;
printf("Animation has been ended!\n");
Efl_Canvas_Animation_Repeat_Mode repeat_mode = _anim_repeat_mode_get(ad->repeat_mode_spin);
if (repeat_mode == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
if (anim)
{
int repeat_count = elm_spinner_value_get(ad->repeat_count_spin);
if (repeat_count % 2 == 1)
{
ad->is_btn_visible = !(ad->is_btn_visible);
if (ad->is_btn_visible)
elm_object_text_set(ad->start_btn, "Start Alpha Animation from 1.0 to 0.0");
else
elm_object_text_set(ad->start_btn, "Start Alpha Animation from 0.0 to 1.0");
}
printf("Animation has been started!\n");
}
else
{
printf("Animation has been ended!\n");
Efl_Canvas_Animation_Repeat_Mode repeat_mode = _anim_repeat_mode_get(ad->repeat_mode_spin);
if (repeat_mode == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
{
int repeat_count = elm_spinner_value_get(ad->repeat_count_spin);
if (repeat_count % 2 == 1)
{
ad->is_btn_visible = !(ad->is_btn_visible);
if (ad->is_btn_visible)
elm_object_text_set(ad->start_btn, "Start Alpha Animation from 1.0 to 0.0");
else
elm_object_text_set(ad->start_btn, "Start Alpha Animation from 0.0 to 1.0");
}
}
elm_object_disabled_set(ad->repeat_count_spin, EINA_FALSE);
elm_object_disabled_set(ad->repeat_mode_spin, EINA_FALSE);
}
elm_object_disabled_set(ad->repeat_count_spin, EINA_FALSE);
elm_object_disabled_set(ad->repeat_mode_spin, EINA_FALSE);
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -89,7 +93,7 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
efl_animation_repeat_mode_set(ad->show_anim, repeat_mode);
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->show_anim);
efl_canvas_object_animation_start(ad->button, ad->show_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 1.0 to 0.0");
}
else
@ -101,12 +105,9 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
efl_animation_repeat_mode_set(ad->hide_anim, repeat_mode);
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->hide_anim);
efl_canvas_object_animation_start(ad->button, ad->hide_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 0.0 to 1.0");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -133,6 +134,7 @@ test_efl_anim_repeat(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
evas_object_resize(btn, 200, 200);
evas_object_move(btn, 100, 50);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Show Animation
Efl_Canvas_Animation *show_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
@ -178,24 +180,14 @@ test_efl_anim_repeat(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
evas_object_move(repeat_mode_spin, 100, 400);
evas_object_show(repeat_mode_spin);
//Initialize App Data
ad->show_anim = show_anim;
ad->hide_anim = hide_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->start_btn = start_btn;
ad->repeat_count_spin = repeat_count_spin;
ad->repeat_mode_spin = repeat_mode_spin;
ad->is_btn_visible = EINA_TRUE;
ad->button = btn;
evas_object_resize(win, 400, 500);
evas_object_show(win);

View File

@ -7,31 +7,38 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *cw_45_degrees_anim;
Efl_Canvas_Animation *ccw_45_degrees_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Eina_Bool is_btn_rotated;
} App_Data;
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been started!\n");
}
Eo *anim = event->info;
static void
_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been ended!\n");
if (anim)
{
printf("Animation has been started!\n");
}
else
{
printf("Animation has been ended!\n");
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -42,18 +49,15 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
if (ad->is_btn_rotated)
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->cw_45_degrees_anim);
efl_canvas_object_animation_start(ad->button, ad->cw_45_degrees_anim, 1.0, 0.0);
efl_text_set(obj, "Start Rotate Animation from 45 to 0 degrees");
}
else
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->ccw_45_degrees_anim);
efl_canvas_object_animation_start(ad->button, ad->ccw_45_degrees_anim, 1.0, 0.0);
efl_text_set(obj, "Start Rotate Animation from 0 to 45 degrees");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -81,6 +85,7 @@ test_efl_anim_rotate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Rotate from 0 to 45 degrees Animation
Efl_Canvas_Animation *cw_45_degrees_anim = efl_add(EFL_CANVAS_ANIMATION_ROTATE_CLASS, win);
@ -97,16 +102,7 @@ test_efl_anim_rotate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
//Initialize App Data
ad->cw_45_degrees_anim = cw_45_degrees_anim;
ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
ad->is_btn_rotated = EINA_FALSE;
//Button to start animation
@ -140,6 +136,7 @@ test_efl_anim_rotate_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Pivot to be center of the rotation
Evas_Object *pivot = elm_button_add(win);
@ -164,18 +161,8 @@ test_efl_anim_rotate_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
//Initialize App Data
ad->cw_45_degrees_anim = cw_45_degrees_anim;
ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->is_btn_rotated = EINA_FALSE;
ad->button = btn;
//Button to start animation
Evas_Object *btn2 = elm_button_add(win);
@ -208,6 +195,7 @@ test_efl_anim_rotate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Absolute coordinate (0, 0) to be center of the rotation
Evas_Object *abs_center = elm_button_add(win);
@ -232,17 +220,8 @@ test_efl_anim_rotate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS
//Initialize App Data
ad->cw_45_degrees_anim = cw_45_degrees_anim;
ad->ccw_45_degrees_anim = ccw_45_degrees_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->is_btn_rotated = EINA_FALSE;
ad->button = btn;
//Button to start animation
Evas_Object *btn2 = elm_button_add(win);

View File

@ -7,31 +7,38 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *scale_double_anim;
Efl_Canvas_Animation *scale_half_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Eina_Bool is_btn_scaled;
} App_Data;
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been started!\n");
}
Eo *anim = event->info;
static void
_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been ended!\n");
if (anim)
{
printf("Animation has been started!\n");
}
else
{
printf("Animation has been ended!\n");
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -42,18 +49,15 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
if (ad->is_btn_scaled)
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->scale_double_anim);
efl_canvas_object_animation_start(ad->button, ad->scale_double_anim, 1.0, 0.0);
efl_text_set(obj, "Start Scale Animation to zoom out");
}
else
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->scale_half_anim);
efl_canvas_object_animation_start(ad->button, ad->scale_half_anim, 1.0, 0.0);
efl_text_set(obj, "Start Scale Animation to zoom in");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -81,6 +85,7 @@ test_efl_anim_scale(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Scale Animation to zoom in
Efl_Canvas_Animation *scale_double_anim = efl_add(EFL_CANVAS_ANIMATION_SCALE_CLASS, win);
@ -97,19 +102,8 @@ test_efl_anim_scale(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
//Initialize App Data
ad->scale_double_anim = scale_double_anim;
ad->scale_half_anim = scale_half_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->is_btn_scaled = EINA_FALSE;
ad->button = btn;
//Button to start animation
Evas_Object *btn2 = elm_button_add(win);
@ -142,6 +136,7 @@ test_efl_anim_scale_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Pivot to be center of the scaling
Evas_Object *pivot = elm_button_add(win);
@ -166,15 +161,7 @@ test_efl_anim_scale_relative(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
//Initialize App Data
ad->scale_double_anim = scale_double_anim;
ad->scale_half_anim = scale_half_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
ad->is_btn_scaled = EINA_FALSE;
//Button to start animation
@ -208,6 +195,7 @@ test_efl_anim_scale_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Absolute coordinate (0, 0) to be center of the scaling
Evas_Object *abs_center = elm_button_add(win);
@ -232,15 +220,7 @@ test_efl_anim_scale_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
//Initialize App Data
ad->scale_double_anim = scale_double_anim;
ad->scale_half_anim = scale_half_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
ad->is_btn_scaled = EINA_FALSE;
//Button to start animation

View File

@ -7,7 +7,7 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *show_anim;
Efl_Canvas_Animation *hide_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Evas_Object *start_delay_spin;
@ -15,29 +15,35 @@ typedef struct _App_Data
} 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)
_anim_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Eo *anim = event->info;
App_Data *ad = data;
printf("Animation has been ended!\n");
elm_object_disabled_set(ad->start_delay_spin, EINA_FALSE);
if (anim)
{
printf("Animation has been started!\n");
elm_object_disabled_set(ad->start_delay_spin, EINA_FALSE);
}
else
{
printf("Animation has been ended!\n");
elm_object_disabled_set(ad->start_delay_spin, EINA_TRUE);
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -54,7 +60,7 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
efl_animation_start_delay_set(ad->show_anim, start_delay);
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->show_anim);
efl_canvas_object_animation_start(ad->button, ad->show_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 1.0 to 0.0");
}
else
@ -63,12 +69,9 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
efl_animation_start_delay_set(ad->hide_anim, start_delay);
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->hide_anim);
efl_canvas_object_animation_start(ad->button, ad->hide_anim, 1.0, 0.0);
efl_text_set(obj, "Start Alpha Animation from 0.0 to 1.0");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -96,6 +99,7 @@ test_efl_anim_start_delay(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
evas_object_resize(btn, 200, 200);
evas_object_move(btn, 100, 50);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Show Animation
Efl_Canvas_Animation *show_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, win);
@ -130,23 +134,12 @@ test_efl_anim_start_delay(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
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 = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, ad);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->start_delay_spin = start_delay_spin;
ad->is_btn_visible = EINA_TRUE;
ad->button = btn;
evas_object_resize(win, 400, 450);
evas_object_show(win);

View File

@ -7,31 +7,38 @@ typedef struct _App_Data
{
Efl_Canvas_Animation *translate_rb_anim;
Efl_Canvas_Animation *translate_lt_anim;
Efl_Canvas_Animation_Player *anim_obj;
Elm_Button *button;
Eina_Bool is_btn_translated;
} App_Data;
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been started!\n");
}
Eo *anim = event->info;
static void
_anim_ended_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
printf("Animation has been ended!\n");
if (anim)
{
printf("Animation has been started!\n");
}
else
{
printf("Animation has been ended!\n");
}
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
printf("Animation is running! Current progress(%lf)\n", progress);
double *progress = event->info;
printf("Animation is running! Current progress(%lf)\n", *progress);
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
static void
_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
@ -42,18 +49,15 @@ _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
if (ad->is_btn_translated)
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->translate_rb_anim);
efl_canvas_object_animation_start(ad->button, ad->translate_rb_anim, 1.0, 0.0);
efl_text_set(obj, "Start Translate Animation to left top");
}
else
{
//Create Animation Object from Animation
efl_animation_player_animation_set(ad->anim_obj, ad->translate_lt_anim);
efl_canvas_object_animation_start(ad->button, ad->translate_lt_anim, 1.0, 0.0);
efl_text_set(obj, "Start Translate Animation to right bottom");
}
//Let Animation Object start animation
efl_player_playing_set(ad->anim_obj, EINA_TRUE);
}
static void
@ -81,6 +85,7 @@ test_efl_anim_translate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, vo
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Translate Animation to right bottom relatively
Efl_Canvas_Animation *translate_rb_anim = efl_add(EFL_CANVAS_ANIMATION_TRANSLATE_CLASS, win);
@ -97,15 +102,7 @@ test_efl_anim_translate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, vo
//Initialize App Data
ad->translate_rb_anim = translate_rb_anim;
ad->translate_lt_anim = translate_lt_anim;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
ad->is_btn_translated = EINA_FALSE;
//Button to start animation
@ -139,6 +136,7 @@ test_efl_anim_translate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_U
evas_object_resize(btn, 150, 150);
evas_object_move(btn, 125, 100);
evas_object_show(btn);
efl_event_callback_array_add(btn, animation_stats_cb(), ad);
//Absolute coordinate (0, 0) for absolute translation
Evas_Object *abs_center = elm_button_add(win);
@ -164,14 +162,7 @@ test_efl_anim_translate_absolute(void *data EINA_UNUSED, Evas_Object *obj EINA_U
ad->translate_rb_anim = translate_rb_anim;
ad->translate_lt_anim = translate_lt_anim;
ad->is_btn_translated = EINA_FALSE;
ad->anim_obj = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, win,
efl_animation_player_target_set(efl_added, btn));
//Register callback called when animation starts
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb, NULL);
//Register callback called when animation ends
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, _anim_ended_cb, NULL);
//Register callback called while animation is executed
efl_event_callback_add(ad->anim_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING, _anim_running_cb, NULL);
ad->button = btn;
//Button to start animation
Evas_Object *btn2 = elm_button_add(win);

View File

@ -513,7 +513,7 @@ _animation_cb(void *data, const Efl_Event *ev)
{
Params *params = data;
efl_ui_spotlight_manager_animation_enabled_set(efl_ui_spotlight_manager_get(params->spotlight), efl_ui_selectable_selected_get(ev->object));
efl_ui_spotlight_manager_animated_transition_set(efl_ui_spotlight_manager_get(params->spotlight), efl_ui_selectable_selected_get(ev->object));
}
static void
@ -536,7 +536,7 @@ view_animation_cb(void *data,
ck = efl_add(EFL_UI_CHECK_CLASS, box);
efl_event_callback_add(ck, EFL_UI_EVENT_SELECTED_CHANGED, _animation_cb, params);
efl_ui_selectable_selected_set(ck, efl_ui_spotlight_manager_animation_enabled_get(efl_ui_spotlight_manager_get(params->spotlight)));
efl_ui_selectable_selected_set(ck, efl_ui_spotlight_manager_animated_transition_get(efl_ui_spotlight_manager_get(params->spotlight)));
efl_text_set(ck, "Animation");
efl_pack_end(box, ck);
efl_gfx_entity_visible_set(ck, 1);

View File

@ -0,0 +1,179 @@
/**
* Example of animation in efl canvas
*
* You'll need at least one engine built for it (excluding the buffer
* one). See stdout/stderr for output.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define WIDTH (640)
#define HEIGHT (480)
struct example_data
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *bg, *scale;
double current_speed;
};
static struct example_data d;
static Evas_Object * /* new rectangle to be put in the box */
_new_rectangle_add(Evas *e)
{
Efl_Canvas_Rectangle *rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, e);
efl_gfx_entity_size_set(rect, EINA_SIZE2D(10, 10));
efl_gfx_color_set(rect, 0, 255, 0, 255);
efl_gfx_entity_visible_set(rect, EINA_TRUE);
return rect;
}
/* use the following commands to interact with this example - 'h' is
* the key for help */
static void
_on_keydown(void *data EINA_UNUSED, const Efl_Event *ev)
{
if (strcmp(efl_input_key_sym_get(ev->info) , "r") == 0)
{
Efl_Canvas_Animation *animation = efl_canvas_object_animation_get(d.scale);
double current_pos = efl_canvas_object_animation_progress_get(d.scale);
d.current_speed *= -1;
efl_canvas_object_animation_start(d.scale, animation, d.current_speed, 1.0 - current_pos);
}
if (strcmp(efl_input_key_sym_get(ev->info), "p") == 0)
{
efl_canvas_object_animation_pause_set(d.scale, !efl_canvas_object_animation_pause_get(d.scale));
}
}
static void
_on_delete(Ecore_Evas *ee EINA_UNUSED)
{
ecore_main_loop_quit();
}
static void /* adjust canvas' contents on resizes */
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
efl_gfx_entity_geometry_set(d.bg, EINA_RECT(0, 0, w, h));
}
static void
print_help(void)
{
printf("evas-animation example\n Press r to reverse the animation of the red rect.\n Press p to pause the animation of the red rect.\n");
}
int
main(void)
{
if (!ecore_evas_init())
return EXIT_FAILURE;
/* this will give you a window with an Evas canvas under the first
* engine available */
d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
if (!d.ee)
goto panic;
print_help();
ecore_evas_name_class_set(d.ee, "Evas Animation example", "Evas Animation Example");
ecore_evas_callback_delete_request_set(d.ee, _on_delete);
ecore_evas_callback_resize_set(d.ee, _canvas_resize_cb);
ecore_evas_show(d.ee);
d.evas = ecore_evas_get(d.ee);
d.bg = _new_rectangle_add(d.evas);
efl_gfx_color_set(d.bg, 255, 255, 255, 255);
efl_gfx_entity_visible_set(d.bg, EINA_TRUE);
efl_canvas_object_key_focus_set(d.bg, EINA_TRUE);
efl_event_callback_add(d.bg, EFL_EVENT_KEY_DOWN, _on_keydown, NULL);
_canvas_resize_cb(d.ee);
Evas_Object *scale_rect = _new_rectangle_add(d.evas);
efl_gfx_entity_geometry_set(scale_rect, EINA_RECT(50, 50, 50, 50));
efl_canvas_object_animation_start(scale_rect,
efl_new(EFL_CANVAS_ANIMATION_SCALE_CLASS,
efl_animation_scale_set(efl_added, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(3.0, 3.0), scale_rect, EINA_VECTOR2(0.5, 0.5)),
efl_animation_start_delay_set(efl_added, 5.0),
efl_animation_duration_set(efl_added, 2.0),
efl_animation_repeat_count_set(efl_added, EFL_ANIMATION_REPEAT_INFINITE)
),
1.0, 0.0);
Evas_Object *scale_rect2 = _new_rectangle_add(d.evas);
efl_gfx_entity_geometry_set(scale_rect2, EINA_RECT(50, 200, 50, 50));
efl_canvas_object_animation_start(scale_rect2,
efl_new(EFL_CANVAS_ANIMATION_SCALE_CLASS,
efl_animation_scale_set(efl_added, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(3.0, 3.0), scale_rect2, EINA_VECTOR2(0.5, 0.5)),
efl_animation_duration_set(efl_added, 2.0),
efl_animation_repeat_count_set(efl_added, EFL_ANIMATION_REPEAT_INFINITE),
efl_animation_repeat_mode_set(efl_added, EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
),
1.0, 0.0);
Evas_Object *scale_rect3 = _new_rectangle_add(d.evas);
efl_gfx_entity_geometry_set(scale_rect3, EINA_RECT(50, 350, 50, 50));
efl_canvas_object_animation_start(scale_rect3,
efl_new(EFL_CANVAS_ANIMATION_SCALE_CLASS,
efl_animation_scale_set(efl_added, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(3.0, 3.0), scale_rect3, EINA_VECTOR2(0.5, 0.5)),
efl_animation_duration_set(efl_added, 2.0),
efl_animation_repeat_count_set(efl_added, 3),
efl_animation_repeat_mode_set(efl_added, EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
),
1.0, 0.0);
Evas_Object *scale_rect4 = _new_rectangle_add(d.evas);
efl_gfx_entity_geometry_set(scale_rect4, EINA_RECT(200, 50, 50, 50));
efl_canvas_object_animation_start(scale_rect4,
efl_new(EFL_CANVAS_ANIMATION_SCALE_CLASS,
efl_animation_scale_set(efl_added, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(3.0, 3.0), scale_rect4, EINA_VECTOR2(0.5, 0.5)),
efl_animation_duration_set(efl_added, 2.0),
efl_animation_final_state_keep_set(efl_added, EINA_TRUE)
),
1.0, 0.0);
Evas_Object *scale_rect5 = d.scale = _new_rectangle_add(d.evas);
efl_gfx_color_set(scale_rect5, 255, 0, 0, 255);
efl_gfx_entity_geometry_set(scale_rect5, EINA_RECT(200, 200, 50, 50));
efl_canvas_object_animation_start(scale_rect5,
efl_new(EFL_CANVAS_ANIMATION_SCALE_CLASS,
efl_animation_scale_set(efl_added, EINA_VECTOR2(1.0, 1.0), EINA_VECTOR2(5.0, 5.0), scale_rect5, EINA_VECTOR2(0.5, 0.5)),
efl_animation_duration_set(efl_added, 5.0),
efl_animation_repeat_count_set(efl_added, EFL_ANIMATION_REPEAT_INFINITE)
),
1.0, 0.0);
d.current_speed = 1.0;
ecore_main_loop_begin();
ecore_evas_shutdown();
return 0;
panic:
fprintf(stderr, "error: Requires at least one Evas engine built and linked"
" to ecore-evas for this example to run properly.\n");
return -2;
}

View File

@ -35,10 +35,9 @@
static Eo *gvg[5];
static void
running_cb(void *data EINA_UNUSED, const Efl_Event *event)
_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
Efl_Canvas_Animation_Player_Event_Running *event_running = event->info;
double progress = event_running->progress;
double progress = *((double*)event->info);
int i;
for (i = 0; i < 5; i++)
@ -120,11 +119,8 @@ main(void)
//Play custom animation
Eo *anim = efl_add(EFL_CANVAS_ANIMATION_CLASS, evas);
efl_animation_duration_set(anim, efl_gfx_frame_controller_frame_duration_get(vg, 0, 0));
Eo *player = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, evas);
efl_animation_player_animation_set(player, anim);
efl_event_callback_add(player, EFL_ANIMATION_PLAYER_EVENT_RUNNING, running_cb, NULL);
efl_player_playing_set(player, EINA_TRUE);
efl_event_callback_add(vg, EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _running_cb, NULL);
efl_canvas_object_animation_start(vg, anim, 1.0, 0.0);
ecore_main_loop_begin();
ecore_evas_shutdown();

View File

@ -50,6 +50,7 @@ examples = [
'evas-vg-batman',
'evas-vg-simple',
'evas-vg-json',
'efl-canvas-animation',
]
foreach example : examples

View File

@ -320,7 +320,7 @@ _efl_canvas_layout_efl_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Edje *ed,
/* FIXDOC: Verify/Expand */
EOLIAN void
_efl_canvas_layout_animation_set(Eo *obj, Edje *ed, Eina_Bool on)
_efl_canvas_layout_animated_set(Eo *obj, Edje *ed, Eina_Bool on)
{
Eina_List *l;
unsigned short i;
@ -390,7 +390,7 @@ break_prog:
}
EOLIAN Eina_Bool
_efl_canvas_layout_animation_get(const Eo *obj EINA_UNUSED, Edje *ed)
_efl_canvas_layout_animated_get(const Eo *obj EINA_UNUSED, Edje *ed)
{
if (!ed) return EINA_FALSE;
if (ed->delete_me) return EINA_FALSE;

View File

@ -10,7 +10,7 @@ class @beta Efl.Canvas.Layout extends Efl.Canvas.Group implements Efl.File, Efl.
event_c_prefix: efl_layout;
data: Edje;
methods {
@property animation {
@property animated {
[[Whether this object is animating or not.
This property indicates whether animations are stopped or not.

View File

@ -2,13 +2,13 @@
EAPI void
edje_object_animation_set(Efl_Canvas_Layout *obj, Eina_Bool on)
{
efl_canvas_layout_animation_set(obj, on);
efl_canvas_layout_animated_set(obj, on);
}
EAPI Eina_Bool
edje_object_animation_get(const Efl_Canvas_Layout *obj)
{
return efl_canvas_layout_animation_get(obj);
return efl_canvas_layout_animated_get(obj);
}
EAPI Efl_Input_Device *

View File

@ -229,7 +229,7 @@ _efl_ui_spotlight_container_efl_object_finalize(Eo *obj, Efl_Ui_Spotlight_Contai
}
else
{
efl_ui_spotlight_manager_animation_enabled_set(manager, EINA_TRUE);
efl_ui_spotlight_manager_animated_transition_set(manager, EINA_TRUE);
}
return obj;
@ -619,7 +619,7 @@ _efl_ui_spotlight_container_spotlight_manager_set(Eo *obj, Efl_Ui_Spotlight_Cont
//the api indicates that the caller passes ownership to this function, so we need to unref here
efl_unref(pd->transition);
//disable animation when not finalized yet, this help reducing the overhead of scheduling a animation that will not be displayed
efl_ui_spotlight_manager_animation_enabled_set(pd->transition, efl_finalized_get(obj));
efl_ui_spotlight_manager_animated_transition_set(pd->transition, efl_finalized_get(obj));
efl_ui_spotlight_manager_bind(pd->transition, obj,
pd->page_root);
efl_ui_spotlight_manager_size_set(pd->transition, pd->page_spec.sz);

View File

@ -55,10 +55,12 @@ abstract @beta Efl.Ui.Spotlight.Manager extends Efl.Object {
size : Eina.Size2D; [[The new size of the sub-widgets.]]
}
}
@property animation_enabled @pure_virtual {
[[This flag can be used to disable animations.]]
@property animated_transition @pure_virtual {
[[When this flag is $true the transition from the previous element to the new one will be animated whenever
@Efl.Ui.Spotlight.Container.active_element changes.]]
values {
enable : bool; [[$true if you want animations to happen, $false otherwise.]]
enable : bool; [[$true to enable animated transitions. If $false, the new active element is shown
immediately.]]
}
}
}

View File

@ -157,13 +157,13 @@ _efl_ui_spotlight_manager_plain_efl_object_destructor(Eo *obj, Efl_Ui_Spotlight_
}
EOLIAN static void
_efl_ui_spotlight_manager_plain_efl_ui_spotlight_manager_animation_enabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Plain_Data *pd, Eina_Bool animation)
_efl_ui_spotlight_manager_plain_efl_ui_spotlight_manager_animated_transition_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Plain_Data *pd, Eina_Bool animation)
{
pd->animation = animation;
}
EOLIAN static Eina_Bool
_efl_ui_spotlight_manager_plain_efl_ui_spotlight_manager_animation_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Plain_Data *pd)
_efl_ui_spotlight_manager_plain_efl_ui_spotlight_manager_animated_transition_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Plain_Data *pd)
{
return pd->animation;
}

View File

@ -6,7 +6,7 @@ class @beta Efl.Ui.Spotlight.Manager_Plain extends Efl.Ui.Spotlight.Manager
Efl.Ui.Spotlight.Manager.content_del;
Efl.Ui.Spotlight.Manager.switch_to;
Efl.Ui.Spotlight.Manager.size {set;}
Efl.Ui.Spotlight.Manager.animation_enabled {set; get;}
Efl.Ui.Spotlight.Manager.animated_transition {set; get;}
Efl.Object.destructor;
}
}

View File

@ -305,7 +305,7 @@ _efl_ui_spotlight_manager_scroll_efl_ui_spotlight_manager_size_set(Eo *obj EINA_
}
EOLIAN static void
_efl_ui_spotlight_manager_scroll_efl_ui_spotlight_manager_animation_enabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Scroll_Data *pd, Eina_Bool animation)
_efl_ui_spotlight_manager_scroll_efl_ui_spotlight_manager_animated_transition_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Scroll_Data *pd, Eina_Bool animation)
{
pd->animation = animation;
if (pd->transition.active && !animation)
@ -317,7 +317,7 @@ _efl_ui_spotlight_manager_scroll_efl_ui_spotlight_manager_animation_enabled_set(
}
EOLIAN static Eina_Bool
_efl_ui_spotlight_manager_scroll_efl_ui_spotlight_manager_animation_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Scroll_Data *pd)
_efl_ui_spotlight_manager_scroll_efl_ui_spotlight_manager_animated_transition_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Scroll_Data *pd)
{
return pd->animation;
}

View File

@ -21,7 +21,7 @@ class @beta Efl.Ui.Spotlight.Manager_Scroll extends Efl.Ui.Spotlight.Manager
Efl.Ui.Spotlight.Manager.content_del;
Efl.Ui.Spotlight.Manager.switch_to;
Efl.Ui.Spotlight.Manager.size {set;}
Efl.Ui.Spotlight.Manager.animation_enabled {set; get;}
Efl.Ui.Spotlight.Manager.animated_transition {set; get;}
Efl.Object.invalidate;
}
}

View File

@ -9,9 +9,9 @@
typedef struct {
Efl_Ui_Spotlight_Container * container;
Efl_Gfx_Entity *group;
Efl_Canvas_Animation_Player *hide, *show;
int from, to;
Efl_Gfx_Entity *content;
Efl_Canvas_Animation_Player *alpha_anim;
Efl_Gfx_Entity *content[2];
int ids[2]; //only used when in animation
Eina_Size2D page_size;
Eina_Bool animation;
} Efl_Ui_Spotlight_Manager_Stack_Data;
@ -21,29 +21,16 @@ typedef struct {
static void
_geom_sync(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Stack_Data *pd)
{
Eina_Array *array = eina_array_new(2);
Eina_Rect group_pos = efl_gfx_entity_geometry_get(pd->group);
if (efl_player_playing_get(pd->hide))
{
//we are currently in animation, sync the geometry of the targets
eina_array_push(array, efl_animation_player_target_get(pd->hide));
eina_array_push(array, efl_animation_player_target_get(pd->show));
}
else
{
//we only have our content right now, or nothing
eina_array_push(array, pd->content);
}
Eina_Rect goal = EINA_RECT_EMPTY();
goal.size = pd->page_size;
goal.y = (group_pos.y + group_pos.h/2)-pd->page_size.h/2;
goal.x = (group_pos.x + group_pos.w/2)-pd->page_size.w/2;
while (eina_array_count(array) > 0)
for (int i = 0; i < 2; ++i)
{
Efl_Gfx_Entity *subobj = eina_array_pop(array);
efl_gfx_entity_geometry_set(subobj, goal);
if (pd->content[i])
efl_gfx_entity_geometry_set(pd->content[i], goal);
}
eina_array_free(array);
}
static void
@ -66,85 +53,36 @@ _running_cb(void *data, const Efl_Event *ev EINA_UNUSED)
EINA_SAFETY_ON_NULL_RETURN(pd);
//calculate absolut position, multiply pos with 2.0 because duration is only 0.5)
absolut_position = pd->from + (pd->to - pd->from)*(efl_player_playback_position_get(pd->show)*2.0);
absolut_position = pd->ids[0] + (pd->ids[1] - pd->ids[0])*(efl_canvas_object_animation_progress_get(ev->object));
efl_event_callback_call(data, EFL_UI_SPOTLIGHT_MANAGER_EVENT_POS_UPDATE, &absolut_position);
}
static void
_anim_started_cb(void *data EINA_UNUSED, const Efl_Event *event)
_hide_object_cb(void *data, const Efl_Event *ev)
{
Efl_Canvas_Object *content;
content = efl_animation_player_target_get(event->object);
efl_gfx_entity_visible_set(content, EINA_TRUE);
if (!ev->info)
{
efl_gfx_entity_visible_set(ev->object, EINA_FALSE);
efl_event_callback_del(ev->object, ev->desc, _hide_object_cb, data);
efl_event_callback_del(ev->object, EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _running_cb, data);
}
}
static void
_hide_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Efl_Ui_Spotlight_Manager_Stack_Data *pd = efl_data_scope_safe_get(data, MY_CLASS);
Efl_Canvas_Object *content;
EINA_SAFETY_ON_NULL_RETURN(pd);
content = efl_animation_player_target_get(pd->hide);
efl_gfx_entity_visible_set(content, EINA_FALSE);
}
static void
_show_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Efl_Ui_Spotlight_Manager_Stack_Data *pd = efl_data_scope_safe_get(data, MY_CLASS);
Efl_Canvas_Object *content;
EINA_SAFETY_ON_NULL_RETURN(pd);
content = efl_animation_player_target_get(pd->show);
efl_gfx_entity_visible_set(content, EINA_TRUE);
pd->content = content;
}
EFL_CALLBACKS_ARRAY_DEFINE(_anim_show_event_cb,
{EFL_ANIMATION_PLAYER_EVENT_RUNNING, _running_cb},
{EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb},
{EFL_ANIMATION_PLAYER_EVENT_ENDED, _show_anim_ended_cb},
)
EFL_CALLBACKS_ARRAY_DEFINE(_anim_hide_event_cb,
{EFL_ANIMATION_PLAYER_EVENT_STARTED, _anim_started_cb},
{EFL_ANIMATION_PLAYER_EVENT_ENDED, _hide_anim_ended_cb},
)
EOLIAN static void
_efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_bind(Eo *obj, Efl_Ui_Spotlight_Manager_Stack_Data *pd, Efl_Ui_Spotlight_Container *spotlight, Efl_Canvas_Group *group)
{
if (spotlight && group)
{
Efl_Canvas_Animation_Alpha *show_anim, *hide_anim;
pd->container = spotlight;
pd->group = group;
efl_event_callback_add(pd->group, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _resize_cb, obj);
efl_event_callback_add(pd->group, EFL_GFX_ENTITY_EVENT_POSITION_CHANGED, _move_cb, obj);
show_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, obj);
efl_animation_alpha_set(show_anim, 0.0, 1.0);
efl_animation_duration_set(show_anim, 0.5);
efl_animation_final_state_keep_set(show_anim, EINA_TRUE);
pd->show = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, obj);
efl_animation_player_animation_set(pd->show, show_anim);
efl_player_playing_set(pd->show, EINA_FALSE);
efl_event_callback_array_add(pd->show, _anim_show_event_cb(), obj);
//Default Hide Animation
hide_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, obj);
efl_animation_alpha_set(hide_anim, 1.0, 0.0);
efl_animation_duration_set(hide_anim, 0.5);
efl_animation_final_state_keep_set(hide_anim, EINA_TRUE);
pd->hide = efl_add(EFL_CANVAS_ANIMATION_PLAYER_CLASS, obj);
efl_animation_player_animation_set(pd->hide, hide_anim);
efl_player_playing_set(pd->hide, EINA_FALSE);
efl_event_callback_array_add(pd->hide, _anim_hide_event_cb(), obj);
pd->alpha_anim = efl_add(EFL_CANVAS_ANIMATION_ALPHA_CLASS, obj);
efl_animation_alpha_set(pd->alpha_anim, 0.0, 1.0);
efl_animation_duration_set(pd->alpha_anim, 0.5);
efl_animation_final_state_keep_set(pd->alpha_anim, EINA_TRUE);
for (int i = 0; i < efl_content_count(spotlight) ; ++i) {
Efl_Gfx_Entity *elem = efl_pack_content_get(spotlight, i);
@ -153,8 +91,8 @@ _efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_bind(Eo *obj, Efl_Ui_Sp
}
if (efl_ui_spotlight_active_element_get(spotlight))
{
pd->content = efl_ui_spotlight_active_element_get(spotlight);
efl_gfx_entity_visible_set(pd->content, EINA_TRUE);
pd->content[0] = efl_ui_spotlight_active_element_get(spotlight);
efl_gfx_entity_visible_set(pd->content[0], EINA_TRUE);
_geom_sync(obj, pd);
}
}
@ -173,14 +111,6 @@ _efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_content_del(Eo *obj EIN
efl_canvas_group_member_remove(pd->container, subobj);
}
static void
_setup_anim(Efl_Animation_Player *player, Efl_Gfx_Entity *entity)
{
efl_player_playing_set(player, EINA_FALSE);
efl_animation_player_target_set(player, entity);
efl_player_playing_set(player, EINA_TRUE);
}
static Eina_Bool
is_valid(Eo *obj, int index)
{
@ -193,33 +123,35 @@ is_valid(Eo *obj, int index)
EOLIAN static void
_efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_switch_to(Eo *obj, Efl_Ui_Spotlight_Manager_Stack_Data *pd, int from, int to)
{
if (efl_pack_content_get(pd->container, to) == pd->content)
if (efl_pack_content_get(pd->container, to) == pd->content[1])
return;
if (is_valid(pd->container, to) && is_valid(pd->container, from))
{
int tmp[2] = {from, to};
for (int i = 0; i < 2; ++i)
{
pd->ids[i] = tmp[i];
pd->content[i] = efl_pack_content_get(pd->container, pd->ids[i]);
if (pd->animation)
efl_canvas_object_animation_start(pd->content[i], pd->alpha_anim, -1.0+2.0*i, 0.0);
efl_gfx_entity_visible_set(pd->content[i], EINA_TRUE);
}
if (pd->animation)
{
pd->from = from;
pd->to = to;
pd->content = NULL;
_setup_anim(pd->hide, efl_pack_content_get(pd->container, from));
_setup_anim(pd->show, efl_pack_content_get(pd->container, to));
}
else
{
efl_gfx_entity_visible_set(efl_pack_content_get(pd->container, from), EINA_FALSE);
pd->content = efl_pack_content_get(pd->container, to);
efl_gfx_entity_visible_set(pd->content, EINA_TRUE);
efl_event_callback_add(pd->content[0], EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _hide_object_cb, obj);
efl_event_callback_add(pd->content[0], EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _running_cb, obj);
}
}
else
{
double pos = to;
pd->content = efl_pack_content_get(pd->container, to);
efl_gfx_entity_visible_set(pd->content, EINA_TRUE);
pd->content[0] = efl_pack_content_get(pd->container, to);
efl_gfx_entity_visible_set(pd->content[0], EINA_TRUE);
efl_event_callback_call(obj, EFL_UI_SPOTLIGHT_MANAGER_EVENT_POS_UPDATE, &pos);
pd->content[1] = NULL;
}
_geom_sync(obj, pd);
@ -250,27 +182,19 @@ _efl_ui_spotlight_manager_stack_efl_object_invalidate(Eo *obj, Efl_Ui_Spotlight_
}
}
static void
_reset_player(Efl_Animation_Player *player, Eina_Bool vis)
{
Efl_Gfx_Entity *obj;
obj = efl_animation_player_target_get(player);
efl_player_playing_set(player, EINA_FALSE);
efl_animation_player_target_set(player, NULL);
efl_gfx_entity_visible_set(obj, vis);
}
EOLIAN static void
_efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_animation_enabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Stack_Data *pd, Eina_Bool animation)
_efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_animated_transition_set(Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Stack_Data *pd, Eina_Bool animation)
{
_reset_player(pd->hide, EINA_FALSE);
_reset_player(pd->show, EINA_TRUE);
for (int i = 0; i < 2; ++i)
{
if (pd->content[i])
efl_canvas_object_animation_stop(pd->content[i]);
}
pd->animation = animation;
}
EOLIAN static Eina_Bool
_efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_animation_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Stack_Data *pd)
_efl_ui_spotlight_manager_stack_efl_ui_spotlight_manager_animated_transition_get(const Eo *obj EINA_UNUSED, Efl_Ui_Spotlight_Manager_Stack_Data *pd)
{
return pd->animation;
}

View File

@ -6,7 +6,7 @@ class @beta Efl.Ui.Spotlight.Manager_Stack extends Efl.Ui.Spotlight.Manager
Efl.Ui.Spotlight.Manager.content_del;
Efl.Ui.Spotlight.Manager.switch_to;
Efl.Ui.Spotlight.Manager.size {set;}
Efl.Ui.Spotlight.Manager.animation_enabled {set; get;}
Efl.Ui.Spotlight.Manager.animated_transition {set; get;}
Efl.Object.invalidate;
}
}

View File

@ -69,7 +69,6 @@ extern "C" {
#include <canvas/efl_canvas_animation_group.eo.h>
#include <canvas/efl_canvas_animation_group_parallel.eo.h>
#include <canvas/efl_canvas_animation_group_sequential.eo.h>
#include <canvas/efl_canvas_animation_player.eo.h>
#include <canvas/efl_canvas_animation_rotate.eo.h>
#include <canvas/efl_canvas_animation_scale.eo.h>
#include <canvas/efl_canvas_animation_translate.eo.h>

View File

@ -223,7 +223,7 @@ struct _Efl_Canvas_Object_Animation_Event
#include "gesture/efl_gesture_events.eo.h"
#include "canvas/efl_canvas_object.eo.h"
#include "canvas/efl_canvas_object_animation.eo.h"
#include "canvas/efl_canvas_animation.eo.h"
#include "canvas/efl_canvas_animation_alpha.eo.h"
#include "canvas/efl_canvas_animation_rotate.eo.h"
@ -232,7 +232,6 @@ struct _Efl_Canvas_Object_Animation_Event
#include "canvas/efl_canvas_animation_group.eo.h"
#include "canvas/efl_canvas_animation_group_parallel.eo.h"
#include "canvas/efl_canvas_animation_group_sequential.eo.h"
#include "canvas/efl_canvas_animation_player.eo.h"
#include "canvas/efl_canvas_event_grabber.eo.h"
/**

View File

@ -1,5 +1,4 @@
import efl_canvas_animation_types;
parse efl_canvas_animation_player;
class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable
{
@ -16,7 +15,7 @@ class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable
removed. This means that if the animation does not end in the object's initial state there will be a noticeable
sudden jump.
To avoid this, animations must finish in the same state as they begin, or the object's state must be
matched to the animation's ending state once the animation finishes (using the @[Efl.Canvas.Animation_Player.ended]
matched to the animation's ending state once the animation finishes (using the @[Efl.Canvas.Object_Animation.animation,changed]
event).
]]
c_prefix: efl_animation;
@ -99,7 +98,7 @@ class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable
}
animation_apply {
[[Overwrite this method to implement your own animation subclasses.
This is used for example by @Efl.Canvas.Animation_Translate or @Efl.Canvas.Animation_Scale.
Subclasses should call their parent's @.animation_apply to get the adjusted $progress value

View File

@ -1,444 +0,0 @@
#include "efl_canvas_animation_player_private.h"
static void
_target_del_cb(void *data, const Efl_Event *event EINA_UNUSED)
{
Efl_Canvas_Animation_Player_Data *pd = data;
pd->target = NULL;
}
EOLIAN static void
_efl_canvas_animation_player_target_set(Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd,
Efl_Canvas_Object *target)
{
if (pd->target == target)
return;
if (pd->target)
efl_event_callback_del(pd->target, EFL_EVENT_DEL, _target_del_cb, pd);
efl_event_callback_add(target, EFL_EVENT_DEL, _target_del_cb, pd);
pd->target = target;
}
EOLIAN static Efl_Canvas_Object *
_efl_canvas_animation_player_target_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Player_Data *pd)
{
return pd->target;
}
EOLIAN static void
_efl_canvas_animation_player_auto_del_set(Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd,
Eina_Bool auto_del)
{
pd->auto_del = auto_del;
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_auto_del_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd)
{
return pd->auto_del;
}
EOLIAN static void
_efl_canvas_animation_player_animation_set(Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd,
Efl_Canvas_Animation *anim)
{
if (anim == pd->animation)
return;
if (!efl_isa(anim, EFL_CANVAS_ANIMATION_CLASS))
{
ERR("Passed argument [%p]:[%s] is not an Efl.Animation",
anim, efl_class_name_get(efl_class_get(anim)));
return;
}
if (pd->animation)
{
efl_player_playing_set(eo_obj, EINA_FALSE);
efl_unref(pd->animation);
}
pd->animation = anim;
efl_ref(pd->animation);
}
EOLIAN static Efl_Canvas_Animation *
_efl_canvas_animation_player_animation_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd)
{
return pd->animation;
}
static Eina_Bool
_animator_cb(void *data)
{
Eo *eo_obj = data;
EFL_ANIMATION_PLAYER_DATA_GET(eo_obj, pd);
EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
double duration, elapsed_time, vector;
if (efl_playable_seekable_get(eo_obj))
{
pd->time.current = ecore_loop_time_get();
duration = efl_animation_duration_get(anim);
elapsed_time = pd->time.current - pd->time.prev;
vector = elapsed_time / duration;
/* When animation player starts, _animator_cb() is called immediately so
* both elapsed time and progress are 0.0.
* Since it is the beginning of the animation if progress is 0.0, the
* following codes for animation should be executed. */
if ((vector <= DBL_EPSILON) && (pd->progress != 0.0))
return ECORE_CALLBACK_RENEW; // There is no update.
//TODO: check negative play_speed.
if (!pd->is_direction_forward)
vector *= -1;
pd->progress += vector;
if (pd->progress > 1.0)
pd->progress = 1.0;
else if (pd->progress < 0.0)
pd->progress = 0.0;
}
else
{
pd->progress = (double)(pd->is_direction_forward);
}
/* The previously applied map effect should be reset before applying the
* current map effect. Otherwise, the incrementally added map effects
* increase numerical error. */
efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj));
efl_animation_apply(anim, pd->progress, efl_animation_player_target_get(eo_obj));
Efl_Canvas_Animation_Player_Event_Running event_running;
event_running.progress = pd->progress;
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_RUNNING,
&event_running);
pd->time.prev = pd->time.current;
//Not end. Keep going.
if (fabs((!!(pd->is_direction_forward)) - pd->progress) > DBL_EPSILON)
return ECORE_CALLBACK_RENEW;
//Repeat animation
if ((efl_animation_repeat_count_get(anim) == EFL_ANIMATION_REPEAT_INFINITE) ||
(pd->remaining_repeat_count > 0))
{
if (pd->remaining_repeat_count > 0)
pd->remaining_repeat_count--;
if (efl_animation_repeat_mode_get(anim) == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
{
pd->is_direction_forward = !pd->is_direction_forward;
}
else
{
pd->progress = 0.0;
}
return ECORE_CALLBACK_RENEW;
}
efl_player_playing_set(eo_obj, EINA_FALSE);
pd->animator = NULL;
return ECORE_CALLBACK_CANCEL;
}
static void
_start(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd)
{
EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
pd->is_direction_forward = EINA_TRUE;
pd->remaining_repeat_count = efl_animation_repeat_count_get(anim);
ecore_animator_del(pd->animator);
pd->animator = NULL;
pd->time.prev = ecore_loop_time_get();
//pre started event is supported within class only (protected event)
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_PRE_STARTED,
NULL);
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_STARTED, NULL);
pd->animator = ecore_evas_animator_add(pd->target, _animator_cb, eo_obj);
_animator_cb(eo_obj);
}
static Eina_Bool
_start_delay_timer_cb(void *data)
{
Eo *eo_obj = data;
EFL_ANIMATION_PLAYER_DATA_GET(eo_obj, pd);
pd->start_delay_timer = NULL;
_start(eo_obj, pd);
return ECORE_CALLBACK_CANCEL;
}
static Eina_Bool
_is_final_state(Efl_Canvas_Animation *anim, double progress)
{
if (!anim) return EINA_FALSE;
if ((progress != 0.0) && (progress != 1.0)) return EINA_FALSE;
if (efl_animation_repeat_mode_get(anim) == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
{
if (efl_animation_repeat_count_get(anim) & 1)
{
if (progress == 0.0)
return EINA_TRUE;
}
else
{
if (progress == 1.0)
return EINA_TRUE;
}
}
else
{
if (progress == 1.0)
return EINA_TRUE;
}
return EINA_FALSE;
}
static void
_player_stop(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Efl_Canvas_Animation *anim)
{
//Reset the state of the target to the initial state
efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj));
if (efl_animation_final_state_keep_get(anim))
{
if (_is_final_state(anim, pd->progress))
{
/* Keep the final state only if efl_player_playing_set(EINA_FALSE) is called at
* the end of _animator_cb. */
efl_animation_apply(anim, pd->progress,
efl_animation_player_target_get(eo_obj));
}
else
{
pd->progress = 0.0;
}
}
else
{
pd->progress = 0.0;
}
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL);
if (pd->auto_del) efl_del(eo_obj);
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_player_playing_set(Eo *eo_obj, Efl_Canvas_Animation_Player_Data *pd, Eina_Bool playing)
{
double start_delay;
EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
if (!efl_playable_get(eo_obj)) return EINA_FALSE;
if ((!playing) && (!pd->is_play)) return EINA_TRUE;
if ((playing) && (pd->is_play)) return EINA_TRUE;
pd->is_play = !!playing;
if (!playing)
{
if (!pd->is_play) return EINA_TRUE;
pd->is_paused = EINA_FALSE;
_player_stop(eo_obj, pd, anim);
return EINA_TRUE;
}
//TODO: check this case is correct
if (pd->start_delay_timer) return EINA_TRUE;
pd->progress = 0.0;
start_delay = efl_animation_start_delay_get(anim);
if (start_delay > 0.0)
{
pd->start_delay_timer = ecore_timer_add(start_delay,
_start_delay_timer_cb, eo_obj);
}
else
_start(eo_obj, pd);
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_player_playing_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Player_Data *pd)
{
return pd->is_play;
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_player_paused_set(Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd,
Eina_Bool paused)
{
paused = !!paused;
/* can't pause if not playing */
if (!pd->is_play) return EINA_FALSE;
if (pd->is_paused == paused) return EINA_TRUE;
pd->is_paused = paused;
if (!paused)
{
//TODO: check this case is correct.
if (pd->start_delay_timer) return EINA_FALSE;
pd->time.prev = ecore_loop_time_get();
pd->animator = ecore_evas_animator_add(pd->target, _animator_cb, eo_obj);
_animator_cb(eo_obj);
}
else
{
ecore_timer_del(pd->start_delay_timer);
pd->start_delay_timer = NULL;
ecore_animator_del(pd->animator);
pd->animator = NULL;
}
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_player_paused_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd)
{
return pd->is_paused;
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_playable_playable_get(const Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED)
{
Efl_Canvas_Animation *anim = efl_animation_player_animation_get(eo_obj);
return efl_playable_get(anim);
}
EOLIAN static double
_efl_canvas_animation_player_efl_player_playback_position_get(const Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED)
{
//TODO: this is not correct
Efl_Canvas_Animation *anim = efl_animation_player_animation_get(eo_obj);
double length = efl_animation_duration_get(anim);
return length * efl_player_playback_progress_get(eo_obj);
}
EOLIAN static void
_efl_canvas_animation_player_efl_player_playback_position_set(Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED,
double sec)
{
//TODO: this is not correct
if (!efl_playable_seekable_get(eo_obj))
return;
EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
double length = efl_animation_duration_get(anim);
pd->progress = sec / length;
/* The previously applied map effect should be reset before applying the
* current map effect. Otherwise, the incrementally added map effects
* increase numerical error. */
efl_gfx_mapping_reset(efl_animation_player_target_get(eo_obj));
efl_animation_apply(anim, pd->progress, efl_animation_player_target_get(eo_obj));
}
EOLIAN static double
_efl_canvas_animation_player_efl_player_playback_progress_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd)
{
return pd->progress;
}
EOLIAN static void
_efl_canvas_animation_player_efl_player_playback_speed_set(Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd,
double play_speed)
{
//TODO: check reverse play case.
if (play_speed < 0)
return;
pd->play_speed = play_speed;
}
EOLIAN static double
_efl_canvas_animation_player_efl_player_playback_speed_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd)
{
return pd->play_speed;
}
EOLIAN static double
_efl_canvas_animation_player_efl_playable_length_get(const Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED)
{
EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
return efl_playable_length_get(anim);
}
EOLIAN static Eina_Bool
_efl_canvas_animation_player_efl_playable_seekable_get(const Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Player_Data *pd EINA_UNUSED)
{
EFL_ANIMATION_PLAYER_ANIMATION_GET(eo_obj, anim);
return efl_playable_seekable_get(anim);
}
EOLIAN static Efl_Object *
_efl_canvas_animation_player_efl_object_constructor(Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd)
{
eo_obj = efl_constructor(efl_super(eo_obj, MY_CLASS));
pd->time.begin = 0.0;
pd->time.current = 0.0;
pd->animation = NULL;
pd->progress = 0.0;
//pd->auto_del = EINA_TRUE;
return eo_obj;
}
EOLIAN static void
_efl_canvas_animation_player_efl_object_destructor(Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd)
{
if (pd->animator)
{
ecore_animator_del(pd->animator);
pd->animator = NULL;
//Reset the state of the target to the initial state
efl_player_playing_set(eo_obj, EINA_FALSE);
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL);
}
efl_unref(pd->animation);
efl_destructor(efl_super(eo_obj, MY_CLASS));
}
EWAPI const Efl_Event_Description _EFL_ANIMATION_PLAYER_EVENT_PRE_STARTED =
EFL_EVENT_DESCRIPTION("pre_started");
#include "efl_canvas_animation_player.eo.c"

View File

@ -1,62 +0,0 @@
class @beta Efl.Canvas.Animation_Player extends Efl.Object implements Efl.Player, Efl.Playable
{
[[Player object for playing canvas animations.
This player object can be used to play animations on a @.target canvas object.
The type of animation depends on the @.animation object.
]]
c_prefix: efl_animation_player;
methods {
@property animation {
[[The animation to play.
This animation object will be used to change the visual state of the @.target object.
]]
values {
animation: Efl.Canvas.Animation; [[An already-configured animation object.]]
}
}
@property auto_del {
[[Auto delete property]]
set {
}
get {
}
values {
auto_del: bool; [[$true to delete animation object automatically when animation is finished or animation is
cancelled, $false otherwise.]]
}
}
@property target {
[[The canvas object to apply the effects of the @.animation object on.
The @.animation object can change several properties of the $target.
You should ensure that nothing else is trying to change them too.
]]
values {
target: Efl.Canvas.Object; [[Canvas object to animate.]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Player.playing { get; set; }
Efl.Player.paused { get; set; }
Efl.Playable.playable { get; }
Efl.Player.playback_position { get; set; }
Efl.Player.playback_progress { get;}
Efl.Player.playback_speed { get; set; }
//Efl.Player.volume { get; set; }
//Efl.Player.mute { get; set; }
Efl.Playable.length { get; }
Efl.Playable.seekable { get; }
}
events {
/* FIXME: This event is similar to Efl.Canvas.Object.anim_started but with different type, might be confusing. */
started: void; [[Animation is started.]]
running: Efl.Canvas.Object_Animation_Event; [[Animation is running.]]
/* FIXME: This event is similar to Efl.Canvas.Object.anim_ended but with different type, might be confusing. */
ended: void; [[Animation is ended.]]
}
}

View File

@ -1,53 +0,0 @@
#define EFL_ANIMATION_PLAYER_PROTECTED
#include "evas_common_private.h"
#include <Ecore.h>
#define MY_CLASS EFL_CANVAS_ANIMATION_PLAYER_CLASS
#define MY_CLASS_NAME efl_class_name_get(MY_CLASS)
#if 0
typedef struct _Target_State
{
Evas_Coord x, y, w, h;
int r, g, b, a;
Evas_Map *map;
Eina_Bool enable_map : 1;
} Target_State;
#endif
typedef struct _Efl_Canvas_Animation_Player_Data
{
Ecore_Animator *animator;
Ecore_Timer *start_delay_timer;
struct {
double prev;
double begin;
double current;
double pause_begin;
} time;
Efl_Canvas_Animation *animation;
Efl_Canvas_Object *target;
double progress;
double play_speed;
int remaining_repeat_count;
Efl_Interpolator *interpolator;
Eina_Bool auto_del : 1;
Eina_Bool is_play : 1;
Eina_Bool is_paused : 1;
Eina_Bool keep_final_state : 1;
Eina_Bool is_direction_forward : 1;
} Efl_Canvas_Animation_Player_Data;
#define EFL_ANIMATION_PLAYER_DATA_GET(o, pd) \
Efl_Canvas_Animation_Player_Data *pd = efl_data_scope_get(o, EFL_CANVAS_ANIMATION_PLAYER_CLASS)
#define EFL_ANIMATION_PLAYER_ANIMATION_GET(o, anim) \
Efl_Canvas_Animation *anim = efl_animation_player_animation_get(o)

View File

@ -11,7 +11,7 @@ struct Efl.Event_Animator_Tick {
abstract Efl.Canvas.Object extends Efl.Loop_Consumer implements Efl.Gfx.Entity, Efl.Gfx.Color, Efl.Gfx.Stack,
Efl.Input.Interface, Efl.Gfx.Hint,
Efl.Gfx.Mapping, Efl.Canvas.Pointer, Efl.Gesture.Events
Efl.Gfx.Mapping, Efl.Canvas.Pointer, Efl.Gesture.Events, Efl.Canvas.Object_Animation
{
[[Efl canvas object abstract class

View File

@ -0,0 +1,197 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "evas_common_private.h"
#include "evas_private.h"
#include "efl_canvas_object_animation.eo.h"
#include <Ecore.h>
#define MY_CLASS EFL_CANVAS_OBJECT_ANIMATION_MIXIN
typedef struct
{
Efl_Canvas_Animation *animation;
double speed;
double progress;
double run_start_time;
double start_pos;
int remaining_repeats;
Efl_Loop_Timer *timer;
Eina_Bool pause_state : 1;
} Efl_Canvas_Object_Animation_Indirect_Data;
typedef struct
{
Efl_Canvas_Object_Animation_Indirect_Data *in;
} Efl_Canvas_Object_Animation_Data;
static void _end(Efl_Canvas_Object_Animation *obj, Efl_Canvas_Object_Animation_Data *pd);
static void
_animator_cb(void *data, const Efl_Event *ev EINA_UNUSED)
{
Eo *obj = data;
Efl_Canvas_Object_Animation_Data *pd = efl_data_scope_get(obj, MY_CLASS);
double duration, elapsed_time, vector, current;
EINA_SAFETY_ON_NULL_RETURN(pd->in);
current = ecore_loop_time_get();
EINA_SAFETY_ON_FALSE_RETURN(pd->in->run_start_time <= current);
duration = efl_animation_duration_get(pd->in->animation) / pd->in->speed;
elapsed_time = current - pd->in->run_start_time;
vector = elapsed_time / duration;
/* When animation player starts, _animator_cb() is called immediately so
* both elapsed time and progress are 0.0.
* Since it is the beginning of the animation if progress is 0.0, the
* following codes for animation should be executed. */
if (pd->in->speed < 0.0)
vector += 1.0;
pd->in->progress = CLAMP(0.0, vector, 1.0);
/* The previously applied map effect should be reset before applying the
* current map effect. Otherwise, the incrementally added map effects
* increase numerical error. */
efl_gfx_mapping_reset(obj);
efl_animation_apply(pd->in->animation, pd->in->progress, obj);
efl_event_callback_call(obj, EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, &pd->in->progress);
//Not end. Keep going.
if ((pd->in->speed < 0 && EINA_DBL_EQ(pd->in->progress, 0)) ||
(pd->in->speed > 0 && EINA_DBL_EQ(pd->in->progress, 1.0)))
{
//Repeat animation
if ((efl_animation_repeat_count_get(pd->in->animation) == EFL_ANIMATION_REPEAT_INFINITE) ||
(pd->in->remaining_repeats > 0))
{
pd->in->remaining_repeats--;
if (efl_animation_repeat_mode_get(pd->in->animation) == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
pd->in->speed *= -1;
pd->in->run_start_time = current;
}
else
{
efl_canvas_object_animation_stop(obj);
}
}
}
static void
_end(Efl_Canvas_Object_Animation *obj, Efl_Canvas_Object_Animation_Data *pd)
{
EINA_SAFETY_ON_NULL_RETURN(pd->in);
efl_event_callback_del(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _animator_cb, obj);
}
static void
_start(Efl_Canvas_Object_Animation *obj, Efl_Canvas_Object_Animation_Data *pd, double delay)
{
EINA_SAFETY_ON_NULL_RETURN(pd->in);
pd->in->run_start_time = ecore_loop_time_get() - efl_animation_duration_get(pd->in->animation)*delay;
efl_event_callback_add(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, _animator_cb, obj);
_animator_cb(obj, NULL);
}
static Eina_Value
_start_fcb(Eo *o, void *data EINA_UNUSED, const Eina_Value v)
{
Efl_Canvas_Object_Animation_Data *pd = efl_data_scope_safe_get(o, MY_CLASS);
if (!pd->in) return v; //animation was stopped before anything started
_start(o, pd, pd->in->start_pos);
return v;
}
EOLIAN static Efl_Canvas_Animation*
_efl_canvas_object_animation_animation_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Object_Animation_Data *pd)
{
if (!pd->in) return NULL;
return pd->in->animation;
}
EOLIAN static double
_efl_canvas_object_animation_animation_progress_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Object_Animation_Data *pd)
{
if (pd->in && pd->in->animation)
return (pd->in->speed < 0) ? fabs(1.0 - pd->in->progress) : pd->in->progress;
else
return -1.0;
}
EOLIAN static void
_efl_canvas_object_animation_animation_pause_set(Eo *obj, Efl_Canvas_Object_Animation_Data *pd, Eina_Bool pause)
{
EINA_SAFETY_ON_NULL_RETURN(pd->in);
if (pd->in->pause_state == pause) return;
if (pause)
_end(obj, pd);
else
_start(obj, pd,(pd->in->speed < 0) ? 1.0 - pd->in->progress : pd->in->progress);
pd->in->pause_state = pause;
}
EOLIAN static Eina_Bool
_efl_canvas_object_animation_animation_pause_get(const Eo *obj EINA_UNUSED, Efl_Canvas_Object_Animation_Data *pd)
{
if (!pd->in) return EINA_FALSE;
return pd->in->pause_state;
}
EOLIAN static void
_efl_canvas_object_animation_animation_start(Eo *obj, Efl_Canvas_Object_Animation_Data *pd, Efl_Canvas_Animation *animation, double speed, double start_pos)
{
Efl_Canvas_Object_Animation_Indirect_Data *in;
if (pd->in && pd->in->animation)
efl_canvas_object_animation_stop(obj);
EINA_SAFETY_ON_FALSE_RETURN(!pd->in);
in = pd->in = calloc(1, sizeof(Efl_Canvas_Object_Animation_Indirect_Data));
EINA_SAFETY_ON_NULL_RETURN(animation);
EINA_SAFETY_ON_FALSE_RETURN(start_pos >= 0.0 && start_pos <= 1.0);
EINA_SAFETY_ON_FALSE_RETURN(!EINA_DBL_EQ(speed, 0.0));
EINA_SAFETY_ON_FALSE_RETURN(efl_playable_seekable_get(animation));
in->pause_state = EINA_FALSE;
in->animation = efl_ref(animation);
in->remaining_repeats = efl_animation_repeat_count_get(animation); // -1 because one run is already going on
in->speed = speed;
in->start_pos = start_pos;
efl_event_callback_call(obj, EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, in->animation);
if (efl_animation_start_delay_get(animation) > 0.0)
{
Eina_Future *f = efl_loop_timeout(efl_loop_get(obj), efl_animation_start_delay_get(animation));
efl_future_then(obj, f, .success = _start_fcb);
}
else
_start(obj, pd, start_pos);
}
EOLIAN static void
_efl_canvas_object_animation_animation_stop(Eo *obj, Efl_Canvas_Object_Animation_Data *pd)
{
if (!pd->in) return;
if (!efl_animation_final_state_keep_get(pd->in->animation))
efl_gfx_mapping_reset(obj);
_end(obj, pd);
efl_unref(pd->in->animation);
pd->in->animation = NULL;
efl_event_callback_call(obj, EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, pd->in->animation);
free(pd->in);
pd->in = NULL;
}
#include "efl_canvas_object_animation.eo.c"

View File

@ -0,0 +1,60 @@
mixin @beta Efl.Canvas.Object_Animation requires Efl.Object
{
methods {
@property animation {
[[The animation that is currently played on the canvas object.
$null in case that there is no animation running.]]
get {
}
values {
animation : Efl.Canvas.Animation; [[The animation which is currently applied on this object.]]
}
}
@property animation_progress {
[[The current progress of the animation, between 0.0 and 1.0.
Even if the animation is going backwards (speed < 0.0). the progress will still go from 0.0 to 1.0.
If there is no animation going on, this will return -1.0.
]]
get {
}
values {
position : double; [[The position the animation applying is currently in.]]
}
}
@property animation_pause {
[[Pause the animation
The animation will not be unset. When $pause is unset, the animation will be resumed at the same progress it has right now.
]]
values {
pause : bool;
}
}
animation_start {
[[Start a animation new animation.
If there is a animation going on, this is stopped.
]]
params {
animation : Efl.Canvas.Animation @move; [[The animation to start.]]
speed : double; [[The speed of the animation, this is counted as a ratio to the animation length. A speed < 0.0 means that the animation will be played bacwards.]]
start_pos : double; [[The position to start, must be between 0.0 and 1.0.]]
}
}
animation_stop {
[[Stop the animation.
After this call, @.animation will return $null. The reference that was taken during @.animation_start will be given up on.
]]
}
}
events {
animation,changed: Efl.Canvas.Animation; [[The animation object got changed.]]
animation_progress,updated : double; [[The animation position got changed.]]
}
}

View File

@ -39,7 +39,6 @@ pub_eo_files = [
'efl_canvas_animation_group.eo',
'efl_canvas_animation_group_parallel.eo',
'efl_canvas_animation_group_sequential.eo',
'efl_canvas_animation_player.eo',
'efl_canvas_text_factory.eo',
'efl_canvas_rectangle.eo',
'efl_canvas_object.eo',
@ -56,6 +55,7 @@ pub_eo_files = [
'efl_gfx_mapping.eo',
'efl_canvas_event_grabber.eo',
'efl_canvas_text.eo',
'efl_canvas_object_animation.eo',
]
evas_canvas_eo_files = pub_eo_files
@ -184,7 +184,6 @@ evas_src += files([
'efl_canvas_animation_group.c',
'efl_canvas_animation_group_parallel.c',
'efl_canvas_animation_group_sequential.c',
'efl_canvas_animation_player.c',
'efl_gfx_vg_value_provider.c',
'efl_canvas_vg_object.c',
'efl_canvas_vg_node.c',
@ -207,6 +206,7 @@ evas_src += files([
'evas_canvas3d_primitive.c',
'evas_canvas3d_node_callback.h',
'evas_canvas3d_eet.c',
'efl_canvas_object_animation.c',
])
evas_include_directories += include_directories('.')

View File

@ -197,8 +197,8 @@ _transition_animation_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED)
}
EFL_OPS_DEFINE(transition_tracker,
EFL_OBJECT_OP_FUNC(efl_ui_spotlight_manager_animation_enabled_set, _transition_animation_set),
EFL_OBJECT_OP_FUNC(efl_ui_spotlight_manager_animation_enabled_get, _transition_animation_get),
EFL_OBJECT_OP_FUNC(efl_ui_spotlight_manager_animated_transition_set, _transition_animation_set),
EFL_OBJECT_OP_FUNC(efl_ui_spotlight_manager_animated_transition_get, _transition_animation_get),
EFL_OBJECT_OP_FUNC(efl_ui_spotlight_manager_content_add, _transition_content_add),
EFL_OBJECT_OP_FUNC(efl_ui_spotlight_manager_content_del, _transition_content_del),
EFL_OBJECT_OP_FUNC(efl_ui_spotlight_manager_switch_to, _transition_request_switch),

View File

@ -5,10 +5,17 @@
#include <stdio.h>
#include <Evas.h>
#define EFL_LOOP_PROTECTED //needed to set the loop time, we need that to simulate time passing for animation,tick
#include <Ecore.h>
#include "evas_suite.h"
#include "evas_tests_helpers.h"
static int called_changed;
static Efl_Canvas_Animation *animation_changed_ev;
static int called_running;
static double animation_running_position;
EFL_START_TEST(evas_object_various)
{
Evas *evas = EVAS_TEST_INIT_EVAS();
@ -51,8 +58,159 @@ EFL_START_TEST(evas_object_freeze_events)
}
EFL_END_TEST
EFL_START_TEST(evas_object_animation_simple)
{
Evas *evas = EVAS_TEST_INIT_EVAS();
Evas_Object *obj = evas_object_rectangle_add(evas);
Efl_Canvas_Animation *animation = efl_add(EFL_CANVAS_ANIMATION_CLASS, evas);
ck_assert_ptr_eq(efl_canvas_object_animation_get(obj) , NULL);
ck_assert(EINA_DBL_EQ(efl_canvas_object_animation_progress_get(obj), -1.0));
efl_canvas_object_animation_start(obj, animation, 1.0, 0.0);
ck_assert_ptr_eq(efl_canvas_object_animation_get(obj) , animation);
ck_assert(EINA_DBL_EQ(efl_canvas_object_animation_progress_get(obj), 0.0));
efl_canvas_object_animation_stop(obj);
ck_assert_ptr_eq(efl_canvas_object_animation_get(obj) , NULL);
ck_assert(EINA_DBL_EQ(efl_canvas_object_animation_progress_get(obj), -1.0));
efl_canvas_object_animation_start(obj, animation, 1.0, 0.0);
efl_canvas_object_animation_stop(obj);
efl_canvas_object_animation_start(obj, animation, -1.0, 1.0);
efl_canvas_object_animation_stop(obj);
efl_canvas_object_animation_stop(obj);
}
EFL_END_TEST
EFL_START_TEST(evas_object_animation_progress)
{
Evas *evas = EVAS_TEST_INIT_EVAS();
Evas_Object *obj = evas_object_rectangle_add(evas);
Efl_Canvas_Animation *animation = efl_add(EFL_CANVAS_ANIMATION_CLASS, evas, efl_animation_duration_set(efl_added, 1.0));
efl_canvas_object_animation_start(obj, animation, 1.0, 0.0);
efl_loop_time_set(efl_main_loop_get(), efl_loop_time_get(efl_main_loop_get()) + 0.5);
efl_event_callback_call(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, NULL);
ck_assert(EINA_DBL_EQ(efl_canvas_object_animation_progress_get(obj), 0.5));
efl_canvas_object_animation_stop(obj);
}
EFL_END_TEST
static inline void
_simulate_time_passing(Eo *obj, double start, double jump)
{
efl_loop_time_set(efl_main_loop_get(), start + jump);
efl_event_callback_call(obj, EFL_CANVAS_OBJECT_EVENT_ANIMATOR_TICK, NULL);
}
static inline void
_simulate_assert_time_passing(Eo *obj, double start, double jump, double expected_position)
{
_simulate_time_passing(obj, start, jump);
ck_assert_int_eq((efl_canvas_object_animation_progress_get(obj)-expected_position)*10000, 0);
}
EFL_START_TEST(evas_object_animation_pause)
{
Evas *evas = EVAS_TEST_INIT_EVAS();
Evas_Object *obj = evas_object_rectangle_add(evas);
double start = efl_loop_time_get(efl_main_loop_get());
Efl_Canvas_Animation *animation = efl_add(EFL_CANVAS_ANIMATION_CLASS, evas, efl_animation_duration_set(efl_added, 1.0));
efl_canvas_object_animation_start(obj, animation, 1.0, 0.0);
_simulate_assert_time_passing(obj, start, 0.2, 0.2);
efl_canvas_object_animation_pause_set(obj, EINA_TRUE);
_simulate_assert_time_passing(obj, start, 0.5, 0.2);
efl_canvas_object_animation_pause_set(obj, EINA_FALSE);
_simulate_assert_time_passing(obj, start, 0.7, 0.4);
efl_canvas_object_animation_stop(obj);
}
EFL_END_TEST
EFL_START_TEST(evas_object_animation_error)
{
Evas *evas = EVAS_TEST_INIT_EVAS();
Evas_Object *obj = evas_object_rectangle_add(evas);
Efl_Canvas_Animation *animation = efl_add(EFL_CANVAS_ANIMATION_CLASS, evas);
EXPECT_ERROR_START;
efl_canvas_object_animation_start(obj, NULL, 1.0, 0.0);
EXPECT_ERROR_END;
EXPECT_ERROR_START;
efl_canvas_object_animation_start(obj, animation, 0.0, 0.0);
EXPECT_ERROR_END;
efl_canvas_object_animation_stop(obj);
EXPECT_ERROR_START;
efl_canvas_object_animation_start(obj, animation, 1.0, 2.0);
EXPECT_ERROR_END;
efl_canvas_object_animation_stop(obj);
EXPECT_ERROR_START;
efl_canvas_object_animation_start(obj, animation, 1.0, -1.0);
EXPECT_ERROR_END;
efl_canvas_object_animation_stop(obj);
}
EFL_END_TEST
static void
_anim_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
{
animation_changed_ev = event->info;
called_changed ++;
}
static void
_anim_running_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
animation_running_position = *((double*) event->info);
called_running ++;
}
EFL_CALLBACKS_ARRAY_DEFINE(animation_stats_cb,
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_CHANGED, _anim_changed_cb },
{EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _anim_running_cb },
)
EFL_START_TEST(evas_object_animation_events)
{
Evas *evas = EVAS_TEST_INIT_EVAS();
Evas_Object *obj = evas_object_rectangle_add(evas);
double start = efl_loop_time_get(efl_main_loop_get());
Efl_Canvas_Animation *animation = efl_add(EFL_CANVAS_ANIMATION_CLASS, evas, efl_animation_duration_set(efl_added, 1.0));
efl_event_callback_array_add(obj, animation_stats_cb(), NULL);
efl_canvas_object_animation_start(obj, animation, 1.0, 0.0);
ck_assert_int_eq(called_changed, 1);
ck_assert_ptr_eq(animation_changed_ev, animation);
ck_assert_int_eq(called_running, 1);
ck_assert(EINA_DBL_EQ(animation_running_position, 0.0));
_simulate_time_passing(obj, start, 1.0);
ck_assert_int_eq(called_changed, 2);
ck_assert_ptr_eq(animation_changed_ev, NULL);
ck_assert_int_eq(called_running, 2);
ck_assert(EINA_DBL_EQ(animation_running_position, 1.0));
ck_assert_ptr_eq(efl_canvas_object_animation_get(obj), NULL);
ck_assert(EINA_DBL_EQ(efl_canvas_object_animation_progress_get(obj), -1.0));
}
EFL_END_TEST
void evas_test_object(TCase *tc)
{
tcase_add_test(tc, evas_object_various);
tcase_add_test(tc, evas_object_freeze_events);
tcase_add_test(tc, evas_object_animation_simple);
tcase_add_test(tc, evas_object_animation_progress);
tcase_add_test(tc, evas_object_animation_pause);
tcase_add_test(tc, evas_object_animation_error);
tcase_add_test(tc, evas_object_animation_events);
}