]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkthemingengine.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkthemingengine.c
index 631cc35cfe8ea267fb4bd52b2482e7c29ad2f297..8a0ae4700c65f1ebeef0c0247c051a1dcaf084a0 100644 (file)
 #include "gtkborderimageprivate.h"
 #include "gtkpango.h"
 #include "gtkcssarrayvalueprivate.h"
+#include "gtkcsscornervalueprivate.h"
 #include "gtkcssenumvalueprivate.h"
+#include "gtkcssnumbervalueprivate.h"
 #include "gtkcssrgbavalueprivate.h"
 #include "gtkcssshadowsvalueprivate.h"
 #include "gtkcsstypesprivate.h"
+#include "gtkhslaprivate.h"
 #include "gtkthemingengineprivate.h"
 #include "gtkroundedboxprivate.h"
 #include "gtkthemingbackgroundprivate.h"
@@ -206,6 +209,8 @@ struct GtkThemingModuleClass
 #define GTK_THEMING_MODULE(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_THEMING_MODULE, GtkThemingModule))
 #define GTK_IS_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_THEMING_MODULE))
 
+GType gtk_theming_module_get_type (void);
+
 G_DEFINE_TYPE (GtkThemingModule, gtk_theming_module, G_TYPE_TYPE_MODULE);
 
 static void
@@ -350,16 +355,6 @@ _gtk_theming_engine_peek_property (GtkThemingEngine *engine,
   return _gtk_style_context_peek_property (engine->priv->context, property_id);
 }
 
-double
-_gtk_theming_engine_get_number (GtkThemingEngine *engine,
-                                guint             property_id,
-                                double            one_hundred_percent)
-{
-  g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0.0);
-
-  return _gtk_style_context_get_number (engine->priv->context, property_id, one_hundred_percent);
-}
-
 /**
  * gtk_theming_engine_get_property:
  * @engine: a #GtkThemingEngine
@@ -578,18 +573,17 @@ gtk_theming_engine_get_state (GtkThemingEngine *engine)
  * Returns: %TRUE if there is a running transition animation for @state.
  *
  * Since: 3.0
+ *
+ * Deprecated: 3.6: Always returns %FALSE
  **/
 gboolean
 gtk_theming_engine_state_is_running (GtkThemingEngine *engine,
                                      GtkStateType      state,
                                      gdouble          *progress)
 {
-  GtkThemingEnginePrivate *priv;
-
   g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
 
-  priv = engine->priv;
-  return gtk_style_context_state_is_running (priv->context, state, progress);
+  return FALSE;
 }
 
 /**
@@ -676,6 +670,10 @@ gtk_theming_engine_has_region (GtkThemingEngine *engine,
  * Returns: the widget direction
  *
  * Since: 3.0
+ *
+ * Deprecated: 3.8: Use gtk_theming_engine_get_state() and
+ *   check for #GTK_STATE_FLAG_DIR_LTR and
+ *   #GTK_STATE_FLAG_DIR_RTL instead.
  **/
 GtkTextDirection
 gtk_theming_engine_get_direction (GtkThemingEngine *engine)
