jaehyun pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4e8e1dc280a182448f698cf72a8df18f88342723

commit 4e8e1dc280a182448f698cf72a8df18f88342723
Author: Jaehyun Cho <jae_hyun....@samsung.com>
Date:   Tue Jun 4 21:49:08 2019 +0900

    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.
---
 src/lib/evas/canvas/efl_canvas_animation_player.c | 48 +++++++++++++++++++----
 1 file changed, 41 insertions(+), 7 deletions(-)

diff --git a/src/lib/evas/canvas/efl_canvas_animation_player.c 
b/src/lib/evas/canvas/efl_canvas_animation_player.c
index edb4d66c53..8466067a12 100644
--- a/src/lib/evas/canvas/efl_canvas_animation_player.c
+++ b/src/lib/evas/canvas/efl_canvas_animation_player.c
@@ -206,6 +206,34 @@ _efl_canvas_animation_player_efl_player_start(Eo *eo_obj,
    _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
 _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj,
                                       Efl_Canvas_Animation_Player_Data *pd)
@@ -219,13 +247,19 @@ _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj,
    if (play)
      {
         efl_player_play_set(eo_obj, EINA_FALSE);
-        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)))
+        if (efl_animation_final_state_keep_get(anim))
           {
-               pd->progress = 1.0;
-               efl_animation_apply(anim, pd->progress,
-                                   efl_animation_player_target_get(eo_obj));
+             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_player_target_get(eo_obj));
+               }
+             else
+               {
+                  pd->progress = 0.0;
+               }
           }
         else
           {
@@ -235,7 +269,7 @@ _efl_canvas_animation_player_efl_player_stop(Eo *eo_obj,
      }
    else
      {
-         pd->progress = 0.0;
+        pd->progress = 0.0;
      }
 
    if (pd->auto_del) efl_del(eo_obj);

-- 


Reply via email to