From ae132c0a1a9587279fdcde5ff755f951bbdbb8cc Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 8 Feb 2012 16:27:39 -0500 Subject: [PATCH] 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 94451e8158..69f4dd2f9f 100644 --- a/gtk/gtkroundedbox.c +++ b/gtk/gtkroundedbox.c @@ -20,6 +20,7 @@ #include "config.h" #include "gtkroundedboxprivate.h" +#include "gtkthemingengineprivate.h" #include @@ -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 07987c4dda..42806c069a 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 68a63608f3..89a5f443d2 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); }