@@ -685,7 +683,9 @@ gtk_theming_engine_get_direction (GtkThemingEngine *engine)
   g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), GTK_TEXT_DIR_LTR);
 
   priv = engine->priv;
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   return gtk_style_context_get_direction (priv->context);
+  G_GNUC_END_IGNORE_DEPRECATIONS;
 }
 
 /**
@@ -780,7 +780,7 @@ gtk_theming_engine_get_border_color (GtkThemingEngine *engine,
 
 /**
  * gtk_theming_engine_get_border:
- * @engine: a #GtkthemingEngine
+ * @engine: a #GtkThemingEngine
  * @state: state to retrieve the border for
  * @border: (out): return value for the border settings
  *
@@ -803,7 +803,7 @@ gtk_theming_engine_get_border (GtkThemingEngine *engine,
 
 /**
  * gtk_theming_engine_get_padding:
- * @engine: a #GtkthemingEngine
+ * @engine: a #GtkThemingEngine
  * @state: state to retrieve the padding for
  * @padding: (out): return value for the padding settings
  *
@@ -859,6 +859,8 @@ gtk_theming_engine_get_margin (GtkThemingEngine *engine,
  *          freed.
  *
  * Since: 3.0
+ *
+ * Deprecated: 3.8: Use gtk_theming_engine_get()
  **/
 const PangoFontDescription *
 gtk_theming_engine_get_font (GtkThemingEngine *engine,
@@ -868,8 +870,10 @@ gtk_theming_engine_get_font (GtkThemingEngine *engine,
 
   g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
 
+  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   priv = engine->priv;
   return gtk_style_context_get_font (priv->context, state);
+  G_GNUC_END_IGNORE_DEPRECATIONS;
 }
 
 /* GtkThemingModule */
@@ -1049,10 +1053,8 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine,
   gtk_theming_engine_get_color (engine, flags, &fg_color);
   gtk_theming_engine_get_background_color (engine, flags, &bg_color);
   gtk_theming_engine_get_border (engine, flags, &border);
-
-  gtk_theming_engine_get (engine, flags,
-                          "border-style", &border_style,
-                          NULL);
+  border_style = _gtk_css_border_style_value_get 
+    (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
 
   border_width = MIN (MIN (border.top, border.bottom),
                       MIN (border.left, border.right));
@@ -1105,22 +1107,14 @@ gtk_theming_engine_render_check (GtkThemingEngine *engine,
     }
   else
     {
-      gdouble progress;
-      gboolean running;
-
-      running = gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress);
-
-      if ((flags & GTK_STATE_FLAG_ACTIVE) || running)
+      if (flags & GTK_STATE_FLAG_ACTIVE)
         {
-          if (!running)
-            progress = 1;
-
           cairo_translate (cr,
                            x + pad, y + pad);
 
           cairo_scale (cr, interior_size / 7., interior_size / 7.);
 
-          cairo_rectangle (cr, 0, 0, 7 * progress, 7);
+          cairo_rectangle (cr, 0, 0, 7, 7);
           cairo_clip (cr);
 
           cairo_move_to  (cr, 7.0, 0.0);
@@ -1182,10 +1176,8 @@ gtk_theming_engine_render_option (GtkThemingEngine *engine,
   gtk_theming_engine_get_color (engine, flags, &fg_color);
   gtk_theming_engine_get_background_color (engine, flags, &bg_color);
   gtk_theming_engine_get_border (engine, flags, &border);
-
-  gtk_theming_engine_get (engine, flags,
-                          "border-style", &border_style,
-                          NULL);
+  border_style = _gtk_css_border_style_value_get 
+    (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
 
   exterior_size = MIN (width, height);
   border_width = MIN (MIN (border.top, border.bottom),
@@ -1348,14 +1340,11 @@ color_shade (const GdkRGBA *color,
              gdouble        factor,
              GdkRGBA       *color_return)
 {
-  GtkSymbolicColor *literal, *shade;
-
-  literal = gtk_symbolic_color_new_literal (color);
-  shade = gtk_symbolic_color_new_shade (literal, factor);
-  gtk_symbolic_color_unref (literal);
+  GtkHSLA hsla;
 
-  gtk_symbolic_color_resolve (shade, NULL, color_return);
-  gtk_symbolic_color_unref (shade);
+  _gtk_hsla_init_from_rgba (&hsla, color);
+  _gtk_hsla_shade (&hsla, &hsla, factor);
+  _gdk_rgba_init_from_hsla (color_return, &hsla);
 }
 
 static void
@@ -1377,23 +1366,25 @@ gtk_theming_engine_render_background (GtkThemingEngine *engine,
 }
 
 static void
-gtk_theming_engine_hide_border_sides (GtkBorder *border,
-                                      guint      hidden_side)
+gtk_theming_engine_hide_border_sides (double         border[4],
+                                      GtkBorderStyle border_style[4],
+                                      guint          hidden_side)
 {
-  if (hidden_side & (1 << GTK_CSS_TOP))
-    border->top = 0;
-  if (hidden_side & (1 << GTK_CSS_RIGHT))
-    border->right = 0;
-  if (hidden_side & (1 << GTK_CSS_BOTTOM))
-    border->bottom = 0;
-  if (hidden_side & (1 << GTK_CSS_LEFT))
-    border->left = 0;
+  guint i;
+
+  for (i = 0; i < 4; i++)
+    {
+      if (hidden_side & (1 << i) ||
+          border_style[i] == GTK_BORDER_STYLE_NONE ||
+          border_style[i] == GTK_BORDER_STYLE_HIDDEN)
+        border[i] = 0;
+    }
 }
 
 static void
 render_frame_fill (cairo_t       *cr,
                    GtkRoundedBox *border_box,
-                   GtkBorder     *border,
+                   const double   border_width[4],
                    GdkRGBA        colors[4],
                    guint          hidden_side)
 {
@@ -1401,7 +1392,11 @@ render_frame_fill (cairo_t       *cr,
   guint i, j;
 
   padding_box = *border_box;
-  _gtk_rounded_box_shrink (&padding_box, border->top, border->right, border->bottom, border->left);
+  _gtk_rounded_box_shrink (&padding_box,
+                           border_width[GTK_CSS_TOP],
+                           border_width[GTK_CSS_RIGHT],
+                           border_width[GTK_CSS_BOTTOM],
+                           border_width[GTK_CSS_LEFT]);
 
   if (hidden_side == 0 &&
       gdk_rgba_equal (&colors[0], &colors[1]) &&
@@ -1501,30 +1496,10 @@ set_stroke_style (cairo_t        *cr,
     }
 }
 
-static int
-get_border_side (GtkBorder  *border,
-                 GtkCssSide  side)
-{
-  switch (side)
-    {
-    case GTK_CSS_TOP:
-      return border->top;
-    case GTK_CSS_RIGHT:
-      return border->right;
-    case GTK_CSS_BOTTOM:
-      return border->bottom;
-    case GTK_CSS_LEFT:
-      return border->left;
-    default:
-      g_assert_not_reached ();
-      return 0;
-    }
-}
-
 static void
 render_frame_stroke (cairo_t       *cr,
                      GtkRoundedBox *border_box,
-                     GtkBorder     *border,
+                     const double   border_width[4],
                      GdkRGBA        colors[4],
                      guint          hidden_side,
                      GtkBorderStyle stroke_style)
@@ -1536,16 +1511,16 @@ render_frame_stroke (cairo_t       *cr,
   different_colors = !gdk_rgba_equal (&colors[0], &colors[1]) ||
                      !gdk_rgba_equal (&colors[0], &colors[2]) ||
                      !gdk_rgba_equal (&colors[0], &colors[3]);
-  different_borders = border->top != border->right ||
-                      border->top != border->bottom ||
-                      border->top != border->left;
+  different_borders = border_width[0] != border_width[1] ||
+                      border_width[0] != border_width[2] ||
+                      border_width[0] != border_width[3] ;
 
   stroke_box = *border_box;
   _gtk_rounded_box_shrink (&stroke_box,
-                           border->top / 2.0,
-                           border->right / 2.0,
-                           border->bottom / 2.0,
-                           border->left / 2.0);
+                           border_width[GTK_CSS_TOP] / 2.0,
+                           border_width[GTK_CSS_RIGHT] / 2.0,
+                           border_width[GTK_CSS_BOTTOM] / 2.0,
+                           border_width[GTK_CSS_LEFT] / 2.0);
 
   if (!different_colors && !different_borders && hidden_side == 0)
     {
@@ -1560,7 +1535,7 @@ render_frame_stroke (cairo_t       *cr,
         }
 
       gdk_cairo_set_source_rgba (cr, &colors[0]);
-      set_stroke_style (cr, border->top, stroke_style, length);
+      set_stroke_style (cr, border_width[0], stroke_style, length);
       cairo_stroke (cr);
     }
   else
@@ -1570,10 +1545,10 @@ render_frame_stroke (cairo_t       *cr,
       padding_box = *border_box;
       _gtk_rounded_box_path (&padding_box, cr);
       _gtk_rounded_box_shrink (&padding_box,
-                               border->top,
-                               border->right,
-                               border->bottom,
-                               border->left);
+                               border_width[GTK_CSS_TOP],
+                               border_width[GTK_CSS_RIGHT],
+                               border_width[GTK_CSS_BOTTOM],
+                               border_width[GTK_CSS_LEFT]);
 
       for (i = 0; i < 4; i++) 
         {
@@ -1596,7 +1571,7 @@ render_frame_stroke (cairo_t       *cr,
 
           gdk_cairo_set_source_rgba (cr, &colors[i]);
           set_stroke_style (cr,
-                            get_border_side (border, i),
+                            border_width[i],
                             stroke_style,
                             _gtk_rounded_box_guess_length (&stroke_box, i));
           cairo_stroke (cr);
@@ -1609,7 +1584,7 @@ render_frame_stroke (cairo_t       *cr,
 static void
 render_border (cairo_t       *cr,
                GtkRoundedBox *border_box,
-               GtkBorder     *border,
+               const double   border_width[4],
                guint          hidden_side,
                GdkRGBA        colors[4],
                GtkBorderStyle border_style[4])
@@ -1652,13 +1627,13 @@ render_border (cairo_t       *cr,
                   dont_draw |= (1 << j);
               }
             
-            render_frame_stroke (cr, border_box, border, colors, dont_draw, border_style[i]);
+            render_frame_stroke (cr, border_box, border_width, colors, dont_draw, border_style[i]);
           }
           break;
         case GTK_BORDER_STYLE_DOUBLE:
           {
             GtkRoundedBox other_box;
-            GtkBorder other_border;
+            double other_border[4];
             guint dont_draw = hidden_side;
 
             for (j = 0; j < 4; j++)
@@ -1667,29 +1642,28 @@ render_border (cairo_t       *cr,
                   hidden_side |= (1 << j);
                 else
                   dont_draw |= (1 << j);
+                
+                other_border[i] = border_width[i] / 3;
               }
-            other_border.top = (border->top + 2) / 3;
-            other_border.right = (border->right + 2) / 3;
-            other_border.bottom = (border->bottom + 2) / 3;
-            other_border.left = (border->left + 2) / 3;
             
-            render_frame_fill (cr, border_box, &other_border, colors, dont_draw);
+            render_frame_fill (cr, border_box, other_border, colors, dont_draw);
             
             other_box = *border_box;
             _gtk_rounded_box_shrink (&other_box,
-                                     border->top - other_border.top,
-                                     border->right - other_border.right,
-                                     border->bottom - other_border.bottom,
-                                     border->left - other_border.left);
-            render_frame_fill (cr, &other_box, &other_border, colors, dont_draw);
+                                     2 * other_border[GTK_CSS_TOP],
+                                     2 * other_border[GTK_CSS_RIGHT],
+                                     2 * other_border[GTK_CSS_BOTTOM],
+                                     2 * other_border[GTK_CSS_LEFT]);
+            render_frame_fill (cr, &other_box, other_border, colors, dont_draw);
           }
+          break;
         case GTK_BORDER_STYLE_GROOVE:
         case GTK_BORDER_STYLE_RIDGE:
           {
             GtkRoundedBox other_box;
             GdkRGBA other_colors[4];
             guint dont_draw = hidden_side;
-            GtkBorder other_border;
+            double other_border[4];
 
             for (j = 0; j < 4; j++)
               {
@@ -1703,23 +1677,18 @@ render_border (cairo_t       *cr,
                   hidden_side |= (1 << j);
                 else
                   dont_draw |= (1 << j);
+                other_border[i] = border_width[i] / 2;
               }
-            other_border.top = border->top / 2;
-            other_border.right = border->right / 2;
-            other_border.bottom = border->bottom / 2;
-            other_border.left = border->left / 2;
             
-            render_frame_fill (cr, border_box, &other_border, colors, dont_draw);
+            render_frame_fill (cr, border_box, other_border, colors, dont_draw);
             
             other_box = *border_box;
             _gtk_rounded_box_shrink (&other_box,
-                                     other_border.top, other_border.right,
-                                     other_border.bottom, other_border.left);
-            other_border.top = border->top - other_border.top;
-            other_border.right = border->right - other_border.right;
-            other_border.bottom = border->bottom - other_border.bottom;
-            other_border.left = border->left - other_border.left;
-            render_frame_fill (cr, &other_box, &other_border, other_colors, dont_draw);
+                                     other_border[GTK_CSS_TOP],
+                                     other_border[GTK_CSS_RIGHT],
+                                     other_border[GTK_CSS_BOTTOM],
+                                     other_border[GTK_CSS_LEFT]);
+            render_frame_fill (cr, &other_box, other_border, other_colors, dont_draw);
           }
           break;
         default:
@@ -1728,7 +1697,7 @@ render_border (cairo_t       *cr,
         }
     }
   
-  render_frame_fill (cr, border_box, border, colors, hidden_side);
+  render_frame_fill (cr, border_box, border_width, colors, hidden_side);
 
   cairo_restore (cr);
 }
@@ -1744,81 +1713,36 @@ render_frame_internal (GtkThemingEngine *engine,
                        GtkJunctionSides  junction)
 {
   GtkBorderImage border_image;
-  GtkStateFlags state;
   GtkBorderStyle border_style[4];
   GtkRoundedBox border_box;
-  gdouble progress;
-  gboolean running;
-  GtkBorder border;
-  GdkRGBA *alloc_colors[4];
+  double border_width[4];
   GdkRGBA colors[4];
-  guint i;
 
-  state = gtk_theming_engine_get_state (engine);
+  border_width[0] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
+  border_width[1] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
+  border_width[2] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
+  border_width[3] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
 
-  gtk_theming_engine_get_border (engine, state, &border);
-  gtk_theming_engine_hide_border_sides (&border, hidden_side);
+  border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
+  border_style[1] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
+  border_style[2] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
+  border_style[3] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
+
+  gtk_theming_engine_hide_border_sides (border_width, border_style, hidden_side);
 
   if (_gtk_border_image_init (&border_image, engine))
-    _gtk_border_image_render (&border_image, &border, cr, x, y, width, height);
+    _gtk_border_image_render (&border_image, border_width, cr, x, y, width, height);
   else
     {
-      gtk_theming_engine_get (engine, state,
-                              "border-top-style", &border_style[0],
-                              "border-right-style", &border_style[1],
-                              "border-bottom-style", &border_style[2],
-                              "border-left-style", &border_style[3],
-                              "border-top-color", &alloc_colors[0],
-                              "border-right-color", &alloc_colors[1],
-                              "border-bottom-color", &alloc_colors[2],
-                              "border-left-color", &alloc_colors[3],
-                              NULL);
-
-      running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
-
-      if (running)
-        {
-          GtkStateFlags other_state;
-          GdkRGBA *other_colors[4];
-
-          if (state & GTK_STATE_FLAG_PRELIGHT)
-            {
-              other_state = state & ~(GTK_STATE_FLAG_PRELIGHT);
-              progress = 1 - progress;
-            }
-          else
-            other_state = state | GTK_STATE_FLAG_PRELIGHT;
-
-          gtk_theming_engine_get (engine, other_state,
-                                  "border-top-color", &other_colors[0],
-                                  "border-right-color", &other_colors[1],
-                                  "border-bottom-color", &other_colors[2],
-                                  "border-left-color", &other_colors[3],
-                                  NULL);
-
-          for (i = 0; i < 4; i++)
-            {
-              colors[i].red = CLAMP (alloc_colors[i]->red + ((other_colors[i]->red - alloc_colors[i]->red) * progress), 0, 1);
-              colors[i].green = CLAMP (alloc_colors[i]->green + ((other_colors[i]->green - alloc_colors[i]->green) * progress), 0, 1);
-              colors[i].blue = CLAMP (alloc_colors[i]->blue + ((other_colors[i]->blue - alloc_colors[i]->blue) * progress), 0, 1);
-              colors[i].alpha = CLAMP (alloc_colors[i]->alpha + ((other_colors[i]->alpha - alloc_colors[i]->alpha) * progress), 0, 1);
-              gdk_rgba_free (other_colors[i]);
-              gdk_rgba_free (alloc_colors[i]);
-            }
-        }
-      else
-        {
-          for (i = 0; i < 4; i++)
-            {
-              colors[i] = *alloc_colors[i];
-              gdk_rgba_free (alloc_colors[i]);
-            }
-        }
+      colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
+      colors[1] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR));
+      colors[2] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR));
+      colors[3] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_LEFT_COLOR));
 
       _gtk_rounded_box_init_rect (&border_box, x, y, width, height);
-      _gtk_rounded_box_apply_border_radius_for_engine (&border_box, engine, state, junction);
+      _gtk_rounded_box_apply_border_radius_for_engine (&border_box, engine, junction);
 
-      render_border (cr, &border_box, &border, hidden_side, colors, border_style);
+      render_border (cr, &border_box, border_width, hidden_side, colors, border_style);
     }
 
   border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_STYLE));
