Efl.Canvas.Animation: Rename repeat_count to play_count
authorXavi Artigas <xavierartigas@yahoo.es>
Wed, 4 Dec 2019 16:25:45 +0000 (17:25 +0100)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 4 Dec 2019 21:22:12 +0000 (06:22 +0900)
Summary:
play_count is a tad simpler to understand, since it means the TOTAL number of
times the animation will play.
The default value is now 1, and 0 means INFINITE (instead of -1). This allows
removing yet another constant from header files.

Depends on D10799

Test Plan: Everything builds and passes tests. Elm_test Animation.Repeat has been adjusted accordingly.

Reviewers: bu5hm4n

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10800

src/bin/elementary/test_efl_anim_repeat.c
src/examples/evas/efl-canvas-animation.c
src/lib/evas/Evas_Common.h
src/lib/evas/Evas_Eo.h
src/lib/evas/canvas/efl_canvas_animation.c
src/lib/evas/canvas/efl_canvas_animation.eo
src/lib/evas/canvas/efl_canvas_animation_private.h
src/lib/evas/canvas/efl_canvas_animation_types.eot
src/lib/evas/canvas/efl_canvas_object_animation.c

index 0f72882..b3dddcd 100644 (file)
@@ -10,7 +10,7 @@ typedef struct _App_Data
    Elm_Button                  *button;
 
    Evas_Object          *start_btn;
-   Evas_Object          *repeat_count_spin;
+   Evas_Object          *play_count_spin;
    Evas_Object          *repeat_mode_spin;
 
    Eina_Bool             is_btn_visible;
@@ -44,8 +44,8 @@ _anim_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
         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)
+             int play_count = elm_spinner_value_get(ad->play_count_spin);
+             if (play_count % 2 == 0)
                {
                   ad->is_btn_visible = !(ad->is_btn_visible);
                   if (ad->is_btn_visible)
@@ -54,7 +54,7 @@ _anim_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
                     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->play_count_spin, EINA_FALSE);
         elm_object_disabled_set(ad->repeat_mode_spin, EINA_FALSE);
      }
 }
@@ -78,16 +78,16 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
 
    ad->is_btn_visible = !(ad->is_btn_visible);
 
-   int repeat_count = elm_spinner_value_get(ad->repeat_count_spin);
-   elm_object_disabled_set(ad->repeat_count_spin, EINA_TRUE);
+   int play_count = elm_spinner_value_get(ad->play_count_spin);
+   elm_object_disabled_set(ad->play_count_spin, EINA_TRUE);
 
    Efl_Canvas_Animation_Repeat_Mode repeat_mode = _anim_repeat_mode_get(ad->repeat_mode_spin);
    elm_object_disabled_set(ad->repeat_mode_spin, EINA_TRUE);
 
    if (ad->is_btn_visible)
      {
-        //Set animation repeat count
-        efl_animation_repeat_count_set(ad->show_anim, repeat_count);
+        //Set animation play count
+        efl_animation_play_count_set(ad->show_anim, play_count);
 
         //Set animation repeat mode
         efl_animation_repeat_mode_set(ad->show_anim, repeat_mode);
@@ -99,7 +99,7 @@ _start_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
    else
      {
         //Set animation repeat count
-        efl_animation_repeat_count_set(ad->hide_anim, repeat_count);
+        efl_animation_play_count_set(ad->hide_anim, play_count);
 
         //Set animation repeat mode
         efl_animation_repeat_mode_set(ad->hide_anim, repeat_mode);
@@ -158,15 +158,15 @@ test_efl_anim_repeat(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
    evas_object_move(start_btn, 100, 300);
    evas_object_show(start_btn);
 
-   //Spinner to set animation repeat count
-   Evas_Object *repeat_count_spin = elm_spinner_add(win);
-   elm_spinner_label_format_set(repeat_count_spin, "Repeat Count: %d");
-   elm_spinner_editable_set(repeat_count_spin, EINA_FALSE);
-   elm_spinner_min_max_set(repeat_count_spin, 0, 3);
-   elm_spinner_value_set(repeat_count_spin, 0);
-   evas_object_resize(repeat_count_spin, 200, 50);
-   evas_object_move(repeat_count_spin, 100, 350);
-   evas_object_show(repeat_count_spin);
+   //Spinner to set animation play count
+   Evas_Object *play_count_spin = elm_spinner_add(win);
+   elm_spinner_label_format_set(play_count_spin, "Play Count (0 is infinite): %d");
+   elm_spinner_editable_set(play_count_spin, EINA_FALSE);
+   elm_spinner_min_max_set(play_count_spin, 0, 3);
+   elm_spinner_value_set(play_count_spin, 1);
+   evas_object_resize(play_count_spin, 200, 50);
+   evas_object_move(play_count_spin, 100, 350);
+   evas_object_show(play_count_spin);
 
    //Spinner to set animation repeat mode
    Evas_Object *repeat_mode_spin = elm_spinner_add(win);
@@ -184,7 +184,7 @@ test_efl_anim_repeat(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
    ad->show_anim = show_anim;
    ad->hide_anim = hide_anim;
    ad->start_btn = start_btn;
-   ad->repeat_count_spin = repeat_count_spin;
+   ad->play_count_spin = play_count_spin;
    ad->repeat_mode_spin = repeat_mode_spin;
    ad->is_btn_visible = EINA_TRUE;
    ad->button = btn;
index 2cc2355..cc24550 100644 (file)
@@ -118,7 +118,7 @@ main(void)
       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)
+      efl_animation_play_count_set(efl_added, 0)
     ),
    1.0, 0.0);
 
@@ -128,7 +128,7 @@ main(void)
     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_play_count_set(efl_added, 0),
       efl_animation_repeat_mode_set(efl_added, EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
     ),
    1.0, 0.0);
