Efl.Ui.Animation_View: Implements Efl.Player interface

Summary:
Chnaged API
.speed.set        => Efl.Player.playback_speed.set
.speed.get        => Efl.Player.playback_speed.get
.progress.get     => Efl.Player.playback_progress.get
.play             => Efl.Player.playing.set(true)
.stop             => Efl.Player.playing.set(false)
.pause            => Efl.Player.paused.set(true)
.resume           => Efl.Player.paused.set(false)
.play_sector      => .playing_sector
.auto_play        => .autoplay
.auto_repeat      => .autorepeat

Remove API
.is_playing_back
.playback         => (use negative speed value)

New feature API
Efl.Player.playback_position.set
Efl.Player.playback_position.get
Efl.Player.playing.get
Efl.Player.paused.get

ref T8476

Test Plan:
meson_option.txt -> remove json in evas-loaders-disabler option
elementary_test -to "animation view"

Reviewers: Hermet, bu5hm4n, kimcinoo, Jaehyun_Cho, segfaultxavi, zmike

Reviewed By: segfaultxavi, zmike

Subscribers: zmike, segfaultxavi, cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8476

Differential Revision: https://phab.enlightenment.org/D10862
This commit is contained in:
junsu choi 2019-12-31 09:52:56 -05:00 committed by Mike Blumenkrantz
parent 2f8683ef41
commit e1afc7c181
6 changed files with 261 additions and 285 deletions

View File

@ -78,15 +78,23 @@ btn_clicked_cb(void *data , const Efl_Event *ev )
if (!text) return;
if (!strcmp("Play", text))
efl_ui_animation_view_play((Evas_Object*)data);
{
double speed = efl_player_playback_speed_get(anim_view);
efl_player_playback_speed_set(anim_view, speed < 0 ? speed * -1 : speed);
efl_player_playing_set(anim_view, EINA_TRUE);
}
else if (!strcmp("Pause", text))
efl_ui_animation_view_pause((Evas_Object*)data);
efl_player_paused_set((Evas_Object*)data, EINA_TRUE);
else if (!strcmp("Resume", text))
efl_ui_animation_view_resume((Evas_Object*)data);
efl_player_paused_set((Evas_Object*)data, EINA_FALSE);
else if (!strcmp("Play Back", text))
efl_ui_animation_view_play_back((Evas_Object*)data);
{
double speed = efl_player_playback_speed_get(anim_view);
efl_player_playback_speed_set(anim_view, speed > 0 ? speed * -1 : speed);
efl_player_playing_set(anim_view, EINA_TRUE);
}
else if (!strcmp("Stop", text))
efl_ui_animation_view_stop((Evas_Object*)data);
efl_player_playing_set((Evas_Object*)data, EINA_FALSE);
else if (!strcmp("ADD", text))
{
Evas_Object *list = (Evas_Object*)data;
@ -145,7 +153,7 @@ static void
check_changed_cb(void *data, const Efl_Event *event)
{
Evas_Object *anim_view = data;
efl_ui_animation_view_auto_repeat_set(anim_view, efl_ui_selectable_selected_get(event->object));
efl_ui_animation_view_autorepeat_set(anim_view, efl_ui_selectable_selected_get(event->object));
}
static void
@ -154,7 +162,7 @@ speed_changed_cb(void *data, const Efl_Event *event)
Evas_Object *anim_view = data;
double speed = 1;
if (efl_ui_selectable_selected_get(event->object)) speed = 0.25;
efl_ui_animation_view_speed_set(anim_view, speed);
efl_player_playback_speed_set(anim_view, speed);
}
static void
@ -206,7 +214,7 @@ static void
_play_updated(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
{
Evas_Object *slider = data;
efl_ui_range_value_set(slider, efl_ui_animation_view_progress_get(obj));
efl_ui_range_value_set(slider, efl_player_playback_progress_get(obj));
}
static void

View File

@ -23,22 +23,30 @@ btn_clicked_cb(void *data , const Efl_Event *ev )
if (!text) return;
if (!strcmp("Play", text))
efl_ui_animation_view_play(anim_view);
{
double speed = efl_player_playback_speed_get(anim_view);
efl_player_playback_speed_set(anim_view, speed < 0 ? speed * -1 : speed);
efl_player_playing_set(anim_view, EINA_TRUE);
}
else if (!strcmp("Pause", text))
efl_ui_animation_view_pause(anim_view);
efl_player_paused_set(anim_view, EINA_TRUE);
else if (!strcmp("Resume", text))
efl_ui_animation_view_resume(anim_view);
efl_player_paused_set(anim_view, EINA_FALSE);
else if (!strcmp("Play Back", text))
efl_ui_animation_view_play_back(anim_view);
{
double speed = efl_player_playback_speed_get(anim_view);
efl_player_playback_speed_set(anim_view, speed > 0 ? speed * -1 : speed);
efl_player_playing_set(anim_view, EINA_TRUE);
}
else if (!strcmp("Stop", text))
efl_ui_animation_view_stop(anim_view);
efl_player_playing_set(anim_view, EINA_FALSE);
}
static void
check_changed_cb(void *data, const Efl_Event *event)
{
Evas_Object *anim_view = data;
efl_ui_animation_view_auto_repeat_set(anim_view, efl_ui_selectable_selected_get(event->object));
efl_ui_animation_view_autorepeat_set(anim_view, efl_ui_selectable_selected_get(event->object));
}
static void
@ -47,7 +55,7 @@ speed_changed_cb(void *data, const Efl_Event *event)
Evas_Object *anim_view = data;
double speed = 1;
if (efl_ui_selectable_selected_get(event->object)) speed = 0.25;
efl_ui_animation_view_speed_set(anim_view, speed);
efl_player_playback_speed_set(anim_view, speed);
}
static void
@ -99,7 +107,7 @@ static void
_play_updated(void *data, Evas_Object *obj, void *ev EINA_UNUSED)
{
Evas_Object *slider = data;
efl_ui_range_value_set(slider, efl_ui_animation_view_progress_get(obj));
efl_ui_range_value_set(slider, efl_player_playback_progress_get(obj));
}
static void