@@ -1827,21 +1751,21 @@ render_frame_internal (GtkThemingEngine *engine,
       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, GTK_CSS_PROPERTY_OUTLINE_WIDTH));
-      border.left = border.right = border.bottom = border.top;
+      border_width[0] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_WIDTH), 100);
+      border_width[3] = border_width[2] = border_width[1] = border_width[0];
       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, GTK_CSS_PROPERTY_OUTLINE_OFFSET));
+      offset = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_OFFSET), 100);
       
       /* reinit box here - outlines don't have a border radius */
       _gtk_rounded_box_init_rect (&border_box, x, y, width, height);
       _gtk_rounded_box_shrink (&border_box,
-                               - border.top - offset,
-                               - border.right - offset,
-                               - border.left - offset,
-                               - border.bottom - offset);
+                               - border_width[GTK_CSS_TOP] - offset,
+                               - border_width[GTK_CSS_RIGHT] - offset,
+                               - border_width[GTK_CSS_LEFT] - offset,
+                               - border_width[GTK_CSS_BOTTOM] - offset);
       
-      render_border (cr, &border_box, &border, hidden_side, colors, border_style);
+      render_border (cr, &border_box, border_width, hidden_side, colors, border_style);
     }
 }
 
@@ -1881,7 +1805,7 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine,
   double x_double, y_double;
   gdouble angle;
   gint line_width;
