roundedbox: add _apply_border_radius() variations for engine/context

And make the base function just use the raw corner radii struct.
This commit is contained in:
Cosimo Cecchi 2012-02-08 16:27:39 -05:00 committed by Matthias Clasen
parent 4c61f1f663
commit ae132c0a1a
3 changed files with 45 additions and 18 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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);
}