[gtk+/wip/cssstyle: 17/27] cssanimatedstyle: Apply animation values after creation



commit 74b14551426213c1e9c8d0b949a0491addffbdae
Author: Benjamin Otte <otte redhat com>
Date:   Tue Dec 16 05:57:36 2014 +0100

    cssanimatedstyle: Apply animation values after creation
    
    This makes GtkCssAnimatedStyle immutable.

 gtk/gtkcssanimatedstyle.c |    3 ++
 gtk/gtkstylecontext.c     |   51 ++++++++++++++++++--------------------------
 2 files changed, 24 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index efdbe12..b8c0d9a 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -435,8 +435,11 @@ gtk_css_animated_style_new (GtkCssStyle             *base_style,
   result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
 
   result->style = g_object_ref (base_style);
+  result->current_time = timestamp;
   result->animations = animations;
 
+  gtk_css_animated_style_apply_animations (result, timestamp);
+
   return GTK_CSS_STYLE (result);
 }
 
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index bc35928..8509aa2 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -2821,16 +2821,7 @@ _gtk_style_context_validate (GtkStyleContext  *context,
                                            priv->scale,
                                            gtk_style_context_should_create_transitions (context) ? current : 
NULL);
 
-      if (!GTK_IS_CSS_ANIMATED_STYLE (values) ||
-          gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (values)))
-        {
-          change &= ~GTK_CSS_CHANGE_ANIMATE;
-        }
-      else
-        {
-          change |= GTK_CSS_CHANGE_ANIMATE;
-          style_info_set_values (info, values);
-        }
+      style_info_set_values (info, values);
       _gtk_style_context_update_animating (context);
 
       if (current)
@@ -2847,6 +2838,8 @@ _gtk_style_context_validate (GtkStyleContext  *context,
     }
   else
     {
+      gtk_style_context_update_cache (context, parent_changes);
+
       changes = gtk_css_style_compute_dependencies (current, parent_changes);
       if (!_gtk_bitmask_is_empty (changes))
         {
@@ -2856,31 +2849,29 @@ _gtk_style_context_validate (GtkStyleContext  *context,
            update_properties (context, current, info->decl, changes);
         }
 
-      gtk_style_context_update_cache (context, parent_changes);
-    }
-
-  if (current)
-    g_object_unref (current);
-
-  if (change & GTK_CSS_CHANGE_ANIMATE &&
-      gtk_style_context_is_animating (context))
-    {
-      GtkCssStyle *new_values;
-      GtkBitmask *animation_changes;
+      if (change & GTK_CSS_CHANGE_ANIMATE &&
+          gtk_style_context_is_animating (context))
+        {
+          GtkCssStyle *new_values;
+          GtkBitmask *animation_changes;
 
-      new_values = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (info->values), timestamp);
-      animation_changes = gtk_css_style_get_difference (new_values, info->values);
-      style_info_set_values (info, new_values);
-      g_object_unref (new_values);
+          new_values = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (info->values), timestamp);
+          animation_changes = gtk_css_style_get_difference (new_values, info->values);
+          style_info_set_values (info, new_values);
+          g_object_unref (new_values);
 
-      changes = _gtk_bitmask_union (changes, animation_changes);
-      _gtk_bitmask_free (animation_changes);
+          changes = _gtk_bitmask_union (changes, animation_changes);
+          _gtk_bitmask_free (animation_changes);
 
-      if (!GTK_IS_CSS_ANIMATED_STYLE (info->values) ||
-          gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (info->values)))
-        _gtk_style_context_update_animating (context);
+          if (!GTK_IS_CSS_ANIMATED_STYLE (info->values) ||
+              gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (info->values)))
+            _gtk_style_context_update_animating (context);
+        }
     }
 
+  if (current)
+    g_object_unref (current);
+
   if (!_gtk_bitmask_is_empty (changes))
     gtk_style_context_do_invalidate (context, changes);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]