[SLP Merge] Thu Jul 7 13:20:56 2011 +0900
[framework/uifw/elementary.git] / src / lib / elm_animator.c
index fd4a741..5808495 100644 (file)
    } while (0)
 
 
-/**
- * @addtogroup Animator Animator
- * @ingroup Elementary
- *
- * elm_animator is designed to provides animation frame.
- * It is somewhat different with any others widgets however elm_animator
- * might useful when your GUIs have animation.
- * Basically, it computes normalized frame value for animation,
- * provides additional functions to adjust this also.
- *
- */
-
 struct _Elm_Animator
 {
 #define ELM_ANIMATOR_MAGIC 0x40777770
@@ -44,7 +32,7 @@ struct _Elm_Animator
    void *completion_arg;
    Elm_Animator_Curve_Style curve_style;
    Eina_Bool auto_reverse:1;
-   Eina_Bool walking:1;
+   Eina_Bool on_animating:1;
 };
 
 static double _animator_curve_linear(double frame);
@@ -116,23 +104,23 @@ _animator_animate_cb(void *data)
    switch (animator->curve_style)
      {
        case ELM_ANIMATOR_CURVE_IN_OUT:
-             frame = _animator_curve_in_out(elapsed_time / animator->duration);
-             break;
+          frame = _animator_curve_in_out(elapsed_time / animator->duration);
+          break;
        case ELM_ANIMATOR_CURVE_IN:
-             frame = _animator_curve_in(elapsed_time / animator->duration);
-             break;
+          frame = _animator_curve_in(elapsed_time / animator->duration);
+          break;
        case ELM_ANIMATOR_CURVE_OUT:
-             frame = _animator_curve_out(elapsed_time / animator->duration);
-             break;
+          frame = _animator_curve_out(elapsed_time / animator->duration);
+          break;
        default:
-         frame = _animator_curve_linear(elapsed_time / animator->duration);
-             break;
+          frame = _animator_curve_linear(elapsed_time / animator->duration);
+          break;
      }
-       
+
    //Reverse?
    if (animator->auto_reverse)
      {
-       if (!(animator->cur_repeat_cnt % 2)) frame = 1 - frame;
+        if (!(animator->cur_repeat_cnt % 2)) frame = 1 - frame;
      }
 
    if (animator->duration > 0)
@@ -143,11 +131,11 @@ _animator_animate_cb(void *data)
    //Repeat and reverse and time done!
    if (!animator->cur_repeat_cnt)
      {
-       animator->walking = EINA_FALSE;
-       _delete_animator(animator);
-       if (animator->completion_op)
-          animator->completion_op(animator->completion_arg);
-       return ECORE_CALLBACK_CANCEL;
+        animator->on_animating = EINA_FALSE;
+        _delete_animator(animator);
+        if (animator->completion_op)
+          animator->completion_op(animator->completion_arg);
+        return ECORE_CALLBACK_CANCEL;
      }
 
    //Repeat Case
@@ -159,19 +147,11 @@ _animator_animate_cb(void *data)
 
 static void
 _animator_parent_del(void *data, Evas *evas __UNUSED__,
-                    Evas_Object *obj __UNUSED__, void *event __UNUSED__)
+                     Evas_Object *obj __UNUSED__, void *event __UNUSED__)
 {
    elm_animator_del(data);
 }
 
-/**
- * Get the value of reverse mode.
- *
- * @param[in] animator Animator object
- * @return EINA_TRUE is reverse mode
- *
- * @ingroup Animator
- */
 EAPI Eina_Bool
 elm_animator_auto_reverse_get(const Elm_Animator *animator)
 {
@@ -179,14 +159,6 @@ elm_animator_auto_reverse_get(const Elm_Animator *animator)
    return animator->auto_reverse;
 }
 
-/**
- * Get the value of repeat count.
- *
- * @param[in] animator Animator object
- * @return Repeat count
- *
- * @ingroup Animator
- */
 EAPI unsigned int
 elm_animator_repeat_get(const Elm_Animator *animator)
 {
@@ -194,30 +166,13 @@ elm_animator_repeat_get(const Elm_Animator *animator)
    return animator->repeat_cnt;
 }
 
-/**
- * Set the animation acceleration style.
- *
- * @param[in] animator Animator object
- * @param[in] cs Curve style. Default is ELM_ANIMATOR_CURVE_LINEAR
- *
- * @ingroup Animator
- */
-EAPI Elm_Animator_Curve_Style 
+EAPI Elm_Animator_Curve_Style
 elm_animator_curve_style_get(const Elm_Animator *animator)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator, ELM_ANIMATOR_CURVE_LINEAR);
-  
-       return animator->curve_style;
+   return animator->curve_style;
 }
 