View File

@ -66,13 +66,12 @@ static void
_transit_go_facade(Eo* obj, Efl_Ui_Animation_View_Data *pd)
{
pd->repeat_times = 0;
if (pd->play_back)
if (pd->playing_reverse)
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK;
else
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY;
evas_object_smart_callback_call(obj, SIG_PLAY_START, NULL);
if (pd->transit) elm_transit_go(pd->transit);
}
if (pd->transit) elm_transit_go(pd->transit);}
static Eina_Bool
_visible_check(Eo *obj)
@ -99,21 +98,21 @@ _visible_check(Eo *obj)
}
static void
_auto_play(Eo *obj, Efl_Ui_Animation_View_Data *pd, Eina_Bool vis)
_autoplay(Eo *obj, Efl_Ui_Animation_View_Data *pd, Eina_Bool vis)
{
if (!pd->auto_play || !pd->transit) return;
if (!pd->autoplay || !pd->transit) return;
//Resume Animation
if (vis)
{
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PAUSE && pd->auto_play_pause)
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PAUSE && pd->autoplay_pause)
{
elm_transit_paused_set(pd->transit, EINA_FALSE);
if (pd->play_back)
if (pd->playing_reverse)
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK;
else
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY;
pd->auto_play_pause = EINA_FALSE;
pd->autoplay_pause = EINA_FALSE;
evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
}
}
@ -125,7 +124,7 @@ _auto_play(Eo *obj, Efl_Ui_Animation_View_Data *pd, Eina_Bool vis)
{
elm_transit_paused_set(pd->transit, EINA_TRUE);
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PAUSE;
pd->auto_play_pause = EINA_TRUE;
pd->autoplay_pause = EINA_TRUE;
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
}
}
@ -147,7 +146,7 @@ _transit_del_cb(Elm_Transit_Effect *effect, Elm_Transit *transit)
Efl_Ui_Animation_View_State prev_state = pd->state;
pd->state = EFL_UI_ANIMATION_VIEW_STATE_STOP;
pd->transit = NULL;
pd->auto_play_pause = EINA_FALSE;
pd->autoplay_pause = EINA_FALSE;
if (prev_state != EFL_UI_ANIMATION_VIEW_STATE_STOP)
{
@ -168,8 +167,18 @@ _transit_cb(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
elm_transit_del(transit);
return;
}
if (pd->playback_direction_changed)
{
elm_transit_progress_value_set(pd->transit, 1 - progress);
progress = 1 - progress ;
if (pd->play_back)
if (pd->playback_speed <= 0) pd->playing_reverse = EINA_TRUE;
else pd->playing_reverse = EINA_FALSE;
pd->playback_direction_changed = EINA_FALSE;
}
if (pd->playing_reverse)
{
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK;
progress = 1 - progress;
@ -182,9 +191,13 @@ _transit_cb(Elm_Transit_Effect *effect, Elm_Transit *transit, double progress)
int update_frame = (int)((maxframe - minframe) * progress) + minframe;
int current_frame = evas_object_vg_animated_frame_get(pd->vg);
if (pd->playback_speed == 0)
update_frame = current_frame;
evas_object_vg_animated_frame_set(pd->vg, update_frame);
if (pd->auto_repeat)
if (pd->autorepeat)
{
int repeat_times = elm_transit_current_repeat_times_get(pd->transit);
if (pd->repeat_times != repeat_times)
@ -212,7 +225,7 @@ _efl_ui_animation_view_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Animation_View
efl_event_callback_add(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED, _size_hint_event_cb, priv);
priv->vg = vg;
priv->speed = 1;
priv->playback_speed = 1;
priv->frame_duration = 0;
priv->min_progress = 0.0;
priv->max_progress = 1.0;
@ -262,16 +275,17 @@ _update_frame_duration(Efl_Ui_Animation_View_Data *pd)
int min_frame = (frame_count - 1) * pd->min_progress;
int max_frame = (frame_count - 1) * pd->max_progress;
double frame_rate = round((double)frame_count / evas_object_vg_animated_frame_duration_get(pd->vg, 0, 0));
double speed = pd->playback_speed < 0 ? pd->playback_speed * -1 : pd->playback_speed;
pd->frame_duration = (double)(max_frame - min_frame) / frame_rate;
if (pd->transit)
elm_transit_duration_set(pd->transit, pd->frame_duration * (1/pd->speed));
elm_transit_duration_set(pd->transit, speed != 0 ? pd->frame_duration * (1 / speed) : 0);
}
static Eina_Bool
_ready_play(Eo *obj, Efl_Ui_Animation_View_Data *pd)
{
pd->auto_play_pause = EINA_FALSE;
pd->autoplay_pause = EINA_FALSE;
pd->state = EFL_UI_ANIMATION_VIEW_STATE_STOP;
if (pd->transit) elm_transit_del(pd->transit);
@ -279,12 +293,12 @@ _ready_play(Eo *obj, Efl_Ui_Animation_View_Data *pd)
pd->frame_cnt = (double) evas_object_vg_animated_frame_count_get(pd->vg);
pd->frame_duration = evas_object_vg_animated_frame_duration_get(pd->vg, 0, 0);
evas_object_vg_animated_frame_set(pd->vg, 0);
if (pd->frame_duration > 0)
{
double speed = pd->playback_speed < 0 ? pd->playback_speed * -1 : pd->playback_speed;
Elm_Transit *transit = elm_transit_add();
elm_transit_object_add(transit, pd->vg);
if (pd->auto_repeat) elm_transit_repeat_times_set(transit, -1);
if (pd->autorepeat) elm_transit_repeat_times_set(transit, -1);
elm_transit_effect_add(transit, _transit_cb, obj, _transit_del_cb);
elm_transit_progress_value_set(transit, pd->progress);
elm_transit_objects_final_state_keep_set(transit, EINA_TRUE);
@ -292,7 +306,7 @@ _ready_play(Eo *obj, Efl_Ui_Animation_View_Data *pd)
if (pd->min_progress != 0.0 || pd->max_progress != 1.0)
_update_frame_duration(pd);
else
elm_transit_duration_set(transit, pd->frame_duration * (1/pd->speed));
elm_transit_duration_set(transit, speed != 0 ? pd->frame_duration * (1 / speed) : 0);
return EINA_TRUE;
}
@ -336,7 +350,7 @@ _efl_ui_animation_view_efl_file_load(Eo *obj, Efl_Ui_Animation_View_Data *pd)
if (!_ready_play(obj, pd)) return 1;
if (pd->auto_play)
if (pd->autoplay)
{
_transit_go_facade(obj, pd);
@ -344,7 +358,7 @@ _efl_ui_animation_view_efl_file_load(Eo *obj, Efl_Ui_Animation_View_Data *pd)
{
elm_transit_paused_set(pd->transit, EINA_TRUE);
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PAUSE;
pd->auto_play_pause = EINA_TRUE;
pd->autoplay_pause = EINA_TRUE;
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
}
}
@ -361,7 +375,7 @@ _efl_ui_animation_view_efl_gfx_entity_position_set(Eo *obj,
efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
_auto_play(obj, pd, _visible_check(obj));
_autoplay(obj, pd, _visible_check(obj));
}
EOLIAN static void
@ -376,7 +390,7 @@ _efl_ui_animation_view_efl_gfx_entity_size_set(Eo *obj,
_sizing_eval(obj, pd);
_auto_play(obj, pd, _visible_check(obj));
_autoplay(obj, pd, _visible_check(obj));
}
EOLIAN static void
@ -389,7 +403,7 @@ _efl_ui_animation_view_efl_gfx_entity_visible_set(Eo *obj,
efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), vis);
_auto_play(obj, pd, _visible_check(obj));
_autoplay(obj, pd, _visible_check(obj));
}
EOLIAN static void
@ -415,60 +429,38 @@ _efl_ui_animation_view_efl_gfx_view_view_size_get(const Eo *obj EINA_UNUSED,
}
EOLIAN static void
_efl_ui_animation_view_auto_repeat_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, Eina_Bool auto_repeat)
_efl_ui_animation_view_autorepeat_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, Eina_Bool autorepeat)
{
if (pd->auto_repeat == auto_repeat) return;
pd->auto_repeat = auto_repeat;
if (pd->autorepeat == autorepeat) return;
pd->autorepeat = autorepeat;
if (pd->transit)
{
if (auto_repeat) elm_transit_repeat_times_set(pd->transit, -1);
if (autorepeat) elm_transit_repeat_times_set(pd->transit, -1);
else elm_transit_repeat_times_set(pd->transit, 0);
}
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_auto_repeat_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
_efl_ui_animation_view_autorepeat_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->auto_repeat;
return pd->autorepeat;
}
EOLIAN static void
_efl_ui_animation_view_auto_play_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd,
Eina_Bool auto_play)
_efl_ui_animation_view_autoplay_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd,
Eina_Bool autoplay)
{
pd->auto_play = auto_play;
if (!auto_play) pd->auto_play_pause = EINA_FALSE;
pd->autoplay = autoplay;
if (!autoplay) pd->autoplay_pause = EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_auto_play_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
_efl_ui_animation_view_autoplay_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->auto_play;
return pd->autoplay;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_play(Eo *obj, Efl_Ui_Animation_View_Data *pd)
{
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY) return EINA_FALSE;
Eina_Bool rewind = EINA_FALSE;
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK) rewind = EINA_TRUE;
pd->play_back = EINA_FALSE;
pd->auto_play_pause = EINA_FALSE;
if (!efl_file_loaded_get(obj)) return EINA_FALSE;
if (!pd->transit && !_ready_play(obj, pd)) return EINA_FALSE;
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_STOP)
_transit_go_facade(obj, pd);
else if (rewind)
elm_transit_progress_value_set(pd->transit, pd->progress);
return EINA_TRUE;
}
Eina_Bool _efl_ui_animation_view_play_sector(Eo *obj, Efl_Ui_Animation_View_Data *pd, const char *start, const char *end)
Eina_Bool _efl_ui_animation_view_playing_sector(Eo *obj, Efl_Ui_Animation_View_Data *pd, const char *start, const char *end)
{
int start_frame = 0;
int end_frame = evas_object_vg_animated_frame_count_get(pd->vg) - 1;
@ -494,13 +486,13 @@ Eina_Bool _efl_ui_animation_view_play_sector(Eo *obj, Efl_Ui_Animation_View_Data
if (start_frame < end_frame)
efl_ui_animation_view_max_frame_set(obj, end_frame);
if (!efl_ui_animation_view_play(obj))
if (!efl_player_playing_set(obj, EINA_TRUE))
return EINA_FALSE;
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_stop(Eo *obj, Efl_Ui_Animation_View_Data *pd)
Eina_Bool
_playing_stop(Eo* obj, Efl_Ui_Animation_View_Data *pd)
{
if (!pd->transit) return EINA_FALSE;
@ -513,84 +505,6 @@ _efl_ui_animation_view_stop(Eo *obj, Efl_Ui_Animation_View_Data *pd)
pd->state = EFL_UI_ANIMATION_VIEW_STATE_STOP;
evas_object_smart_callback_call(obj, SIG_PLAY_STOP, NULL);
elm_transit_del(pd->transit);
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_pause(Eo *obj, Efl_Ui_Animation_View_Data *pd)
{
if (!pd->transit) return EINA_FALSE;
if ((pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY) ||
(pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK))
{
elm_transit_paused_set(pd->transit, EINA_TRUE);
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PAUSE;
pd->auto_play_pause = EINA_FALSE;
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
return EINA_TRUE;
}
return EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_resume(Eo *obj, Efl_Ui_Animation_View_Data *pd)
{
if (!pd->transit) return EINA_FALSE;
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PAUSE)
{
elm_transit_paused_set(pd->transit, EINA_FALSE);
if (pd->play_back)
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK;
else
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY;
pd->auto_play_pause = EINA_FALSE;
evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
return EINA_TRUE;
}
return EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_play_back(Eo *obj, Efl_Ui_Animation_View_Data *pd)
{
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK) return EINA_FALSE;
Eina_Bool rewind = EINA_FALSE;
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY) rewind = EINA_TRUE;
pd->play_back = EINA_TRUE;
pd->auto_play_pause = EINA_FALSE;
if (!efl_file_loaded_get(obj)) return EINA_FALSE;
if (!pd->transit && !_ready_play(obj, pd)) return EINA_FALSE;
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_STOP)
{
if (pd->progress == 0) pd->progress = 1.0;
_transit_go_facade(obj, pd);
}
else if (rewind)
elm_transit_progress_value_set(pd->transit, 1 - pd->progress);
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_speed_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, double speed)
{
if (speed <= 0) return EINA_FALSE;
pd->speed = speed;
if (pd->transit)
elm_transit_duration_set(pd->transit, pd->frame_duration * (1/pd->speed));
return EINA_TRUE;
}
@ -608,19 +522,13 @@ _efl_ui_animation_view_progress_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_D
if (pd->transit)
{
if (pd->play_back)
if (pd->playing_reverse)
elm_transit_progress_value_set(pd->transit, 1 - progress);
else
elm_transit_progress_value_set(pd->transit, progress);
}
}
EOLIAN static double
_efl_ui_animation_view_progress_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->progress;
}
EOLIAN static void
_efl_ui_animation_view_frame_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, int frame_num)
{
@ -634,12 +542,6 @@ _efl_ui_animation_view_frame_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_Vie
return (int) ((double) (evas_object_vg_animated_frame_count_get(pd->vg) - 1) * progress);
}
EOLIAN static double
_efl_ui_animation_view_speed_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->speed;
}
EOLIAN static double
_efl_ui_animation_view_duration_time_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
@ -659,12 +561,6 @@ _efl_ui_animation_view_state_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_Vie
return pd->state;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_is_playing_back(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->play_back;
}
EOLIAN static int
_efl_ui_animation_view_frame_count_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
@ -775,6 +671,139 @@ _efl_ui_animation_view_value_provider_override(Eo *obj EINA_UNUSED, Efl_Ui_Anima
efl_key_data_set(pd->vg, "_vg_value_providers", pd->vp_list);
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_efl_player_playing_set(Eo *obj, Efl_Ui_Animation_View_Data *pd, Eina_Bool playing)
{
if (playing)
{
if ((pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY && pd->playback_speed > 0)
|| (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK && pd->playback_speed <= 0))
return EINA_FALSE;
Eina_Bool rewind = EINA_FALSE;
if ((pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY && pd->playback_speed <= 0)
|| (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK && pd->playback_speed > 0))
rewind = EINA_TRUE;
if (pd->playback_speed <= 0)
pd->playing_reverse = EINA_TRUE;
else
pd->playing_reverse = EINA_FALSE;
pd->autoplay_pause = EINA_FALSE;
if (!efl_file_loaded_get(obj)) return EINA_FALSE;
if (!pd->transit && !_ready_play(obj, pd)) return EINA_FALSE;
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_STOP)
{
if (pd->playing_reverse && pd->progress == 0) pd->progress = 1.0;
_transit_go_facade(obj, pd);
}
else if (rewind)
{
elm_transit_progress_value_set(pd->transit, pd->playing_reverse ? 1 - pd->progress : pd->progress);
pd->playback_direction_changed = EINA_FALSE;
}
}
else
{
return _playing_stop(obj, pd);
}
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_efl_player_playing_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY)
return EINA_TRUE;
return EINA_FALSE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_efl_player_paused_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, Eina_Bool paused)
{
if (paused)
{
if ((pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY) ||
(pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK))
{
elm_transit_paused_set(pd->transit, paused);
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PAUSE;
pd->autoplay_pause = EINA_FALSE;
evas_object_smart_callback_call(obj, SIG_PLAY_PAUSE, NULL);
}
}
else
{
if (pd->transit && pd->state == EFL_UI_ANIMATION_VIEW_STATE_PAUSE)
{
elm_transit_paused_set(pd->transit, paused);
if (pd->playing_reverse)
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK;
else
pd->state = EFL_UI_ANIMATION_VIEW_STATE_PLAY;
pd->autoplay_pause = EINA_FALSE;
evas_object_smart_callback_call(obj, SIG_PLAY_RESUME, NULL);
}
}
return EINA_TRUE;
}
EOLIAN static Eina_Bool
_efl_ui_animation_view_efl_player_paused_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
if (pd->state == EFL_UI_ANIMATION_VIEW_STATE_PAUSE)
return EINA_TRUE;
return EINA_FALSE;
}
EOLIAN static void
_efl_ui_animation_view_efl_player_playback_position_set(Eo *obj, Efl_Ui_Animation_View_Data *pd, double sec)
{
EINA_SAFETY_ON_TRUE_RETURN(sec < 0);
EINA_SAFETY_ON_TRUE_RETURN(sec > pd->frame_duration);
efl_ui_animation_view_progress_set(obj, pd->frame_duration != 0 ? sec / pd->frame_duration : 0);
}
EOLIAN static double
_efl_ui_animation_view_efl_player_playback_position_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->frame_duration * pd->progress;
}
EOLIAN static double
_efl_ui_animation_view_efl_player_playback_progress_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->progress;
}
EOLIAN static void
_efl_ui_animation_view_efl_player_playback_speed_set(Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd, double speed)
{
// pd->playback_direction_changed is used only during playback.
if ((pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY ||
pd->state == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK)
&& ((pd->playback_speed > 0 && speed < 0) || (pd->playback_speed < 0 && speed > 0)))
pd->playback_direction_changed = EINA_TRUE;
pd->playback_speed = speed;
speed = speed < 0 ? speed * -1 : speed;
if (pd->transit)
elm_transit_duration_set(pd->transit, pd->playback_speed != 0 ? pd->frame_duration * (1 / speed) : 0);
}
EOLIAN static double
_efl_ui_animation_view_efl_player_playback_speed_get(const Eo *obj EINA_UNUSED, Efl_Ui_Animation_View_Data *pd)
{
return pd->playback_speed;
}
EAPI Elm_Animation_View*
elm_animation_view_add(Evas_Object *parent)
{

View File

@ -3,15 +3,14 @@ enum @beta Efl.Ui.Animation_View_State
{
[[State of animation view]]
not_ready, [[Animation is not ready to play. (Probably, it didn't file set yet or failed to read file.]]
play, [[Animation is playing. See @Efl.Ui.Animation_View.play.]]
play_back, [[Animation is playing back (rewinding). See @Efl.Ui.Animation_View.play_back.]]
pause, [[Animation has been paused. To continue animation call @Efl.Ui.Animation_View.resume.
See @Efl.Ui.Animation_View.pause.]]
play, [[Animation is playing.]]
play_back, [[Animation is playing back (rewinding).]]
pause, [[Animation has been paused.]]
stop [[Animation view successfully loaded a file then readied for playing.
Otherwise after finished animation or stopped forcibly by request. See @Efl.Ui.Animation_View.stop.]]
Otherwise after finished animation or stopped forcibly by request.]]
}
class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View, Efl.File
class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View, Efl.File, Efl.Player
{
[[Elementary Animation view class.
Animation view is designed to show and play animation of
@ -26,10 +25,10 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
]]
event_c_prefix: efl_ui_animation_view;
methods {
@property auto_play {
@property autoplay {
[[Animation will be started automatically when it's possible.
If @.auto_play is $true, animation will be started when it's readied.
If @.autoplay is $true, animation will be started when it's readied.
The condition of $auto play is when animation view opened file successfully,
yet to play it plus when the object is visible.
If animation view is disabled, invisible,
@ -45,14 +44,14 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
get {
}
values {
auto_play: bool(false); [[Auto play mode.]]
autoplay: bool(false); [[Auto play mode.]]
}
}
@property auto_repeat {
@property autorepeat {
[[Turn on/off animation looping.
If @.auto_repeat is $true, it repeats animation when animation frame is reached to
end. This auto repeat mode is valid to both play and play_back cases.
If @.autorepeat is $true, it repeats animation when animation frame is reached to
end. This auto repeat mode is valid to both playing and playing_backward cases.
$true Enable auto play mode, disable otherwise.
]]
@ -61,25 +60,7 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
get {
}
values {
auto_repeat: bool; [[Loop mode, Default is $false.]]
}
}
@property speed {
[[Control animation speed.
Control animation speed by multiplying $speed value. If you want to play
animation double-time faster, you can give $speed 2. If you want to play
animation double-time slower, you can give $speed 0.5.
Warning: speed must be greater than zero.
]]
set {
return: bool; [[$true when it's successful. $false otherwise.]]
}
get {
}
values {
speed: double(1.0); [[Speed factor.]]
autorepeat: bool; [[Loop mode, Default is $false.]]
}
}
@property duration_time {
@ -104,8 +85,6 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
]]
set {
}
get {
}
values {
progress: double; [[Progress position. Value must be 0 ~ 1.]]
}
@ -123,19 +102,7 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
frame_num: int; [[Current frame number.]]
}
}
play {
[[Play animation one time instantly when it's available.
If current keyframe is on a certain position by playing back, this will
play forward from there.
Warning: Play request will be ignored if animation source is not set yet or
animation is paused state or it's already on playing.
]]
return: bool; [[$true when it's successful. $false otherwise.]]
}
play_sector {
playing_sector {
[[Play animation of sector one time instantly when it's available.
If end sector is NULL, only start sector is referenced.
@ -154,46 +121,6 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
}
return: bool; [[$true when it's successful. $false otherwise.]]
}
play_back {
[[Play back animation one time instantly when it's available.
If current keyframe is on a certain position by playing, this will
play backward from there.
Warning: Play back request will be ignored if animation source is not set yet or
animation is paused state or it's already on playing back.
]]
return: bool; [[$true when it's successful. $false otherwise.]]
}
pause {
[[Pause current animation instantly.
Once animation is paused, animation view must get resume to play continue again.
Warning: Animation must be on playing or playing back status.
]]
return: bool; [[$true when it's successful. $false otherwise.]]
}
resume {
[[Resume paused animation to continue animation.
Warning: This resume must be called on animation paused status.
]]
return: bool; [[$true when it's successful. $false otherwise.]]
}
stop {
[[Stop playing animation.
Stop animation instantly regardless of its status and reset to
show first frame of animation. Even though current animation is paused,
the animation status will be stopped.
]]
return: bool; [[$true when it's successful. $false otherwise.]]
}
@property default_view_size {
[[The default view size that specified from vector resource.
]]
@ -213,12 +140,6 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
state: Efl.Ui.Animation_View_State; [[Current animation view state]]
}
}
is_playing_back {
[[Returns the status whether current animation is on playing forward or backward.
Note: If animation view is not on playing, it will return $false.
]]
return: bool; [[$true, if animation on playing back, $false otherwise.]]
}
@property frame_count {
[[The index of end frame of the animation view, if it's animated.
Note : frame number starts with 0.
@ -300,6 +221,11 @@ class @beta Efl.Ui.Animation_View extends Efl.Ui.Widget implements Efl.Gfx.View,
Efl.Gfx.Entity.position { set; }
Efl.Gfx.Entity.size { set; }
Efl.Gfx.View.view_size { set; get; }
Efl.Player.playing { set; get; }
Efl.Player.paused { set; get; }
Efl.Player.playback_position { set; get; }
Efl.Player.playback_progress { get; }
Efl.Player.playback_speed { set; get; }
}
events {
play,start: void; [[Called when animation is just started]]

View File

@ -2,37 +2,39 @@
EAPI void
elm_animation_view_auto_play_set(Efl_Ui_Animation_View *obj, Eina_Bool auto_play)
{
efl_ui_animation_view_auto_play_set(obj, auto_play);
efl_ui_animation_view_autoplay_set(obj, auto_play);
}
EAPI Eina_Bool
elm_animation_view_auto_play_get(const Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_auto_play_get(obj);
return efl_ui_animation_view_autoplay_get(obj);
}
EAPI void
elm_animation_view_auto_repeat_set(Efl_Ui_Animation_View *obj, Eina_Bool auto_repeat)
elm_animation_view_auto_repeat_set(Efl_Ui_Animation_View *obj, Eina_Bool autorepeat)
{
efl_ui_animation_view_auto_repeat_set(obj, auto_repeat);
efl_ui_animation_view_autorepeat_set(obj, autorepeat);
}
EAPI Eina_Bool
elm_animation_view_auto_repeat_get(const Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_auto_repeat_get(obj);
return efl_ui_animation_view_autorepeat_get(obj);
}
EAPI Eina_Bool
elm_animation_view_speed_set(Efl_Ui_Animation_View *obj, double speed)
{
return efl_ui_animation_view_speed_set(obj, speed);
if (!obj) return EINA_FALSE;
efl_player_playback_speed_set(obj, speed);
return EINA_TRUE;
}
EAPI double
elm_animation_view_speed_get(const Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_speed_get(obj);
return efl_player_playback_speed_get(obj);
}
EAPI double
@ -50,7 +52,7 @@ elm_animation_view_progress_set(Efl_Ui_Animation_View *obj, double progress)
EAPI double
elm_animation_view_progress_get(const Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_progress_get(obj);
return efl_player_playback_progress_get(obj);
}
EAPI void
@ -68,31 +70,33 @@ elm_animation_view_frame_get(const Efl_Ui_Animation_View *obj)
EAPI Eina_Bool
elm_animation_view_play(Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_play(obj);
return efl_player_playing_set(obj, EINA_TRUE);
}
EAPI Eina_Bool
elm_animation_view_play_back(Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_play_back(obj);
double speed = efl_player_playback_speed_get(obj);
efl_player_playback_speed_set(obj, speed < 0 ? speed * -1 : speed);
return efl_player_playing_set(obj, EINA_TRUE);
}
EAPI Eina_Bool
elm_animation_view_pause(Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_pause(obj);
return efl_player_paused_set(obj, EINA_TRUE);
}
EAPI Eina_Bool
elm_animation_view_resume(Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_resume(obj);
return efl_player_paused_set(obj, EINA_FALSE);
}
EAPI Eina_Bool
elm_animation_view_stop(Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_stop(obj);
return efl_player_playing_set(obj, EINA_FALSE);
}
EAPI Eina_Size2D
@ -104,7 +108,7 @@ elm_animation_view_default_size_get(const Efl_Ui_Animation_View *obj)
EAPI Eina_Bool
elm_animation_view_is_playing_back(Efl_Ui_Animation_View *obj)
{
return efl_ui_animation_view_is_playing_back(obj);
return (efl_ui_animation_view_state_get(obj) == EFL_UI_ANIMATION_VIEW_STATE_PLAY_BACK);
}
EAPI int

View File

@ -12,7 +12,7 @@ struct _Efl_Ui_Animation_View_Data
Efl_Ui_Animation_View_State state;
Elm_Transit *transit;
Eina_Stringshare *file;
double speed;
double playback_speed;
double progress;
double frame_cnt;
int repeat_times;
@ -21,10 +21,11 @@ struct _Efl_Ui_Animation_View_Data
double max_progress;
Eina_List *vp_list;
Eina_Bool play_back : 1;
Eina_Bool auto_play : 1;
Eina_Bool auto_play_pause: 1;
Eina_Bool auto_repeat : 1;
Eina_Bool playing_reverse : 1;
Eina_Bool autoplay : 1;
Eina_Bool autoplay_pause: 1;
Eina_Bool autorepeat : 1;
Eina_Bool playback_direction_changed : 1;
};
#define EFL_UI_ANIMATION_VIEW_DATA_GET(o, sd) \