hermet pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=8a46bf160273ecda8eac5b60c8c445b5e5a046e3

commit 8a46bf160273ecda8eac5b60c8c445b5e5a046e3
Author: jiin.moon <[email protected]>
Date:   Wed Dec 17 19:35:13 2014 +0900

    Transit: Support BEZIER CURVE
    
    Summary:
    Support BEZIER CURVE in elm transit
             @feature
    
    Reviewers: seoz, raster, Hermet
    
    Subscribers: raster, seoz
    
    Differential Revision: https://phab.enlightenment.org/D1759
---
 src/lib/elm_transit.c | 41 ++++++++++++++++++++++++++++-------------
 src/lib/elm_transit.h | 46 +++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 71 insertions(+), 16 deletions(-)

diff --git a/src/lib/elm_transit.c b/src/lib/elm_transit.c
index 394c77e..705d6b9 100644
--- a/src/lib/elm_transit.c
+++ b/src/lib/elm_transit.c
@@ -57,7 +57,7 @@ struct _Elm_Transit
    double progress;
    unsigned int effects_pending_del;
    int walking;
-   double v1, v2;
+   double v[4];
    Eina_Bool auto_reverse : 1;
    Eina_Bool event_enabled : 1;
    Eina_Bool deleted : 1;
@@ -348,34 +348,39 @@ _transit_animate_cb(void *data)
          transit->progress =
             ecore_animator_pos_map(transit->progress,
                                    ECORE_POS_MAP_ACCELERATE_FACTOR,
-                                   transit->v1, 0);
+                                   transit->v[0], 0);
          break;
       case ELM_TRANSIT_TWEEN_MODE_DECELERATE:
          transit->progress =
             ecore_animator_pos_map(transit->progress,
                                    ECORE_POS_MAP_DECELERATE_FACTOR,
-                                   transit->v1, 0);
+                                   transit->v[0], 0);
          break;
       case ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL:
          transit->progress =
             ecore_animator_pos_map(transit->progress,
                                    ECORE_POS_MAP_SINUSOIDAL_FACTOR,
-                                   transit->v1, 0);
+                                   transit->v[0], 0);
          break;
       case ELM_TRANSIT_TWEEN_MODE_DIVISOR_INTERP:
          transit->progress = ecore_animator_pos_map(transit->progress,
                                                     
ECORE_POS_MAP_DIVISOR_INTERP,
-                                                    transit->v1, transit->v2);
+                                                    transit->v[0], 
transit->v[1]);
          break;
       case ELM_TRANSIT_TWEEN_MODE_BOUNCE:
          transit->progress = ecore_animator_pos_map(transit->progress,
                                                     ECORE_POS_MAP_BOUNCE,
-                                                    transit->v1, transit->v2);
+                                                    transit->v[0], 
transit->v[1]);
          break;
       case ELM_TRANSIT_TWEEN_MODE_SPRING:
          transit->progress = ecore_animator_pos_map(transit->progress,
                                                     ECORE_POS_MAP_SPRING,
-                                                    transit->v1, transit->v2);
+                                                    transit->v[0], 
transit->v[1]);
+         break;
+      case ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE:
+         transit->progress = ecore_animator_pos_map_n(transit->progress,
+                                                      
ECORE_POS_MAP_CUBIC_BEZIER,
+                                                      4, transit->v);
          break;
       default:
          break;
@@ -477,8 +482,8 @@ elm_transit_add(void)
 
    elm_transit_tween_mode_set(transit, ELM_TRANSIT_TWEEN_MODE_LINEAR);
 
-   transit->v1 = 1.0;
-   transit->v2 = 0.0;
+   transit->v[0] = 1.0;
+   transit->v[1] = 0.0;
    transit->smooth = EINA_TRUE;
 
    return transit;
@@ -681,16 +686,26 @@ EAPI void
 elm_transit_tween_mode_factor_set(Elm_Transit *transit, double v1, double v2)
 {
    ELM_TRANSIT_CHECK_OR_RETURN(transit);
-   transit->v1 = v1;
-   transit->v2 = v2;
+   transit->v[0] = v1;
+   transit->v[1] = v2;
 }
 
 EAPI void
 elm_transit_tween_mode_factor_get(const Elm_Transit *transit, double *v1, 
double *v2)
 {
    ELM_TRANSIT_CHECK_OR_RETURN(transit);
-   if (v1) *v1 = transit->v1;
-   if (v2) *v2 = transit->v2;
+   if (v1) *v1 = transit->v[0];
+   if (v2) *v2 = transit->v[1];
+}
+
+EAPI void
+elm_transit_tween_mode_factor_n_set(Elm_Transit *transit, unsigned int v_size, 
double *v)
+{
+   int i;
+   ELM_TRANSIT_CHECK_OR_RETURN(transit);
+   if (v_size > 4) v_size = 4;
+   for (i = 0; i < v_size; i++)
+     transit->v[i] = v[i];
 }
 
 EAPI void
