[gtk+/wip/colorchooser-v2] roundedbox: add _apply_border_radius() variations for engine/context



commit d5d7af41665a12a896a38dc94e67e622905a1785
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Feb 8 16:27:39 2012 -0500

    roundedbox: add _apply_border_radius() variations for engine/context
    
    And make the base function just use the raw corner radii struct.

 gtk/gtkroundedbox.c        |   51 ++++++++++++++++++++++++++++++-------------
 gtk/gtkroundedboxprivate.h |   10 +++++++-
 gtk/gtkthemingengine.c     |    2 +-
 3 files changed, 45 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkroundedbox.c b/gtk/gtkroundedbox.c
index 94451e8..69f4dd2 100644
--- a/gtk/gtkroundedbox.c
+++ b/gtk/gtkroundedbox.c
@@ -20,6 +20,7 @@
 #include "config.h"
 
 #include "gtkroundedboxprivate.h"
+#include "gtkthemingengineprivate.h"
 
 #include <string.h>
 
@@ -76,23 +77,10 @@ gtk_rounded_box_clamp_border_radius (GtkRoundedBox *box)
 }
 
 void
-_gtk_rounded_box_apply_border_radius (GtkRoundedBox    *box,
-                                      GtkThemingEngine *engine,
-                                      GtkStateFlags     state,
-                                      GtkJunctionSides  junction)
+_gtk_rounded_box_apply_border_radius (GtkRoundedBox *box,
+                                      GtkCssBorderCornerRadius **corner,
+                                      GtkJunctionSides junction)
 {
-  GtkCssBorderCornerRadius *corner[4];
-  guint i;
-
-  gtk_theming_engine_get (engine, state,
-                          /* Can't use border-radius as it's an int for
-                           * backwards compat */
-                          "border-top-left-radius", &corner[GTK_CSS_TOP_LEFT],
-                          "border-top-right-radius", &corner[GTK_CSS_TOP_RIGHT],
-                          "border-bottom-right-radius", &corner[GTK_CSS_BOTTOM_RIGHT],
-                          "border-bottom-left-radius", &corner[GTK_CSS_BOTTOM_LEFT],
-                          NULL);
-
   if (corner[GTK_CSS_TOP_LEFT] && (junction & GTK_JUNCTION_CORNER_TOPLEFT) == 0)
     {
       box->corner[GTK_CSS_TOP_LEFT].horizontal = _gtk_css_number_get (&corner[GTK_CSS_TOP_LEFT]->horizontal,
@@ -123,11 +111,42 @@ _gtk_rounded_box_apply_border_radius (GtkRoundedBox    *box,
     }
 
   gtk_rounded_box_clamp_border_radius (box);
+}
+
+void
+_gtk_rounded_box_apply_border_radius_for_context (GtkRoundedBox    *box,
+                                                  GtkStyleContext  *context,
+                                                  GtkStateFlags     state,
+                                                  GtkJunctionSides  junction)
+{
+  GtkCssBorderCornerRadius *corner[4];
+  guint i;
+
+  gtk_style_context_get (context, state,
+                         /* Can't use border-radius as it's an int for
+                          * backwards compat */
+                         "border-top-left-radius", &corner[GTK_CSS_TOP_LEFT],
+                         "border-top-right-radius", &corner[GTK_CSS_TOP_RIGHT],
+                         "border-bottom-right-radius", &corner[GTK_CSS_BOTTOM_RIGHT],
+                         "border-bottom-left-radius", &corner[GTK_CSS_BOTTOM_LEFT],
+                         NULL);
+
+  _gtk_rounded_box_apply_border_radius (box, corner, junction);
 
   for (i = 0; i < 4; i++)
     g_free (corner[i]);
 }
 
+void
+_gtk_rounded_box_apply_border_radius_for_engine (GtkRoundedBox    *box,
+                                                 GtkThemingEngine *engine,
+                                                 GtkStateFlags     state,
+                                                 GtkJunctionSides  junction)
+{
+  _gtk_rounded_box_apply_border_radius_for_context (box, _gtk_theming_engine_get_context (engine),
+                                                    state, junction);
+}
+
 static void
 gtk_css_border_radius_grow (GtkRoundedBoxCorner *corner,
                             double               horizontal,
diff --git a/gtk/gtkroundedboxprivate.h b/gtk/gtkroundedboxprivate.h
index 07987c4..42806c0 100644
--- a/gtk/gtkroundedboxprivate.h
+++ b/gtk/gtkroundedboxprivate.h
@@ -49,10 +49,18 @@ void            _gtk_rounded_box_init_rect                      (GtkRoundedBox
                                                                  double               width,
                                                                  double               height);
 
-void            _gtk_rounded_box_apply_border_radius            (GtkRoundedBox       *box,
+void            _gtk_rounded_box_apply_border_radius            (GtkRoundedBox *box,
+                                                                 GtkCssBorderCornerRadius **corner,
+                                                                 GtkJunctionSides junction);
+void            _gtk_rounded_box_apply_border_radius_for_engine (GtkRoundedBox       *box,
                                                                  GtkThemingEngine    *engine,
                                                                  GtkStateFlags        state,
                                                                  GtkJunctionSides     junction);
+void            _gtk_rounded_box_apply_border_radius_for_context (GtkRoundedBox    *box,
+                                                                  GtkStyleContext  *context,
+                                                                  GtkStateFlags     state,
+                                                                  GtkJunctionSides  junction);
+
 void            _gtk_rounded_box_shrink                         (GtkRoundedBox       *box,
                                                                  double               top,
                                                                  double               right,
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 68a6360..89a5f44 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -1815,7 +1815,7 @@ render_frame_internal (GtkThemingEngine *engine,
         }
 
       _gtk_rounded_box_init_rect (&border_box, x, y, width, height);
-      _gtk_rounded_box_apply_border_radius (&border_box, engine, state, junction);
+      _gtk_rounded_box_apply_border_radius_for_engine (&border_box, engine, state, junction);
 
       render_border (cr, &border_box, &border, hidden_side, colors, border_style);
     }



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