@@ -139,7 +139,7 @@ main(void)
     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_play_count_set(efl_added, 4),
       efl_animation_repeat_mode_set(efl_added, EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE)
     ),
    1.0, 0.0);
@@ -162,7 +162,7 @@ main(void)
     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)
+      efl_animation_play_count_set(efl_added, 0)
     ),
    1.0, 0.0);
    d.current_speed = 1.0;
index 5d7bfb2..b755611 100644 (file)
@@ -3497,8 +3497,6 @@ typedef Eo Efl_Animation_Group_Sequential;
 
 #endif
 
-#define EFL_ANIMATION_REPEAT_INFINITE -1
-
 // The below type are necessary for legacy API and need to be manually kept in sync with .eo file.
 #ifndef _EFL_INPUT_DEVICE_EO_CLASS_TYPE
 #define _EFL_INPUT_DEVICE_EO_CLASS_TYPE
index f156ec5..9d873d5 100644 (file)
@@ -122,8 +122,6 @@ typedef Eo Efl_Canvas_Animation_Group_Sequential;
 
 #endif
 
-#define EFL_ANIMATION_REPEAT_INFINITE -1
-
 struct _Efl_Canvas_Animation_Player_Event_Running
 {
    double progress;
index 001dca7..53d006f 100644 (file)
@@ -52,19 +52,19 @@ _efl_canvas_animation_repeat_mode_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_A
 }
 
 EOLIAN static void
-_efl_canvas_animation_repeat_count_set(Eo *eo_obj EINA_UNUSED,
+_efl_canvas_animation_play_count_set(Eo *eo_obj EINA_UNUSED,
                                 Efl_Canvas_Animation_Data *pd,
                                 int count)
 {
-   EINA_SAFETY_ON_FALSE_RETURN(count >= EFL_ANIMATION_REPEAT_INFINITE);
+   EINA_SAFETY_ON_FALSE_RETURN(count >= 0);
 
-   pd->repeat_count = count;
+   pd->play_count = count;
 }
 
 EOLIAN static int
-_efl_canvas_animation_repeat_count_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Data *pd)
+_efl_canvas_animation_play_count_get(const Eo *eo_obj EINA_UNUSED, Efl_Canvas_Animation_Data *pd)
 {
-   return pd->repeat_count;
+   return pd->play_count;
 }
 
 EOLIAN static void
