[gnome-todo/gbsneto/listview2: 2/5] animation: Remove cubic-bezier and steps ease modes




commit ccfcb59f7f28320a96a8498c22787b4f9f34337c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Sep 26 11:26:33 2020 -0300

    animation: Remove cubic-bezier and steps ease modes
    
    We don't really need it in GNOME To Do. Our use cases are more
    self-contained and limited in scope, and the current ease modes
    are more than enough.

 src/animation/gtd-animation-enums.h |  28 -----
 src/animation/gtd-easing.c          |  99 ------------------
 src/animation/gtd-easing.h          |  16 ---
 src/animation/gtd-timeline.c        | 197 ------------------------------------
 src/animation/gtd-timeline.h        |  16 ---
 5 files changed, 356 deletions(-)
---
diff --git a/src/animation/gtd-animation-enums.h b/src/animation/gtd-animation-enums.h
index 4c57998..5b28fa5 100644
--- a/src/animation/gtd-animation-enums.h
+++ b/src/animation/gtd-animation-enums.h
@@ -79,22 +79,6 @@ G_BEGIN_DECLS
  *   tweening, with bounce on end
  * @GTD_EASE_IN_OUT_BOUNCE: exponentially decaying parabolic (bounce)
  *   tweening, with bounce on both ends
- * @GTD_STEPS: parametrized step function; see clutter_timeline_set_step_progress()
- *   for further details. (Since 1.12)
- * @GTD_STEP_START: equivalent to %GTD_STEPS with a number of steps
- *   equal to 1, and a step mode of %GTD_STEP_MODE_START. (Since 1.12)
- * @GTD_STEP_END: equivalent to %GTD_STEPS with a number of steps
- *   equal to 1, and a step mode of %GTD_STEP_MODE_END. (Since 1.12)
- * @GTD_CUBIC_BEZIER: cubic bezier between (0, 0) and (1, 1) with two
- *   control points; see clutter_timeline_set_cubic_bezier_progress(). (Since 1.12)
- * @GTD_EASE: equivalent to %GTD_CUBIC_BEZIER with control points
- *   in (0.25, 0.1) and (0.25, 1.0). (Since 1.12)
- * @GTD_EASE_IN: equivalent to %GTD_CUBIC_BEZIER with control points
- *   in (0.42, 0) and (1.0, 1.0). (Since 1.12)
- * @GTD_EASE_OUT: equivalent to %GTD_CUBIC_BEZIER with control points
- *   in (0, 0) and (0.58, 1.0). (Since 1.12)
- * @GTD_EASE_IN_OUT: equivalent to %GTD_CUBIC_BEZIER with control points
- *   in (0.42, 0) and (0.58, 1.0). (Since 1.12)
  * @GTD_ANIMATION_LAST: last animation mode, used as a guard for
  *   registered global alpha functions
  *
@@ -169,18 +153,6 @@ typedef enum
   GTD_EASE_OUT_BOUNCE,
   GTD_EASE_IN_OUT_BOUNCE,
 
-  /* step functions (see css3-transitions) */
-  GTD_STEPS,
-  GTD_STEP_START, /* steps(1, start) */
-  GTD_STEP_END, /* steps(1, end) */
-
-  /* cubic bezier (see css3-transitions) */
-  GTD_EASE_CUBIC_BEZIER,
-  GTD_EASE,
-  GTD_EASE_IN,
-  GTD_EASE_OUT,
-  GTD_EASE_IN_OUT,
-
   /* guard, before registered alpha functions */
   GTD_EASE_LAST
 } GtdEaseMode;
diff --git a/src/animation/gtd-easing.c b/src/animation/gtd-easing.c
index ef9a1c7..c674f91 100644
--- a/src/animation/gtd-easing.c
+++ b/src/animation/gtd-easing.c
@@ -397,94 +397,6 @@ gtd_ease_in_out_bounce (gdouble t,
     return ease_out_bounce_internal (t * 2 - d, d) * 0.5 + 1.0 * 0.5;
 }
 
