static void gtk_css_animation_set_values (GtkStyleAnimation *style_animation, gint64 for_time_us, GtkCssComputedValues *values) { 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_computed_values_get_intrinsic_value (values, property_id)); _gtk_css_computed_values_set_animated_value (values, property_id, value); _gtk_css_value_unref (value); } }
static void gtk_css_animation_finalize (GObject *object) { GtkCssAnimation *animation = GTK_CSS_ANIMATION (object); g_free (animation->name); _gtk_css_keyframes_unref (animation->keyframes); _gtk_css_value_unref (animation->ease); G_OBJECT_CLASS (_gtk_css_animation_parent_class)->finalize (object); }
static gboolean gtk_css_animation_is_static (GtkStyleAnimation *style_animation, gint64 at_time_us) { GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation); double iteration; if (animation->play_state == GTK_CSS_PLAY_STATE_PAUSED) return TRUE; iteration = gtk_css_animation_get_iteration (animation, at_time_us); return iteration >= animation->iteration_count; }
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); } }