]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkthemingengine.c
cssvalue: Make GtkCssShadowValue only hold one shadow
[~andy/gtk] / gtk / gtkthemingengine.c
index f79127a60cf2a4ca18c74ad617e78d3fe9cd250e..cd7ecad9df85b032e235d415062b82730e85a41f 100644 (file)
 #include "gtkmodulesprivate.h"
 #include "gtkborderimageprivate.h"
 #include "gtkpango.h"
-#include "gtkshadowprivate.h"
+#include "gtkcssarrayvalueprivate.h"
+#include "gtkcssenumvalueprivate.h"
+#include "gtkcssrgbavalueprivate.h"
+#include "gtkcssshadowvalueprivate.h"
 #include "gtkcsstypesprivate.h"
 #include "gtkthemingengineprivate.h"
 #include "gtkroundedboxprivate.h"
@@ -340,23 +343,21 @@ _gtk_theming_engine_get_context (GtkThemingEngine *engine)
 
 GtkCssValue *
 _gtk_theming_engine_peek_property (GtkThemingEngine *engine,
-                                   const char       *property_name)
+                                   guint             property_id)
 {
   g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
-  g_return_val_if_fail (property_name != NULL, NULL);
 
-  return _gtk_style_context_peek_property (engine->priv->context, property_name);
+  return _gtk_style_context_peek_property (engine->priv->context, property_id);
 }
 
 double
 _gtk_theming_engine_get_number (GtkThemingEngine *engine,
-                                const char       *property_name,
+                                guint             property_id,
                                 double            one_hundred_percent)
 {
   g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0.0);
-  g_return_val_if_fail (property_name != NULL, 0.0);
 
-  return _gtk_style_context_get_number (engine->priv->context, property_name, one_hundred_percent);
+  return _gtk_style_context_get_number (engine->priv->context, property_id, one_hundred_percent);
 }
 
 /**
@@ -1820,17 +1821,17 @@ render_frame_internal (GtkThemingEngine *engine,
       render_border (cr, &border_box, &border, hidden_side, colors, border_style);
     }
 
-  border_style[0] = _gtk_css_value_get_border_style (_gtk_theming_engine_peek_property (engine, "outline-style"));
+  border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_STYLE));
   if (border_style[0] != GTK_BORDER_STYLE_NONE)
     {
       int offset;
 
       border_style[1] = border_style[2] = border_style[3] = border_style[0];
-      border.top = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-width"));
+      border.top = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_WIDTH));
       border.left = border.right = border.bottom = border.top;
-      colors[0] = *_gtk_css_value_get_rgba (_gtk_theming_engine_peek_property (engine, "outline-color"));
+      colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_COLOR));
       colors[3] = colors[2] = colors[1] = colors[0];
-      offset = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-offset"));
+      offset = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_OFFSET));
       
       /* reinit box here - outlines don't have a border radius */
       _gtk_rounded_box_init_rect (&border_box, x, y, width, height);
@@ -2100,10 +2101,11 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine,
                                   PangoLayout      *layout)
 {
   GdkRGBA fg_color;
-  GtkCssValue *text_shadow = NULL;
+  GtkCssValue *shadows;
   GtkStateFlags flags;
   gdouble progress;
   gboolean running;
+  guint i;
 
   cairo_save (cr);
   flags = gtk_theming_engine_get_state (engine);
@@ -2132,11 +2134,14 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine,
       fg_color.alpha = CLAMP (fg_color.alpha + ((other_fg.alpha - fg_color.alpha) * progress), 0, 1);
     }
 
-  text_shadow = _gtk_theming_engine_peek_property (engine, "text-shadow");
+  shadows = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_TEXT_SHADOW);
 
   prepare_context_for_layout (cr, x, y, layout);
 
-  _gtk_css_shadow_value_paint_layout (text_shadow, cr, layout);
+  for (i = 0; i < _gtk_css_array_value_get_n_values (shadows); i++)
+    {
+      _gtk_css_shadow_value_paint_layout (_gtk_css_array_value_get_nth (shadows, i), cr, layout);
+    }
 
   gdk_cairo_set_source_rgba (cr, &fg_color);
   pango_cairo_show_layout (cr, layout);
@@ -2690,10 +2695,10 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine,
 }
 
 void
-_gtk_theming_engine_paint_spinner (cairo_t *cr,
-                                   gdouble  radius,
-                                   gdouble  progress,
-                                   GdkRGBA *color)
+_gtk_theming_engine_paint_spinner (cairo_t       *cr,
+                                   gdouble        radius,
+                                   gdouble        progress,
+                                   const GdkRGBA *color)
 {
   guint num_steps, step;
   gdouble half;
@@ -2750,10 +2755,11 @@ render_spinner (GtkThemingEngine *engine,
                 gdouble           height)
 {
   GtkStateFlags state;
-  GtkCssValue *shadow;
+  GtkCssValue *shadows;
   GdkRGBA color;
   gdouble progress;
   gdouble radius;
+  guint i;
 
   state = gtk_theming_engine_get_state (engine);
 
@@ -2763,14 +2769,18 @@ render_spinner (GtkThemingEngine *engine,
   radius = MIN (width / 2, height / 2);
 
   gtk_theming_engine_get_color (engine, state, &color);
-  shadow = _gtk_theming_engine_peek_property (engine, "icon-shadow");
+  shadows = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW);
 
   cairo_save (cr);
   cairo_translate (cr, x + width / 2, y + height / 2);
 
-  _gtk_css_shadow_value_paint_spinner (shadow, cr,
-                                       radius,
-                                       progress);
+  for (i = 0; i < _gtk_css_array_value_get_n_values (shadows); i++)
+    {
+      _gtk_css_shadow_value_paint_spinner (_gtk_css_array_value_get_nth (shadows, i),
+                                           cr,
+                                           radius,
+                                           progress);
+    }
 
   _gtk_theming_engine_paint_spinner (cr,
                                      radius,
@@ -2937,11 +2947,18 @@ gtk_theming_engine_render_icon (GtkThemingEngine *engine,
                                 gdouble x,
                                 gdouble y)
 {
+  GtkCssValue *shadows;
+  guint i;
+
   cairo_save (cr);
 
   gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
 
-  _gtk_css_shadow_value_paint_icon (_gtk_theming_engine_peek_property (engine, "icon-shadow"), cr);
+  shadows = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW);
+  for (i = 0; i < _gtk_css_array_value_get_n_values (shadows); i++)
+    {
+      _gtk_css_shadow_value_paint_icon (_gtk_css_array_value_get_nth (shadows, i), cr);
+    }
 
   cairo_paint (cr);