Example #1
0
static void
gtk_switch_on_frame_clock_update (GdkFrameClock *clock,
                                  GtkSwitch     *sw)
{
  GtkSwitchPrivate *priv = sw->priv;
  gint64 now;

  now = gdk_frame_clock_get_frame_time (clock);

  if (now < priv->end_time)
    {
      gdouble t;
      gint dest_offset;

      if (priv->is_active)
        dest_offset = 0;
      else
        dest_offset = gtk_widget_get_allocated_width (GTK_WIDGET (sw)) / 2;

      t = (now - priv->start_time) / (gdouble) (priv->end_time - priv->start_time);
      t = ease_out_cubic (t);
      priv->handle_x = priv->offset + t * (dest_offset - priv->offset);
    }
  else
    {
      gtk_switch_set_active (sw, !priv->is_active);
    }

  gtk_widget_queue_draw (GTK_WIDGET (sw));
}
Example #2
0
static int
get_bin_window_x (GdStack *stack, GtkAllocation *allocation)
{
  GdStackPrivate *priv = stack->priv;
  int x = 0;

  if (priv->transition_pos < 1.0)
    {
      if (priv->transition_type == GD_STACK_TRANSITION_TYPE_SLIDE_LEFT)
        x = allocation->width * (1 - ease_out_cubic (priv->transition_pos));
      if (priv->transition_type == GD_STACK_TRANSITION_TYPE_SLIDE_RIGHT)
        x = -allocation->width * (1 - ease_out_cubic (priv->transition_pos));
    }

  return x;
}
static gboolean on_tick_callback(DeepinFixed* self, GdkFrameClock* clock, 
        gpointer data)
{
    DeepinFixedPrivate* priv = self->priv;
    ChildAnimationInfo* ai = (ChildAnimationInfo*)data;

    gint64 now = gdk_frame_clock_get_frame_time(clock);

    gdouble duration = (now - ai->last_time) / 1000000.0;
    if (ai->last_time != ai->start_time && duration < 0.033) return G_SOURCE_CONTINUE;
    ai->last_time = now;

    gdouble t = 1.0;
    if (now < ai->end_time) {
        t = (now - ai->start_time) / (gdouble)(ai->end_time - ai->start_time);
    }
    t = ease_out_cubic(t);
    ai->current_pos = t * ai->target_pos;
    if (ai->current_pos > ai->target_pos) ai->current_pos = ai->target_pos;

    deepin_fixed_move_internal(self, ai->child,
            ai->target_x * ai->current_pos + ai->old_x * (1 - ai->current_pos),
            ai->target_y * ai->current_pos + ai->old_y * (1 - ai->current_pos));

    if (ai->current_pos >= ai->target_pos) {
        deepin_fixed_end_animation(self, ai);
        return G_SOURCE_REMOVE;
    }

    return G_SOURCE_CONTINUE;
}
Example #4
0
static void
gtk_revealer_animate_step (GtkRevealer *revealer,
                           gint64       now)
{
  GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
  gdouble t;

  if (now < priv->end_time)
    t = (now - priv->start_time) / (gdouble) (priv->end_time - priv->start_time);
  else
    t = 1.0;
  t = ease_out_cubic (t);

  gtk_revealer_set_position (revealer,
                            priv->source_pos + (t * (priv->target_pos - priv->source_pos)));
}
Example #5
0
double ease_out_in_cubic(double t, double b, double c, double d, const std::vector<double>& params)
{
    if (t < d / 2)
        return ease_out_cubic(t * 2, b, c / 2, d, params);
    return ease_in_cubic(t * 2 - d, b + c / 2, c / 2, d, params);
}