diff --git a/src/lib/elm_transit.h b/src/lib/elm_transit.h
index 32ffe59..a99bc87 100644
--- a/src/lib/elm_transit.h
+++ b/src/lib/elm_transit.h
@@ -74,9 +74,13 @@ typedef enum
    ELM_TRANSIT_TWEEN_MODE_BOUNCE, /**< Start at 0.0 then "drop" like a ball
                                      bouncing to the ground at 1.0, and
                                      bounce v2 times, with decay factor of v1 
*/
-   ELM_TRANSIT_TWEEN_MODE_SPRING /**< Start at 0.0 then "wobble" like a spring
-                                    rest position 1.0, and wobble v2 times,
-                                    with decay factor of v1 */
+   ELM_TRANSIT_TWEEN_MODE_SPRING, /**< Start at 0.0 then "wobble" like a spring
+                                     rest position 1.0, and wobble v2 times,
+                                     with decay factor of v1 */
+   ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE /**< @since 1.13
+                                          Follow the cubic-bezier curve
+                                          calculated with the control points
+                                          (x1, y1), (x2, y2) */
 } Elm_Transit_Tween_Mode;
 
 /**
@@ -502,6 +506,42 @@ EAPI void                   
elm_transit_tween_mode_factor_set(Elm_Transit *trans
 EAPI void                   elm_transit_tween_mode_factor_get(const 
Elm_Transit *transit, double *v1, double *v2);
 
 /**
+ * Set the transit animation acceleration factor.
+ *
+ * This function sets the tween mode factor of the transit that can be:
+ * If you use the below tween modes, you have to set the factor using this API.
+ * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL - Start slow, speed up then slow down
+ * at end, v[0] being a power factor, 0.0 being linear, 1.0 being
+ * ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL default, 2.0 being much more pronounced
+ * sinusoidal(squared), 3.0 being cubed, etc.
+ * ELM_TRANSIT_TWEEN_MODE_DECELERATE - Start fast then slow down, v[0] being a
+ * power factor, 0.0 being linear, 1.0 being ELM_TRANSIT_TWEEN_MODE_DECELERATE
+ * default, 2.0 being much more pronounced decelerate (squared), 3.0 being
+ * cubed, etc.
+ * ELM_TRANSIT_TWEEN_MODE_ACCELERATE - Start slow then speed up, v[0] being a
+ * power factor, 0.0 being linear, 1.0 being ELM_TRANSIT_TWEEN_MODE_ACCELERATE
+ * default, 2.0 being much more pronounced accelerate (squared), 3.0 being
+ * cubed, etc.
+ * ELM_TRANSIT_TWEEN_MODE_DIVISOR_INTERP - Start at gradient v[0], interpolated
+ * via power of v[1] curve
+ * ELM_TRANSIT_TWEEN_MODE_BOUNCE - Start at 0.0 then "drop" like a ball 
bouncing
+ * to the ground at 1.0, and bounce v[1] times, with decay factor of v[0]
+ * ELM_TRANSIT_TWEEN_MODE_SPRING - Start at 0.0 then "wobble" like a spring 
rest
+ * position 1.0, and wobble v[1] times, with decay factor of v[0]
+ * ELM_TRANSIT_TWEEN_MODE_BEZIER_CURVE - Use an interpolated cubic-bezier curve
+ * ajusted with parameters from v[0] to v[3]
+ *
+ * @param transit The transit object.
+ * @param v_size The size of the array pointing to v
+ * @param v The address of an array with the double parameters to be used by 
the mapping.
+ *
+ * @see elm_transit_tween_mode_factor_set()
+ * @since 1.13
+ * @ingroup Transit
+ */
+EAPI void                   elm_transit_tween_mode_factor_n_set(Elm_Transit 
*transit, unsigned int v_size, double *v);
+
+/**
  * Set the transit animation time
  *
  * @note @p transit can not be NULL

-- 


Reply via email to