summaryrefslogtreecommitdiff
path: root/gtk/gtkcssanimatedstyle.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2014-12-14 17:06:27 +0100
committerBenjamin Otte <otte@redhat.com>2015-01-07 14:26:47 +0100
commit79f73921096e795d92257d7ce063161aece057da (patch)
tree17ba0934542506d6e8a2fa0e945ce33f192c078a /gtk/gtkcssanimatedstyle.c
parentdb36ee36a6bde810b79b5253768a8edaa1fa2a71 (diff)
downloadgtk+-79f73921096e795d92257d7ce063161aece057da.tar.gz
stylecontext: Make static styles static
Instead of keeping an animated style everywhere, we replace it with the static style when nothing gets animated. Apart from making the code cleaner, this gets rid of a bunch of animated style values that do nothing but wrap a static style.
Diffstat (limited to 'gtk/gtkcssanimatedstyle.c')
-rw-r--r--gtk/gtkcssanimatedstyle.c62
1 files changed, 36 insertions, 26 deletions
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index efbce2490b..baf5be6796 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -117,13 +117,20 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
static void
gtk_css_animated_style_init (GtkCssAnimatedStyle *style)
{
- style->style = gtk_css_static_style_new ();
}
GtkCssStyle *
-gtk_css_animated_style_new (void)
+gtk_css_animated_style_new (GtkCssStyle *style)
{
- return g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
+ GtkCssAnimatedStyle *result;
+
+ g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
+
+ result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
+
+ result->style = g_object_ref (style);
+
+ return GTK_CSS_STYLE (result);
}
void
@@ -254,7 +261,7 @@ gtk_css_animated_style_find_transition (GtkCssAnimatedStyle *style,
static void
gtk_css_animated_style_create_css_transitions (GtkCssAnimatedStyle *style,
gint64 timestamp,
- GtkCssAnimatedStyle *source)
+ GtkCssStyle *source)
{
TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
GtkCssValue *durations, *delays, *timing_functions;
@@ -280,23 +287,26 @@ gtk_css_animated_style_create_css_transitions (GtkCssAnimatedStyle *style,
if (duration + delay == 0.0)
continue;
- start = gtk_css_animated_style_get_intrinsic_value (source, i);
- end = gtk_css_animated_style_get_intrinsic_value (style, i);
- if (_gtk_css_value_equal (start, end))
- {
- animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
- if (animation)
- style->animations = g_slist_prepend (style->animations, g_object_ref (animation));
- }
- else
+ if (GTK_IS_CSS_ANIMATED_STYLE (source))
{
- animation = _gtk_css_transition_new (i,
- gtk_css_style_get_value (GTK_CSS_STYLE (source), i),
- _gtk_css_array_value_get_nth (timing_functions, i),
- timestamp + delay * G_USEC_PER_SEC,
- timestamp + (delay + duration) * G_USEC_PER_SEC);
- style->animations = g_slist_prepend (style->animations, animation);
+ start = gtk_css_animated_style_get_intrinsic_value (GTK_CSS_ANIMATED_STYLE (source), i);
+ end = gtk_css_animated_style_get_intrinsic_value (style, i);
+ if (_gtk_css_value_equal (start, end))
+ {
+ animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
+ if (animation)
+ style->animations = g_slist_prepend (style->animations, g_object_ref (animation));
+
+ continue;
+ }
}
+
+ animation = _gtk_css_transition_new (i,
+ gtk_css_style_get_value (source, i),
+ _gtk_css_array_value_get_nth (timing_functions, i),
+ timestamp + delay * G_USEC_PER_SEC,
+ timestamp + (delay + duration) * G_USEC_PER_SEC);
+ style->animations = g_slist_prepend (style->animations, animation);
}
}
@@ -320,11 +330,11 @@ gtk_css_animated_style_find_animation (GtkCssAnimatedStyle *style,
static void
gtk_css_animated_style_create_css_animations (GtkCssAnimatedStyle *style,
- GtkCssAnimatedStyle *parent_style,
+ GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
- GtkCssAnimatedStyle *source)
+ GtkCssStyle *source)
{
GtkCssValue *durations, *delays, *timing_functions, *animations;
GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
@@ -353,8 +363,8 @@ gtk_css_animated_style_create_css_animations (GtkCssAnimatedStyle *style,
if (animation)
continue;
- if (source)
- animation = gtk_css_animated_style_find_animation (source, name);
+ if (GTK_IS_CSS_ANIMATED_STYLE (source))
+ animation = gtk_css_animated_style_find_animation (GTK_CSS_ANIMATED_STYLE (source), name);
if (animation)
{
@@ -368,7 +378,7 @@ gtk_css_animated_style_create_css_animations (GtkCssAnimatedStyle *style,
if (keyframes == NULL)
continue;
- keyframes = _gtk_css_keyframes_compute (keyframes, provider, scale, GTK_CSS_STYLE (style), GTK_CSS_STYLE (parent_style));
+ keyframes = _gtk_css_keyframes_compute (keyframes, provider, scale, GTK_CSS_STYLE (style), parent_style);
animation = _gtk_css_animation_new (name,
keyframes,
@@ -390,11 +400,11 @@ gtk_css_animated_style_create_css_animations (GtkCssAnimatedStyle *style,
void
gtk_css_animated_style_create_animations (GtkCssAnimatedStyle *style,
- GtkCssAnimatedStyle *parent_style,
+ GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
- GtkCssAnimatedStyle *source)
+ GtkCssStyle *source)
{
if (source != NULL)
gtk_css_animated_style_create_css_transitions (style, timestamp, source);