forked from AuroraMiddleware/gtk
style: Convert draw_shadow_gap vfunc to a Cairo version
This commit is contained in:
parent
e1544bcc7f
commit
3f7b36d5cc
@ -199,10 +199,9 @@ static void gtk_default_draw_tab (GtkStyle *style,
|
|||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
static void gtk_default_draw_shadow_gap (GtkStyle *style,
|
static void gtk_default_draw_shadow_gap (GtkStyle *style,
|
||||||
GdkWindow *window,
|
cairo_t *cr,
|
||||||
GtkStateType state_type,
|
GtkStateType state_type,
|
||||||
GtkShadowType shadow_type,
|
GtkShadowType shadow_type,
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
const gchar *detail,
|
const gchar *detail,
|
||||||
gint x,
|
gint x,
|
||||||
@ -3046,10 +3045,9 @@ gtk_default_draw_tab (GtkStyle *style,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_default_draw_shadow_gap (GtkStyle *style,
|
gtk_default_draw_shadow_gap (GtkStyle *style,
|
||||||
GdkWindow *window,
|
cairo_t *cr,
|
||||||
GtkStateType state_type,
|
GtkStateType state_type,
|
||||||
GtkShadowType shadow_type,
|
GtkShadowType shadow_type,
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
const gchar *detail,
|
const gchar *detail,
|
||||||
gint x,
|
gint x,
|
||||||
@ -3064,9 +3062,6 @@ gtk_default_draw_shadow_gap (GtkStyle *style,
|
|||||||
GdkColor *color2 = NULL;
|
GdkColor *color2 = NULL;
|
||||||
GdkColor *color3 = NULL;
|
GdkColor *color3 = NULL;
|
||||||
GdkColor *color4 = NULL;
|
GdkColor *color4 = NULL;
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
sanitize_size (window, &width, &height);
|
|
||||||
|
|
||||||
switch (shadow_type)
|
switch (shadow_type)
|
||||||
{
|
{
|
||||||
@ -3099,13 +3094,6 @@ gtk_default_draw_shadow_gap (GtkStyle *style,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cr = gdk_cairo_create (window);
|
|
||||||
if (area)
|
|
||||||
{
|
|
||||||
gdk_cairo_rectangle (cr, area);
|
|
||||||
cairo_clip (cr);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (shadow_type)
|
switch (shadow_type)
|
||||||
{
|
{
|
||||||
case GTK_SHADOW_NONE:
|
case GTK_SHADOW_NONE:
|
||||||
@ -3249,8 +3237,6 @@ gtk_default_draw_shadow_gap (GtkStyle *style,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_destroy (cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -5573,13 +5559,72 @@ gtk_paint_shadow_gap (GtkStyle *style,
|
|||||||
gint gap_x,
|
gint gap_x,
|
||||||
gint gap_width)
|
gint gap_width)
|
||||||
{
|
{
|
||||||
|
cairo_t *cr;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_STYLE (style));
|
g_return_if_fail (GTK_IS_STYLE (style));
|
||||||
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
|
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
|
||||||
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
|
g_return_if_fail (style->depth == gdk_drawable_get_depth (window));
|
||||||
|
|
||||||
GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, window, state_type, shadow_type,
|
sanitize_size (window, &width, &height);
|
||||||
(GdkRectangle *) area, widget, detail,
|
|
||||||
|
cr = gtk_style_cairo_create (window, area);
|
||||||
|
|
||||||
|
gtk_cairo_paint_shadow_gap (style, cr, state_type, shadow_type,
|
||||||
|
widget, detail,
|
||||||
|
x, y, width, height, gap_side, gap_x, gap_width);
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_cairo_paint_shadow_gap:
|
||||||
|
* @style: a #GtkStyle
|
||||||
|
* @cr: a #cairo_t
|
||||||
|
* @state_type: a state
|
||||||
|
* @shadow_type: type of shadow to draw
|
||||||
|
* @widget: (allow-none): the widget
|
||||||
|
* @detail: (allow-none): a style detail
|
||||||
|
* @x: x origin of the rectangle
|
||||||
|
* @y: y origin of the rectangle
|
||||||
|
* @width: width of the rectangle
|
||||||
|
* @height: width of the rectangle
|
||||||
|
* @gap_side: side in which to leave the gap
|
||||||
|
* @gap_x: starting position of the gap
|
||||||
|
* @gap_width: width of the gap
|
||||||
|
*
|
||||||
|
* Draws a shadow around the given rectangle in @cr
|
||||||
|
* using the given style and state and shadow type, leaving a
|
||||||
|
* gap in one side.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_cairo_paint_shadow_gap (GtkStyle *style,
|
||||||
|
cairo_t *cr,
|
||||||
|
GtkStateType state_type,
|
||||||
|
GtkShadowType shadow_type,
|
||||||
|
GtkWidget *widget,
|
||||||
|
const gchar *detail,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
gint width,
|
||||||
|
gint height,
|
||||||
|
GtkPositionType gap_side,
|
||||||
|
gint gap_x,
|
||||||
|
gint gap_width)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_STYLE (style));
|
||||||
|
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_shadow_gap != NULL);
|
||||||
|
g_return_if_fail (cr != NULL);
|
||||||
|
g_return_if_fail (width >= 0);
|
||||||
|
g_return_if_fail (height >= 0);
|
||||||
|
|
||||||
|
cairo_save (cr);
|
||||||
|
|
||||||
|
GTK_STYLE_GET_CLASS (style)->draw_shadow_gap (style, cr, state_type, shadow_type,
|
||||||
|
widget, detail,
|
||||||
x, y, width, height, gap_side, gap_x, gap_width);
|
x, y, width, height, gap_side, gap_x, gap_width);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -264,10 +264,9 @@ struct _GtkStyleClass
|
|||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
void (*draw_shadow_gap) (GtkStyle *style,
|
void (*draw_shadow_gap) (GtkStyle *style,
|
||||||
GdkWindow *window,
|
cairo_t *cr,
|
||||||
GtkStateType state_type,
|
GtkStateType state_type,
|
||||||
GtkShadowType shadow_type,
|
GtkShadowType shadow_type,
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
const gchar *detail,
|
const gchar *detail,
|
||||||
gint x,
|
gint x,
|
||||||
@ -650,20 +649,33 @@ void gtk_cairo_paint_tab (GtkStyle *style,
|
|||||||
gint y,
|
gint y,
|
||||||
gint width,
|
gint width,
|
||||||
gint height);
|
gint height);
|
||||||
void gtk_paint_shadow_gap (GtkStyle *style,
|
void gtk_paint_shadow_gap (GtkStyle *style,
|
||||||
GdkWindow *window,
|
GdkWindow *window,
|
||||||
GtkStateType state_type,
|
GtkStateType state_type,
|
||||||
GtkShadowType shadow_type,
|
GtkShadowType shadow_type,
|
||||||
const GdkRectangle *area,
|
const GdkRectangle *area,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
const gchar *detail,
|
const gchar *detail,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
GtkPositionType gap_side,
|
GtkPositionType gap_side,
|
||||||
gint gap_x,
|
gint gap_x,
|
||||||
gint gap_width);
|
gint gap_width);
|
||||||
|
void gtk_cairo_paint_shadow_gap (GtkStyle *style,
|
||||||
|
cairo_t *cr,
|
||||||
|
GtkStateType state_type,
|
||||||
|
GtkShadowType shadow_type,
|
||||||
|
GtkWidget *widget,
|
||||||
|
const gchar *detail,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
gint width,
|
||||||
|
gint height,
|
||||||
|
GtkPositionType gap_side,
|
||||||
|
gint gap_x,
|
||||||
|
gint gap_width);
|
||||||
void gtk_paint_box_gap (GtkStyle *style,
|
void gtk_paint_box_gap (GtkStyle *style,
|
||||||
GdkWindow *window,
|
GdkWindow *window,
|
||||||
GtkStateType state_type,
|
GtkStateType state_type,
|
||||||
|
@ -767,10 +767,9 @@ draw_tab (GtkStyle *style,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
draw_shadow_gap (GtkStyle *style,
|
draw_shadow_gap (GtkStyle *style,
|
||||||
GdkWindow *window,
|
cairo_t *cr,
|
||||||
GtkStateType state,
|
GtkStateType state,
|
||||||
GtkShadowType shadow,
|
GtkShadowType shadow,
|
||||||
GdkRectangle *area,
|
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
const gchar *detail,
|
const gchar *detail,
|
||||||
gint x,
|
gint x,
|
||||||
@ -792,9 +791,9 @@ draw_shadow_gap (GtkStyle *style,
|
|||||||
match_data.shadow = shadow;
|
match_data.shadow = shadow;
|
||||||
match_data.state = state;
|
match_data.state = state;
|
||||||
|
|
||||||
if (!draw_gap_image_no_cairo (style, window, area, widget, &match_data, FALSE,
|
if (!draw_gap_image (style, cr, widget, &match_data, FALSE,
|
||||||
x, y, width, height, gap_side, gap_x, gap_width))
|
x, y, width, height, gap_side, gap_x, gap_width))
|
||||||
parent_class->draw_shadow_gap (style, window, state, shadow, area, widget, detail,
|
parent_class->draw_shadow_gap (style, cr, state, shadow, widget, detail,
|
||||||
x, y, width, height, gap_side, gap_x, gap_width);
|
x, y, width, height, gap_side, gap_x, gap_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user