]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssrgbavalue.c
gtkenums: correct various documentation typos
[~andy/gtk] / gtk / gtkcssrgbavalue.c
index f11f8b7acfd590c12d2d17eb75e0fb071c7f57af..fb52acefa5052105a33c444cf4712778bdcecc10 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "gtkcssrgbavalueprivate.h"
 
+#include "gtkcssstylepropertyprivate.h"
 #include "gtkstylecontextprivate.h"
-#include "gtksymboliccolorprivate.h"
 
 struct _GtkCssValue {
   GTK_CSS_VALUE_BASE
@@ -33,6 +33,17 @@ gtk_css_value_rgba_free (GtkCssValue *value)
   g_slice_free (GtkCssValue, value);
 }
 
+static GtkCssValue *
+gtk_css_value_rgba_compute (GtkCssValue             *value,
+                            guint                    property_id,
+                            GtkStyleProviderPrivate *provider,
+                            GtkCssComputedValues    *values,
+                            GtkCssComputedValues    *parent_values,
+                            GtkCssDependencies      *dependencies)
+{
+  return _gtk_css_value_ref (value);
+}
+
 static gboolean
 gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
                           const GtkCssValue *rgba2)
@@ -40,6 +51,23 @@ gtk_css_value_rgba_equal (const GtkCssValue *rgba1,
   return gdk_rgba_equal (&rgba1->rgba, &rgba2->rgba);
 }
 
+static GtkCssValue *
+gtk_css_value_rgba_transition (GtkCssValue *start,
+                               GtkCssValue *end,
+                               guint        property_id,
+                               double       progress)
+{
+  GdkRGBA transition;
+
+  progress = CLAMP (progress, 0, 1);
+  transition.red = start->rgba.red + (end->rgba.red - start->rgba.red) * progress;
+  transition.green = start->rgba.green + (end->rgba.green - start->rgba.green) * progress;
+  transition.blue = start->rgba.blue + (end->rgba.blue - start->rgba.blue) * progress;
+  transition.alpha = start->rgba.alpha + (end->rgba.alpha - start->rgba.alpha) * progress;
+
+  return _gtk_css_rgba_value_new_from_rgba (&transition);
+}
+
 static void
 gtk_css_value_rgba_print (const GtkCssValue *rgba,
                           GString           *string)
@@ -51,7 +79,9 @@ gtk_css_value_rgba_print (const GtkCssValue *rgba,
 
 static const GtkCssValueClass GTK_CSS_VALUE_RGBA = {
   gtk_css_value_rgba_free,
+  gtk_css_value_rgba_compute,
   gtk_css_value_rgba_equal,
+  gtk_css_value_rgba_transition,
   gtk_css_value_rgba_print
 };
 
@@ -75,47 +105,3 @@ _gtk_css_rgba_value_get_rgba (const GtkCssValue *rgba)
 
   return &rgba->rgba;
 }
-
-GtkCssValue *
-_gtk_css_rgba_value_compute_from_symbolic (GtkCssValue     *rgba,
-                                           GtkCssValue     *fallback,
-                                           GtkStyleContext *context,
-                                           gboolean         for_color_property)
-{
-  GtkSymbolicColor *symbolic;
-  GtkCssValue *resolved;
-
-  g_return_val_if_fail (rgba != NULL, NULL);
-
-  symbolic = _gtk_css_value_get_symbolic_color (rgba);
-
-  if (symbolic == _gtk_symbolic_color_get_current_color ())
-    {
-      /* The computed value of the ‘currentColor’ keyword is the computed
-       * value of the ‘color’ property. If the ‘currentColor’ keyword is
-       * set on the ‘color’ property itself, it is treated as ‘color: inherit’. 
-       */
-      if (for_color_property)
-        {
-          GtkStyleContext *parent = gtk_style_context_get_parent (context);
-
-          if (parent)
-            return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, "color"));
-          else
-            return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, TRUE);
-        }
-      else
-        {
-          return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
-        }
-    }
-  
-  resolved = _gtk_style_context_resolve_color_value (context, symbolic);
-
-  if (resolved == NULL)
-    return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, for_color_property);
-
-  g_assert (resolved->class == &GTK_CSS_VALUE_RGBA);
-  return resolved;
-}
-