efl_canvas_animation: fix final_state_keep logic

Previously, final_state_keep did not work correctly with animation
repeat.
e.g. repeat mode is restart and repeat count is 1, then final_state_keep
did not work.

Now, final_state_keep logic has been fixed to work correctly.
This commit is contained in:
Jaehyun Cho 2019-06-04 21:49:08 +09:00
parent 9eb0b28cc7
commit 4e8e1dc280
1 changed files with 41 additions and 7 deletions

View File

@ -206,6 +206,34 @@ _efl_canvas_animation_player_efl_player_start(Eo *eo_obj,
_start(eo_obj, pd); _start(eo_obj, pd);
} }
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;
}
EOLIAN static void EOLIAN static void
_efl_canvas_animation_player_efl_player_stop(Eo *eo_obj, _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj,
Efl_Canvas_Animation_Player_Data *pd) Efl_Canvas_Animation_Player_Data *pd)
@ -219,11 +247,12 @@ _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj,
if (play) if (play)
{ {
efl_player_play_set(eo_obj, EINA_FALSE); efl_player_play_set(eo_obj, EINA_FALSE);
if ((efl_animation_final_state_keep_get(anim)) && if (efl_animation_final_state_keep_get(anim))
(efl_animation_repeat_mode_get(anim) != EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE) &&
(!(efl_animation_repeat_count_get(anim) & 1)))
{ {
pd->progress = 1.0; if (_is_final_state(anim, pd->progress))
{
/* Keep the final state only if efl_player_stop is called at
* the end of _animator_cb. */
efl_animation_apply(anim, pd->progress, efl_animation_apply(anim, pd->progress,
efl_animation_player_target_get(eo_obj)); efl_animation_player_target_get(eo_obj));
} }
@ -231,6 +260,11 @@ _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj,
{ {
pd->progress = 0.0; pd->progress = 0.0;
} }
}
else
{
pd->progress = 0.0;
}
efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL); efl_event_callback_call(eo_obj, EFL_ANIMATION_PLAYER_EVENT_ENDED, NULL);
} }
else else