-  gboolean running, is_rtl;
+  gboolean is_rtl;
   gdouble progress;
 
   cairo_save (cr);
@@ -1890,12 +1814,9 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine,
   gtk_theming_engine_get_color (engine, flags, &fg_color);
   gtk_theming_engine_get_border_color (engine, flags, &outline_color);
 
-  running = gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress);
-  is_rtl = (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL);
+  is_rtl = (gtk_theming_engine_get_state (engine) & GTK_STATE_FLAG_DIR_RTL);
   line_width = 1;
-
-  if (!running)
-    progress = (flags & GTK_STATE_FLAG_ACTIVE) ? 1 : 0;
+  progress = (flags & GTK_STATE_FLAG_ACTIVE) ? 1 : 0;
 
   if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_HORIZONTAL))
     {
@@ -2102,36 +2023,11 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine,
 {
   GdkRGBA fg_color;
   GtkStateFlags flags;
-  gdouble progress;
-  gboolean running;
 
   cairo_save (cr);
   flags = gtk_theming_engine_get_state (engine);
   gtk_theming_engine_get_color (engine, flags, &fg_color);
 
-  running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress);
-
-  if (running)
-    {
-      GtkStateFlags other_flags;
-      GdkRGBA other_fg;
-
-      if (flags & GTK_STATE_FLAG_PRELIGHT)
-        {
-          other_flags = flags & ~(GTK_STATE_FLAG_PRELIGHT);
-          progress = 1 - progress;
-        }
-      else
-        other_flags = flags | GTK_STATE_FLAG_PRELIGHT;
-
-      gtk_theming_engine_get_color (engine, other_flags, &other_fg);
-
-      fg_color.red = CLAMP (fg_color.red + ((other_fg.red - fg_color.red) * progress), 0, 1);
-      fg_color.green = CLAMP (fg_color.green + ((other_fg.green - fg_color.green) * progress), 0, 1);
-      fg_color.blue = CLAMP (fg_color.blue + ((other_fg.blue - fg_color.blue) * progress), 0, 1);
-      fg_color.alpha = CLAMP (fg_color.alpha + ((other_fg.alpha - fg_color.alpha) * progress), 0, 1);
-    }
-
   prepare_context_for_layout (cr, x, y, layout);
 
   _gtk_css_shadows_value_paint_layout (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_TEXT_SHADOW),
@@ -2152,32 +2048,8 @@ gtk_theming_engine_render_slider (GtkThemingEngine *engine,
                                   gdouble           height,
                                   GtkOrientation    orientation)
 {
-  const GtkWidgetPath *path;
-  gint thickness;
-
-  path = gtk_theming_engine_get_path (engine);
-
   gtk_theming_engine_render_background (engine, cr, x, y, width, height);
   gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
-
-  /* FIXME: thickness */
-  thickness = 2;
-
-  if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE))
-    {
-      if (orientation == GTK_ORIENTATION_VERTICAL)
-        gtk_theming_engine_render_line (engine, cr,
-                                        x + thickness,
-                                        y + (gint) height / 2,
-                                        x + width - thickness - 1,
-                                        y + (gint) height / 2);
-      else
-        gtk_theming_engine_render_line (engine, cr,
-                                        x + (gint) width / 2,
-                                        y + thickness,
-                                        x + (gint) width / 2,
-                                        y + height - thickness - 1);
-    }
 }
 
 static void