-/**
- * Set auto reverse function.
- *
- * @param[in] animator Animator object
- * @param[in] reverse Reverse or not
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_auto_reverse_set(Elm_Animator *animator, Eina_Bool reverse)
 {
@@ -226,74 +181,38 @@ elm_animator_auto_reverse_set(Elm_Animator *animator, Eina_Bool reverse)
    animator->auto_reverse = reverse;
    if (reverse)
       animator->repeat_cnt =
-        _animator_compute_reverse_repeat_count(animator->repeat_cnt);
+        _animator_compute_reverse_repeat_count(animator->repeat_cnt);
    else
       animator->repeat_cnt =
-        _animator_compute_no_reverse_repeat_count(animator->repeat_cnt);
+        _animator_compute_no_reverse_repeat_count(animator->repeat_cnt);
 }
 
-/**
- * Set the animation acceleration style.
- *
- * @param[in] animator Animator object
- * @param[in] cs Curve style. Default is ELM_ANIMATOR_CURVE_LINEAR
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_curve_style_set(Elm_Animator *animator,
-                            Elm_Animator_Curve_Style cs)
+                             Elm_Animator_Curve_Style cs)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator);
-
-       animator->curve_style = cs;
+   animator->curve_style = cs;
 }
-
-/**
- * Set the operation duration.
- *
- * @param[in] animator Animator object
- * @param[in] duration Duration in second
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_duration_set(Elm_Animator *animator, double duration)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator);
-   if (animator->walking) return;
+   if (animator->on_animating) return;
    animator->duration = duration;
 }
 
-/**
- * Set the callback function for animator operation.
- * The range of callback function frame data is to 0 ~ 1
- * User can refer this frame value for one's animation frame data.
- * @param[in] animator Animator object
- * @param[in] func Callback function pointer
- * @param[in] data Callback function user argument
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_operation_callback_set(Elm_Animator *animator,
                                     Elm_Animator_Operation_Cb func,
                                     void *data)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator);
-   if (animator->walking) return;
+   if (animator->on_animating) return;
    animator->animator_op = func;
    animator->animator_arg = data;
 }
 
-/**
- * Add new animator.
- *
- * @param[in] parent Parent object
- * @return animator object
- *
- * @ingroup Animator
- */
 EAPI Elm_Animator *
 elm_animator_add(Evas_Object *parent)
 {
@@ -305,32 +224,17 @@ elm_animator_add(Evas_Object *parent)
    elm_animator_curve_style_set(animator, ELM_ANIMATOR_CURVE_LINEAR);
    if (parent)
       evas_object_event_callback_add(parent, EVAS_CALLBACK_DEL,
-                                    _animator_parent_del, animator);
+                                     _animator_parent_del, animator);
    return animator;
 }
 
-/**
- * Get the status for the animator operation.
- *
- * @param[in] animator Animator object
- * @return EINA_TRUE is animator is operating.
- *
- * @ingroup Animator
- */
 EAPI Eina_Bool
 elm_animator_operating_get(const Elm_Animator *animator)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator, EINA_FALSE);
-   return animator->walking;
+   return animator->on_animating;
 }
 
-/**
- * Delete animator.
- *
- * @param[in] animator Animator object
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_del(Elm_Animator *animator)
 {
@@ -338,85 +242,47 @@ elm_animator_del(Elm_Animator *animator)
    _delete_animator(animator);
    if (animator->parent)
       evas_object_event_callback_del(animator->parent, EVAS_CALLBACK_DEL,
-                                    _animator_parent_del);
+                                     _animator_parent_del);
 
    EINA_MAGIC_SET(animator, EINA_MAGIC_NONE);
    free(animator);
 }
 
-/**
- * Set the callback function for the animator end.
- *
- * @param[in]  animator Animator object
- * @param[in]  func   Callback function pointe
- * @param[in]  data Callback function user argument
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_completion_callback_set(Elm_Animator *animator,
-                                    Elm_Animator_Completion_Cb func,
+                                     Elm_Animator_Completion_Cb func,
                                      void *data)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator);
-   if (animator->walking) return;
+   if (animator->on_animating) return;
    animator->completion_op = func;
    animator->completion_arg = data;
 }
 
-/**
- * Pause the animator.
- *
- * @param[in]  animator Animator object
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_pause(Elm_Animator *animator)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator);
-   if (!animator->walking) return;
+   if (!animator->on_animating) return;
    ecore_animator_freeze(animator->animator);
 }
 
-/**
- * Resume the animator.
- *
- * @param[in]  animator Animator object
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_resume(Elm_Animator *animator)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator);
-   if (!animator->walking) return;
+   if (!animator->on_animating) return;
    ecore_animator_thaw(animator->animator);
 }
 
-/**
- * Stop animator.
- *
- * @param[in] animator Animator object
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_stop(Elm_Animator *animator)
 {
    ELM_ANIMATOR_CHECK_OR_RETURN(animator);
-   animator->walking = EINA_FALSE;
+   animator->on_animating = EINA_FALSE;
    _delete_animator(animator);
 }
 
-/**
- * Set the animator repeat count.
- *
- * @param[in]  animator Animator object
- * @param[in]  repeat_cnt Repeat count
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_repeat_set(Elm_Animator *animator, unsigned int repeat_cnt)
 {
@@ -426,13 +292,6 @@ elm_animator_repeat_set(Elm_Animator *animator, unsigned int repeat_cnt)
       animator->repeat_cnt = _animator_compute_reverse_repeat_count(repeat_cnt);
 }
 
-/**
- * Animate now.
- *
- * @param[in] animator Animator object
- *
- * @ingroup Animator
- */
 EAPI void
 elm_animator_animate(Elm_Animator *animator)
 {
@@ -442,5 +301,5 @@ elm_animator_animate(Elm_Animator *animator)
    animator->cur_repeat_cnt = animator->repeat_cnt;
    if (!animator->animator)
       animator->animator = ecore_animator_add(_animator_animate_cb, animator);
-   if (animator->animator) animator->walking = EINA_TRUE;
+   if (animator->animator) animator->on_animating = EINA_TRUE;
 }