-static inline gdouble
-ease_steps_end (gdouble p,
-                int    n_steps)
-{
-  return floor (p * (gdouble) n_steps) / (gdouble) n_steps;
-}
-
-gdouble
-gtd_ease_steps_start (gdouble t,
-                      gdouble d,
-                      int     n_steps)
-{
-  return 1.0 - ease_steps_end (1.0 - (t / d), n_steps);
-}
-
-gdouble
-gtd_ease_steps_end (gdouble t,
-                    gdouble d,
-                    int     n_steps)
-{
-  return ease_steps_end ((t / d), n_steps);
-}
-
-static inline gdouble
-x_for_t (gdouble t,
-         gdouble x_1,
-         gdouble x_2)
-{
-  gdouble omt = 1.0 - t;
-
-  return 3.0 * omt * omt * t * x_1
-       + 3.0 * omt * t * t * x_2
-       + t * t * t;
-}
-
-static inline gdouble
-y_for_t (gdouble t,
-         gdouble y_1,
-         gdouble y_2)
-{
-  gdouble omt = 1.0 - t;
-
-  return 3.0 * omt * omt * t * y_1
-       + 3.0 * omt * t * t * y_2
-       + t * t * t;
-}
-
-static inline gdouble
-t_for_x (gdouble x,
-         gdouble x_1,
-         gdouble x_2)
-{
-  gdouble min_t = 0, max_t = 1;
-  int i;
-
-  for (i = 0; i < 30; ++i)
-    {
-      gdouble guess_t = (min_t + max_t) / 2.0;
-      gdouble guess_x = x_for_t (guess_t, x_1, x_2);
-
-      if (x < guess_x)
-        max_t = guess_t;
-      else
-        min_t = guess_t;
-    }
-
-  return (min_t + max_t) / 2.0;
-}
-
-gdouble
-gtd_ease_cubic_bezier (gdouble t,
-                       gdouble d,
-                       gdouble x_1,
-                       gdouble y_1,
-                       gdouble x_2,
-                       gdouble y_2)
-{
-  gdouble p = t / d;
-
-  if (p == 0.0)
-    return 0.0;
-
-  if (p == 1.0)
-    return 1.0;
-
-  return y_for_t (t_for_x (p, x_1, x_2), y_1, y_2);
-}
-
 /*< private >
  * _gtd_animation_modes:
  *
@@ -529,17 +441,6 @@ static const struct {
   { GTD_EASE_OUT_BOUNCE,     gtd_ease_out_bounce, "easeOutBounce" },
   { GTD_EASE_IN_OUT_BOUNCE,  gtd_ease_in_out_bounce, "easeInOutBounce" },
 
-  /* the parametrized functions need a cast */
-  { GTD_STEPS,               (GtdEaseFunc) gtd_ease_steps_end, "steps" },
-  { GTD_STEP_START,          (GtdEaseFunc) gtd_ease_steps_start, "stepStart" },
-  { GTD_STEP_END,            (GtdEaseFunc) gtd_ease_steps_end, "stepEnd" },
-
-  { GTD_EASE_CUBIC_BEZIER,   (GtdEaseFunc) gtd_ease_cubic_bezier, "cubicBezier" },
-  { GTD_EASE,                (GtdEaseFunc) gtd_ease_cubic_bezier, "ease" },
-  { GTD_EASE_IN,             (GtdEaseFunc) gtd_ease_cubic_bezier, "easeIn" },
-  { GTD_EASE_OUT,            (GtdEaseFunc) gtd_ease_cubic_bezier, "easeOut" },
-  { GTD_EASE_IN_OUT,         (GtdEaseFunc) gtd_ease_cubic_bezier, "easeInOut" },
-
   { GTD_EASE_LAST,           NULL, "sentinel" },
 };
 