@@ -2194,8 +2066,7 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
   GtkJunctionSides junction;
   GtkStateFlags state;
   gint border_width;
-  GtkCssBorderCornerRadius *top_left_radius, *top_right_radius;
-  GtkCssBorderCornerRadius *bottom_left_radius, *bottom_right_radius;
+  GtkCssValue *corner[4];
   gdouble x0, y0, x1, y1, xc, yc, wc, hc;
   GtkBorder border;
 
@@ -2204,12 +2075,10 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
   junction = gtk_theming_engine_get_junction_sides (engine);
 
   gtk_theming_engine_get_border (engine, state, &border);
-  gtk_theming_engine_get (engine, state,
-                         "border-top-left-radius", &top_left_radius,
-                         "border-top-right-radius", &top_right_radius,
-                         "border-bottom-right-radius", &bottom_right_radius,
-                         "border-bottom-left-radius", &bottom_left_radius,
-                         NULL);
+  corner[GTK_CSS_TOP_LEFT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS);
+  corner[GTK_CSS_TOP_RIGHT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS);
+  corner[GTK_CSS_BOTTOM_LEFT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS);
+  corner[GTK_CSS_BOTTOM_RIGHT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS);
 
   border_width = MIN (MIN (border.top, border.bottom),
                       MIN (border.left, border.right));
