Example #1
0
static void
gtk_css_animation_set_values (GtkStyleAnimation    *style_animation,
                              gint64                for_time_us,
                              GtkCssAnimatedStyle  *style)
{
  GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
  double iteration, progress;
  guint i;

  iteration = gtk_css_animation_get_iteration (animation, for_time_us);

  if (!gtk_css_animation_is_executing_at_iteration (animation, iteration))
    return;

  progress = gtk_css_animation_get_progress_from_iteration (animation, iteration);
  progress = _gtk_css_ease_value_transform (animation->ease, progress);
  
  for (i = 0; i < _gtk_css_keyframes_get_n_properties (animation->keyframes); i++)
    {
      GtkCssValue *value;
      guint property_id;
      
      property_id = _gtk_css_keyframes_get_property_id (animation->keyframes, i);

      value = _gtk_css_keyframes_get_value (animation->keyframes,
                                            i,
                                            progress,
                                            gtk_css_animated_style_get_intrinsic_value (style, property_id));
      gtk_css_animated_style_set_animated_value (style, property_id, value);
      _gtk_css_value_unref (value);
    }
}
Example #2
0
static GtkCssValue *
gtk_css_animated_style_get_value (GtkCssStyle *style,
                                  guint        id)
{
  GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);

  if (animated->animated_values &&
      id < animated->animated_values->len &&
      g_ptr_array_index (animated->animated_values, id))
    return g_ptr_array_index (animated->animated_values, id);

  return gtk_css_animated_style_get_intrinsic_value (animated, id);
}
Example #3
0
static GSList *
gtk_css_animated_style_create_css_transitions (GSList              *animations,
                                               GtkCssStyle         *base_style,
                                               gint64               timestamp,
                                               GtkCssStyle         *source)
{
  TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
  GtkCssValue *durations, *delays, *timing_functions;
  guint i;

  transition_infos_set (transitions, gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_PROPERTY));

  durations = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DURATION);
  delays = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_DELAY);
  timing_functions = gtk_css_style_get_value (base_style, GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION);

  for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
    {
      GtkStyleAnimation *animation;
      GtkCssValue *start, *end;
      double duration, delay;

      if (!transitions[i].pending)
        continue;

      duration = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, transitions[i].index), 100);
      delay = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, transitions[i].index), 100);
      if (duration + delay == 0.0)
        continue;

      if (GTK_IS_CSS_ANIMATED_STYLE (source))
        {
          start = gtk_css_animated_style_get_intrinsic_value (GTK_CSS_ANIMATED_STYLE (source), i);
          end = gtk_css_style_get_value (base_style, i);

          if (_gtk_css_value_equal (start, end))
            {
              animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
              if (animation)
                {
                  animation = _gtk_style_animation_advance (animation, timestamp);
                  animations = g_slist_prepend (animations, animation);
                }

              continue;
            }
        }

      if (_gtk_css_value_equal (gtk_css_style_get_value (source, i),
                                gtk_css_style_get_value (base_style, i)))
        continue;

      animation = _gtk_css_transition_new (i,
                                           gtk_css_style_get_value (source, i),
                                           _gtk_css_array_value_get_nth (timing_functions, i),
                                           timestamp,
                                           duration * G_USEC_PER_SEC,
                                           delay * G_USEC_PER_SEC);
      animations = g_slist_prepend (animations, animation);
    }

  return animations;
}