diff --git a/src/animation/gtd-easing.h b/src/animation/gtd-easing.h
index 71800bd..b83bb7f 100644
--- a/src/animation/gtd-easing.h
+++ b/src/animation/gtd-easing.h
@@ -138,20 +138,4 @@ gdouble              gtd_ease_out_bounce                         (gdouble
 gdouble              gtd_ease_in_out_bounce                      (gdouble            t,
                                                                   gdouble            d);
 
-gdouble              gtd_ease_steps_start                        (gdouble            t,
-                                                                  gdouble            d,
-                                                                  int                steps);
-
-gdouble              gtd_ease_steps_end                          (gdouble            t,
-                                                                  gdouble            d,
-                                                                  int                steps);
-
-gdouble              gtd_ease_cubic_bezier                       (gdouble            t,
-                                                                  gdouble            d,
-                                                                  gdouble            x_1,
-                                                                  gdouble            y_1,
-                                                                  gdouble            x_2,
-                                                                  gdouble            y_2);
-
-
 G_END_DECLS
diff --git a/src/animation/gtd-timeline.c b/src/animation/gtd-timeline.c
index 7c2e684..19908d4 100644
--- a/src/animation/gtd-timeline.c
+++ b/src/animation/gtd-timeline.c
@@ -1660,50 +1660,6 @@ gtd_timeline_progress_func (GtdTimeline *self,
 {
   GtdTimelinePrivate *priv = gtd_timeline_get_instance_private (self);
 
-  /* parametrized easing functions need to be handled separately */
-  switch (priv->progress_mode)
-    {
-    case GTD_STEPS:
-      if (priv->step_mode == GTD_STEP_MODE_START)
-        return gtd_ease_steps_start (elapsed, duration, priv->n_steps);
-      else if (priv->step_mode == GTD_STEP_MODE_END)
-        return gtd_ease_steps_end (elapsed, duration, priv->n_steps);
-      else
-        g_assert_not_reached ();
-      break;
-
-    case GTD_STEP_START:
-      return gtd_ease_steps_start (elapsed, duration, 1);
-
-    case GTD_STEP_END:
-      return gtd_ease_steps_end (elapsed, duration, 1);
-
-    case GTD_EASE_CUBIC_BEZIER:
-      return gtd_ease_cubic_bezier (elapsed, duration,
-                                    priv->cb_1.x, priv->cb_1.y,
-                                    priv->cb_2.x, priv->cb_2.y);
-
-    case GTD_EASE:
-      return gtd_ease_cubic_bezier (elapsed, duration,
-                                    0.25, 0.1, 0.25, 1.0);
-
-    case GTD_EASE_IN:
-      return gtd_ease_cubic_bezier (elapsed,
-                                    duration,
-                                    0.42, 0.0, 1.0, 1.0);
-
-    case GTD_EASE_OUT:
-      return gtd_ease_cubic_bezier (elapsed, duration,
-                                    0.0, 0.0, 0.58, 1.0);
-
-    case GTD_EASE_IN_OUT:
-      return gtd_ease_cubic_bezier (elapsed, duration,
-                                    0.42, 0.0, 0.58, 1.0);
-
-    default:
-      break;
-    }
-
   return gtd_easing_for_mode (priv->progress_mode, elapsed, duration);
 }
 
@@ -1829,159 +1785,6 @@ gtd_timeline_get_current_repeat (GtdTimeline *self)
   return priv->current_repeat;
 }
 
-/**
- * gtd_timeline_set_step_progress:
- * @timeline: a #GtdTimeline
- * @n_steps: the number of steps
- * @step_mode: whether the change should happen at the start
- *   or at the end of the step
- *
- * Sets the #GtdTimeline:progress-mode of the @timeline to %GTD_STEPS
- * and provides the parameters of the step function.
- *
- * Since: 1.12
- */
-void
-gtd_timeline_set_step_progress (GtdTimeline *self,
-                                gint         n_steps,
-                                GtdStepMode  step_mode)
-{
-  GtdTimelinePrivate *priv;
-
-  g_return_if_fail (GTD_IS_TIMELINE (self));
-  g_return_if_fail (n_steps > 0);
-
-  priv = gtd_timeline_get_instance_private (self);
-
-  if (priv->progress_mode == GTD_STEPS &&
-      priv->n_steps == n_steps &&
-      priv->step_mode == step_mode)
-    return;
-
-  priv->n_steps = n_steps;
-  priv->step_mode = step_mode;
-  gtd_timeline_set_progress_mode (self, GTD_STEPS);
-}
-
-/**
- * gtd_timeline_get_step_progress:
- * @timeline: a #GtdTimeline
- * @n_steps: (out): return location for the number of steps, or %NULL
- * @step_mode: (out): return location for the value change policy,
- *   or %NULL
- *
- * Retrieves the parameters of the step progress mode used by @timeline.
- *
- * Return value: %TRUE if the @timeline is using a step progress
- *   mode, and %FALSE otherwise
- *
- * Since: 1.12
- */
-gboolean
-gtd_timeline_get_step_progress (GtdTimeline *self,
-                                gint        *n_steps,
-                                GtdStepMode *step_mode)
-{
-  GtdTimelinePrivate *priv;
-
-  g_return_val_if_fail (GTD_IS_TIMELINE (self), FALSE);
-
-  priv = gtd_timeline_get_instance_private (self);
-
-  if (!(priv->progress_mode == GTD_STEPS ||
-        priv->progress_mode == GTD_STEP_START ||
-        priv->progress_mode == GTD_STEP_END))
-    return FALSE;
-
-  if (n_steps != NULL)
-    *n_steps = priv->n_steps;
-
-  if (step_mode != NULL)
-    *step_mode = priv->step_mode;
-
-  return TRUE;
-}
-
-/**
- * gtd_timeline_set_cubic_bezier_progress:
- * @timeline: a #GtdTimeline
- * @c_1: the first control point for the cubic bezier
- * @c_2: the second control point for the cubic bezier
- *
- * Sets the #GtdTimeline:progress-mode of @timeline
- * to %GTD_CUBIC_BEZIER, and sets the two control
- * points for the cubic bezier.
- *
- * The cubic bezier curve is between (0, 0) and (1, 1). The X coordinate
- * of the two control points must be in the [ 0, 1 ] range, while the
- * Y coordinate of the two control points can exceed this range.
- *
- * Since: 1.12
- */
-void
-gtd_timeline_set_cubic_bezier_progress (GtdTimeline            *self,
-                                        const graphene_point_t *c_1,
-                                        const graphene_point_t *c_2)
-{
-  GtdTimelinePrivate *priv;
-
-  g_return_if_fail (GTD_IS_TIMELINE (self));
-  g_return_if_fail (c_1 != NULL && c_2 != NULL);
-
-  priv = gtd_timeline_get_instance_private (self);
-
-  priv->cb_1 = *c_1;
-  priv->cb_2 = *c_2;
-
-  /* ensure the range on the X coordinate */
-  priv->cb_1.x = CLAMP (priv->cb_1.x, 0.f, 1.f);
-  priv->cb_2.x = CLAMP (priv->cb_2.x, 0.f, 1.f);
-
-  gtd_timeline_set_progress_mode (self, GTD_EASE_CUBIC_BEZIER);
-}
-
-/**
- * gtd_timeline_get_cubic_bezier_progress:
- * @timeline: a #GtdTimeline
- * @c_1: (out caller-allocates): return location for the first control
- *   point of the cubic bezier, or %NULL
- * @c_2: (out caller-allocates): return location for the second control
- *   point of the cubic bezier, or %NULL
- *
- * Retrieves the control points for the cubic bezier progress mode.
- *
- * Return value: %TRUE if the @timeline is using a cubic bezier progress
- *   more, and %FALSE otherwise
- *
- * Since: 1.12
- */
-gboolean
-gtd_timeline_get_cubic_bezier_progress (GtdTimeline      *self,
-                                        graphene_point_t *c_1,
-                                        graphene_point_t *c_2)
-{
-  GtdTimelinePrivate *priv;
-
-  g_return_val_if_fail (GTD_IS_TIMELINE (self), FALSE);
-
-  priv = gtd_timeline_get_instance_private (self);
-
-  if (!(priv->progress_mode == GTD_EASE_CUBIC_BEZIER ||
-        priv->progress_mode == GTD_EASE ||
-        priv->progress_mode == GTD_EASE_IN ||
-        priv->progress_mode == GTD_EASE_OUT ||
-        priv->progress_mode == GTD_EASE_IN_OUT))
-    return FALSE;
-
-  if (c_1 != NULL)
-    *c_1 = priv->cb_1;
-
-  if (c_2 != NULL)
-    *c_2 = priv->cb_2;
-
-  return TRUE;
-}
-
 void
 gtd_timeline_cancel_delay (GtdTimeline *self)
 {
diff --git a/src/animation/gtd-timeline.h b/src/animation/gtd-timeline.h
index 1dd775e..c4d9aef 100644
--- a/src/animation/gtd-timeline.h
+++ b/src/animation/gtd-timeline.h
@@ -144,22 +144,6 @@ void                 gtd_timeline_set_progress_mode              (GtdTimeline
 
 GtdEaseMode          gtd_timeline_get_progress_mode              (GtdTimeline          *timeline);
 
-void                 gtd_timeline_set_step_progress              (GtdTimeline          *timeline,
-                                                                  gint                  n_steps,
-                                                                  GtdStepMode           step_mode);
-
-gboolean             gtd_timeline_get_step_progress              (GtdTimeline          *timeline,
-                                                                  gint                 *n_steps,
-                                                                  GtdStepMode          *step_mode);
-
-void                 gtd_timeline_set_cubic_bezier_progress      (GtdTimeline            *timeline,
-                                                                  const graphene_point_t *c_1,
-                                                                  const graphene_point_t *c_2);
-
-gboolean             gtd_timeline_get_cubic_bezier_progress      (GtdTimeline      *timeline,
-                                                                  graphene_point_t *c_1,
-                                                                  graphene_point_t *c_2);
-
 gint64               gtd_timeline_get_duration_hint              (GtdTimeline          *timeline);
 gint                 gtd_timeline_get_current_repeat             (GtdTimeline          *timeline);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]