@@ -2224,10 +2093,10 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
       wc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
       hc = border_width;
 
-      if (xy0_gap < _gtk_css_number_get (&top_left_radius->horizontal, width))
+      if (xy0_gap < _gtk_css_corner_value_get_x (corner[GTK_CSS_TOP_LEFT], width))
         junction |= GTK_JUNCTION_CORNER_TOPLEFT;
 
-      if (xy1_gap > width - _gtk_css_number_get (&top_right_radius->horizontal, width))
+      if (xy1_gap > width - _gtk_css_corner_value_get_x (corner[GTK_CSS_TOP_RIGHT], width))
         junction |= GTK_JUNCTION_CORNER_TOPRIGHT;
       break;
     case GTK_POS_BOTTOM:
@@ -2236,10 +2105,10 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
       wc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
       hc = border_width;
 
-      if (xy0_gap < _gtk_css_number_get (&bottom_left_radius->horizontal, width))
+      if (xy0_gap < _gtk_css_corner_value_get_x (corner[GTK_CSS_BOTTOM_LEFT], width))
         junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;
 
-      if (xy1_gap > width - _gtk_css_number_get (&bottom_right_radius->horizontal, width))
+      if (xy1_gap > width - _gtk_css_corner_value_get_x (corner[GTK_CSS_BOTTOM_RIGHT], width))
         junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;
 
       break;
