mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 15:14:17 +00:00
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:
parent
4c61f1f663
commit
ae132c0a1a
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user