Ejemplo n.º 1
0
static GtkCssKeyframes *
gtk_style_cascade_get_keyframes (GtkStyleProviderPrivate *provider,
                                 const char              *name)
{
  GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
  GtkStyleCascadeIter iter;
  GtkCssKeyframes *keyframes;
  GtkStyleProvider *item;

  for (item = gtk_style_cascade_iter_init (cascade, &iter);
       item;
       item = gtk_style_cascade_iter_next (cascade, &iter))
    {
      if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item))
        continue;
          
      keyframes = _gtk_style_provider_private_get_keyframes (GTK_STYLE_PROVIDER_PRIVATE (item), name);
      if (keyframes)
        {
          gtk_style_cascade_iter_clear (&iter);
          return keyframes;
        }
    }

  gtk_style_cascade_iter_clear (&iter);
  return NULL;
}
Ejemplo n.º 2
0
static void
gtk_css_computed_values_create_css_animations (GtkCssComputedValues    *values,
        GtkCssComputedValues    *parent_values,
        gint64                   timestamp,
        GtkStyleProviderPrivate *provider,
        GtkCssComputedValues    *source)
{
    GtkCssValue *durations, *delays, *timing_functions, *animations;
    GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
    guint i;

    animations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_NAME);
    durations = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DURATION);
    delays = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DELAY);
    timing_functions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION);
    iteration_counts = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT);
    directions = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_DIRECTION);
    play_states = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE);
    fill_modes = _gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_ANIMATION_FILL_MODE);

    for (i = 0; i < _gtk_css_array_value_get_n_values (animations); i++)
    {
        GtkStyleAnimation *animation;
        GtkCssKeyframes *keyframes;
        const char *name;

        name = _gtk_css_ident_value_get (_gtk_css_array_value_get_nth (animations, i));
        if (g_ascii_strcasecmp (name, "none") == 0)
            continue;

        animation = gtk_css_computed_values_find_animation (values, name);
        if (animation)
            continue;

        if (source)
            animation = gtk_css_computed_values_find_animation (source, name);

        if (animation)
        {
            animation = _gtk_css_animation_copy (GTK_CSS_ANIMATION (animation),
                                                 timestamp,
                                                 _gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)));
        }
        else
        {
            keyframes = _gtk_style_provider_private_get_keyframes (provider, name);
            if (keyframes == NULL)
                continue;

            keyframes = _gtk_css_keyframes_compute (keyframes, provider, values, parent_values);

            animation = _gtk_css_animation_new (name,
                                                keyframes,
                                                timestamp,
                                                _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, i), 100) * G_USEC_PER_SEC,
                                                _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, i), 100) * G_USEC_PER_SEC,
                                                _gtk_css_array_value_get_nth (timing_functions, i),
                                                _gtk_css_direction_value_get (_gtk_css_array_value_get_nth (directions, i)),
                                                _gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
                                                _gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
                                                _gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
            _gtk_css_keyframes_unref (keyframes);
        }
        values->animations = g_slist_prepend (values->animations, animation);
    }
}