@@ -115,12 +115,12 @@ _efl_canvas_animation_animation_apply(Eo *eo_obj,
 EOLIAN static double
 _efl_canvas_animation_efl_playable_length_get(const Eo *eo_obj, Efl_Canvas_Animation_Data *pd EINA_UNUSED)
 {
-   if (efl_animation_repeat_count_get(eo_obj) == EFL_ANIMATION_REPEAT_INFINITE)
+   if (efl_animation_play_count_get(eo_obj) == 0)
      {
         return INFINITY;
      }
 
-   return (efl_animation_duration_get(eo_obj) * (efl_animation_repeat_count_get(eo_obj) + 1));
+   return (efl_animation_duration_get(eo_obj) * efl_animation_play_count_get(eo_obj));
 }
 
 EOLIAN static Eina_Bool
@@ -139,6 +139,7 @@ EOLIAN static Efl_Object*
 _efl_canvas_animation_efl_object_constructor(Eo *obj, Efl_Canvas_Animation_Data *pd)
 {
    pd->duration = _default_animation_time;
+   pd->play_count = 1;
    return efl_constructor(efl_super(obj, MY_CLASS));
 }
 
index a55cf73..49bd1cb 100644 (file)
@@ -40,7 +40,7 @@ class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable
       @property duration {
          [[The duration of a single animation "run".
            The @Efl.Playable.length implementation will return this duration adjusted by @.repeat_mode and
-           @.repeat_count.
+           @.play_count.
          ]]
          set {
          }
@@ -61,13 +61,15 @@ class @beta Efl.Canvas.Animation extends Efl.Object implements Efl.Playable
             mode: Efl.Canvas.Animation_Repeat_Mode(Efl.Canvas.Animation_Repeat_Mode.restart); [[Repeat mode.]]
          }
       }
-      @property repeat_count {
-         [[How many times to repeat an animation once it finishes.
-           $[0] means that the animation only plays once (it is not repeated) and is the default value.
-           $[-1] means that the animation is repeated forever.
+      @property play_count {
+         [[How many times to play an animation.
+           $[1] means that the animation only plays once (it is not repeated), whereas $[2] will play it
+           again once it finishes the first time and then stop.
+           $[0] means that the animation is repeated forever.
+           @.repeat_mode controls the direction in which subsequent playbacks will run.
          ]]
          values {
-            count: int(0); [[Repeat count.]]
+            count: int(1); [[Play count.]]
          }
       }
       @property start_delay {
index c8f0609..9995d23 100644 (file)
@@ -10,7 +10,7 @@ typedef struct _Efl_Canvas_Animation_Data
    double                    start_delay_time;
 
    Efl_Canvas_Animation_Repeat_Mode repeat_mode;
-   int                       repeat_count;
+   int                       play_count;
 
    Efl_Interpolator         *interpolator;
 
@@ -25,4 +25,4 @@ typedef struct _Efl_Canvas_Animation_Data
 
 #define FINAL_STATE_IS_REVERSE(anim) \
    ((efl_animation_repeat_mode_get(anim) == EFL_CANVAS_ANIMATION_REPEAT_MODE_REVERSE) && \
-    (efl_animation_repeat_count_get(anim) & 1))
+    (efl_animation_play_count_get(anim) & 1))
index cfdda2d..bb44fe4 100644 (file)
@@ -5,9 +5,11 @@ struct @beta Efl.Canvas.Animation_Player_Event_Running; [[Information of event r
 
 enum @beta Efl.Canvas.Animation_Repeat_Mode
 {
-   [[Animation repeat mode]]
+   [[Animation repeat mode.]]
 
-   restart = 0, [[Restart animation when the animation ends.]]
-   reverse = 1, [[Reverse animation when the animation ends.]]
+   restart = 0, [[Restart animation when the animation ends: The animation will play again from the beginning to the
+                  end.]]
+   reverse = 1, [[Reverse animation when the animation ends: The animation will continue playing from the end to the
+                  beginning.]]
    last
 }
index 5663833..3fbc0e9 100644 (file)
@@ -70,7 +70,7 @@ _animator_cb(void *data, const Efl_Event *ev EINA_UNUSED)
        (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) ||
+        if ((efl_animation_play_count_get(pd->in->animation) == 0) ||
             (pd->in->remaining_repeats > 0))
           {
              pd->in->remaining_repeats--;
@@ -167,7 +167,7 @@ _efl_canvas_object_animation_animation_start(Eo *obj, Efl_Canvas_Object_Animatio
 
    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->remaining_repeats = efl_animation_play_count_get(animation) - 1; // -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);