@@ -2249,10 +2118,10 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
       wc = border_width;
       hc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
 
-      if (xy0_gap < _gtk_css_number_get (&top_left_radius->vertical, height))
+      if (xy0_gap < _gtk_css_corner_value_get_y (corner[GTK_CSS_TOP_LEFT], height))
         junction |= GTK_JUNCTION_CORNER_TOPLEFT;
 
-      if (xy1_gap > height - _gtk_css_number_get (&bottom_left_radius->vertical, height))
+      if (xy1_gap > height - _gtk_css_corner_value_get_y (corner[GTK_CSS_BOTTOM_LEFT], height))
         junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;
 
       break;
@@ -2262,10 +2131,10 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
       wc = border_width;
       hc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
 
-      if (xy0_gap < _gtk_css_number_get (&top_right_radius->vertical, height))
+      if (xy0_gap < _gtk_css_corner_value_get_y (corner[GTK_CSS_TOP_RIGHT], height))
         junction |= GTK_JUNCTION_CORNER_TOPRIGHT;
 
-      if (xy1_gap > height - _gtk_css_number_get (&bottom_right_radius->vertical, height))
+      if (xy1_gap > height - _gtk_css_corner_value_get_y (corner[GTK_CSS_BOTTOM_RIGHT], height))
         junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;
 
       break;
@@ -2283,11 +2152,6 @@ gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
                          0, junction);
 
   cairo_restore (cr);
-
-  g_free (top_left_radius);
-  g_free (top_right_radius);
-  g_free (bottom_right_radius);
-  g_free (bottom_left_radius);
 }
 
 static void
@@ -2303,62 +2167,35 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine,
   GtkJunctionSides junction = 0;
   guint hidden_side = 0;
 
-  cairo_save (cr);
-
   switch (gap_side)
     {
     case GTK_POS_LEFT:
       junction = GTK_JUNCTION_LEFT;
       hidden_side = (1 << GTK_CSS_LEFT);
-
-      cairo_translate (cr, x + width, y);
-      cairo_rotate (cr, G_PI / 2);
       break;
     case GTK_POS_RIGHT:
       junction = GTK_JUNCTION_RIGHT;
       hidden_side = (1 << GTK_CSS_RIGHT);
-
-      cairo_translate (cr, x, y + height);
-      cairo_rotate (cr, - G_PI / 2);
       break;
     case GTK_POS_TOP:
       junction = GTK_JUNCTION_TOP;
       hidden_side = (1 << GTK_CSS_TOP);
-
-      cairo_translate (cr, x + width, y + height);
-      cairo_rotate (cr, G_PI);
       break;
     case GTK_POS_BOTTOM:
       junction = GTK_JUNCTION_BOTTOM;
       hidden_side = (1 << GTK_CSS_BOTTOM);
-
-      cairo_translate (cr, x, y);
       break;
     }
 
-  if (gap_side == GTK_POS_TOP ||
-      gap_side == GTK_POS_BOTTOM)
-    _gtk_theming_background_init (&bg, engine, 
-                                  0, 0,
-                                  width, height,
-                                  GTK_JUNCTION_BOTTOM);
-  else
-    _gtk_theming_background_init (&bg, engine, 
-                                  0, 0,
-                                  height, width,
-                                  GTK_JUNCTION_BOTTOM);
-
+  _gtk_theming_background_init (&bg, engine, 
+                                x, y,
+                                width, height,
+                                junction);
   _gtk_theming_background_render (&bg, cr);
 
-  cairo_restore (cr);
-
-  cairo_save (cr);
-
   render_frame_internal (engine, cr,
                          x, y, width, height,
                          hidden_side, junction);
-
-  cairo_restore (cr);
 }
 
 static void
@@ -2405,6 +2242,7 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine,
   GtkJunctionSides sides;
   GtkThemingBackground bg;
   gint xx, yy;
+  gboolean has_image;
 
   cairo_save (cr);
   flags = gtk_theming_engine_get_state (engine);
@@ -2417,8 +2255,11 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine,
   color_shade (&bg_color, 1.3, &lighter);
 
   _gtk_theming_background_init (&bg, engine, x, y, width, height, sides);
+  has_image = _gtk_theming_background_has_background_image (&bg);
   _gtk_theming_background_render (&bg, cr);
 
+  gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
+
   if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
     {
       /* reduce confusing values to a meaningful state */
@@ -2668,12 +2509,15 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine,
     }
   else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR))
     {
-      if (width > height)
-        for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5)
-          render_dot (cr, &lighter, &darker, xx, y + height / 2 - 1, 3);
-      else
-        for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5)
-          render_dot (cr, &lighter, &darker, x + width / 2 - 1, yy, 3);
+      if (!has_image)
+        {
+          if (width > height)
+            for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5)
+              render_dot (cr, &lighter, &darker, xx, y + height / 2 - 1, 3);
+          else
+            for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5)
+              render_dot (cr, &lighter, &darker, x + width / 2 - 1, yy, 3);
+        }
     }
   else
     {
@@ -2750,14 +2594,9 @@ render_spinner (GtkThemingEngine *engine,
 {
   GtkStateFlags state;
   GdkRGBA color;
-  gdouble progress;
   gdouble radius;
 
   state = gtk_theming_engine_get_state (engine);
-
-  if (!gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress))
-    progress = -1;
-
   radius = MIN (width / 2, height / 2);
 
   gtk_theming_engine_get_color (engine, state, &color);
@@ -2768,11 +2607,11 @@ render_spinner (GtkThemingEngine *engine,
   _gtk_css_shadows_value_paint_spinner (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW),
                                         cr,
                                         radius,
-                                        progress);
+                                        -1);
 
   _gtk_theming_engine_paint_spinner (cr,
                                      radius,
-                                     progress,
+                                     -1,
                                      &color);
 
   cairo_restore (cr);
@@ -2786,13 +2625,18 @@ gtk_theming_engine_render_activity (GtkThemingEngine *engine,
                                     gdouble           width,
                                     gdouble           height)
 {
-  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER))
+  GtkThemingBackground bg;
+  
+  _gtk_theming_background_init (&bg, engine, x, y, width, height, 0);
+  
+  if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER) &&
+      !_gtk_theming_background_has_background_image (&bg))
     {
       render_spinner (engine, cr, x, y, width, height);
     }
   else
     {
-      gtk_theming_engine_render_background (engine, cr, x, y, width, height);
+      _gtk_theming_background_render (&bg, cr);
       gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
     }
 }