render: Don't require passing CSS properties to builtin images

Instead, make the buiultin image get those properties itself in the
compute vfunc.
This commit is contained in:
Benjamin Otte
2015-01-19 17:14:55 +01:00
parent 9ce8ce1198
commit 45541cbf10
3 changed files with 133 additions and 276 deletions

View File

@ -21,6 +21,10 @@
#include "gtkcssimagebuiltinprivate.h" #include "gtkcssimagebuiltinprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkhslaprivate.h" #include "gtkhslaprivate.h"
#include "gtkrenderprivate.h" #include "gtkrenderprivate.h"
@ -38,12 +42,9 @@ gtk_css_image_builtin_draw_check (GtkCssImage *image,
double width, double width,
double height, double height,
gboolean checked, gboolean checked,
gboolean inconsistent, gboolean inconsistent)
const GdkRGBA * fg_color,
const GdkRGBA * bg_color,
const GdkRGBA * border_color,
int border_width)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
gint x, y, exterior_size, interior_size, thickness, pad; gint x, y, exterior_size, interior_size, thickness, pad;
exterior_size = MIN (width, height); exterior_size = MIN (width, height);
@ -65,19 +66,19 @@ gtk_css_image_builtin_draw_check (GtkCssImage *image,
x = - (1 + exterior_size - (gint) width) / 2; x = - (1 + exterior_size - (gint) width) / 2;
y = - (1 + exterior_size - (gint) height) / 2; y = - (1 + exterior_size - (gint) height) / 2;
if (border_width > 0) if (builtin->border_width > 0)
{ {
cairo_set_line_width (cr, border_width); cairo_set_line_width (cr, builtin->border_width);
cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1); cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1);
gdk_cairo_set_source_rgba (cr, bg_color); gdk_cairo_set_source_rgba (cr, &builtin->bg_color);
cairo_fill_preserve (cr); cairo_fill_preserve (cr);
gdk_cairo_set_source_rgba (cr, border_color); gdk_cairo_set_source_rgba (cr, &builtin->border_color);
cairo_stroke (cr); cairo_stroke (cr);
} }
gdk_cairo_set_source_rgba (cr, fg_color); gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
if (inconsistent) if (inconsistent)
{ {
@ -132,12 +133,9 @@ gtk_css_image_builtin_draw_option (GtkCssImage *image,
double width, double width,
double height, double height,
gboolean checked, gboolean checked,
gboolean inconsistent, gboolean inconsistent)
const GdkRGBA * fg_color,
const GdkRGBA * bg_color,
const GdkRGBA * border_color,
int border_width)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
gint x, y, exterior_size, interior_size, thickness, pad; gint x, y, exterior_size, interior_size, thickness, pad;
exterior_size = MIN (width, height); exterior_size = MIN (width, height);
@ -148,9 +146,9 @@ gtk_css_image_builtin_draw_option (GtkCssImage *image,
x = - (1 + exterior_size - width) / 2; x = - (1 + exterior_size - width) / 2;
y = - (1 + exterior_size - height) / 2; y = - (1 + exterior_size - height) / 2;
if (border_width > 0) if (builtin->border_width > 0)
{ {
cairo_set_line_width (cr, border_width); cairo_set_line_width (cr, builtin->border_width);
cairo_new_sub_path (cr); cairo_new_sub_path (cr);
cairo_arc (cr, cairo_arc (cr,
@ -159,14 +157,14 @@ gtk_css_image_builtin_draw_option (GtkCssImage *image,
(exterior_size - 1) / 2., (exterior_size - 1) / 2.,
0, 2 * G_PI); 0, 2 * G_PI);
gdk_cairo_set_source_rgba (cr, bg_color); gdk_cairo_set_source_rgba (cr, &builtin->bg_color);
cairo_fill_preserve (cr); cairo_fill_preserve (cr);
gdk_cairo_set_source_rgba (cr, border_color); gdk_cairo_set_source_rgba (cr, &builtin->border_color);
cairo_stroke (cr); cairo_stroke (cr);
} }
gdk_cairo_set_source_rgba (cr, fg_color); gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
/* FIXME: thickness */ /* FIXME: thickness */
thickness = 1; thickness = 1;
@ -219,9 +217,9 @@ gtk_css_image_builtin_draw_arrow (GtkCssImage *image,
cairo_t *cr, cairo_t *cr,
double width, double width,
double height, double height,
GtkCssImageBuiltinType image_type, GtkCssImageBuiltinType image_type)
const GdkRGBA * color)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
double line_width; double line_width;
double size; double size;
@ -260,7 +258,7 @@ gtk_css_image_builtin_draw_arrow (GtkCssImage *image,
cairo_rel_line_to (cr, size / 2.0, size / 2.0); cairo_rel_line_to (cr, size / 2.0, size / 2.0);
cairo_rel_line_to (cr, - size / 2.0, size / 2.0); cairo_rel_line_to (cr, - size / 2.0, size / 2.0);
gdk_cairo_set_source_rgba (cr, color); gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
cairo_stroke (cr); cairo_stroke (cr);
} }
@ -271,10 +269,9 @@ gtk_css_image_builtin_draw_expander (GtkCssImage *image,
double height, double height,
gboolean horizontal, gboolean horizontal,
gboolean is_rtl, gboolean is_rtl,
gboolean expanded, gboolean expanded)
const GdkRGBA * fg_color,
const GdkRGBA * border_color)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
double vertical_overshoot; double vertical_overshoot;
int diameter; int diameter;
double radius; double radius;
@ -355,11 +352,11 @@ gtk_css_image_builtin_draw_expander (GtkCssImage *image,
cairo_set_line_width (cr, line_width); cairo_set_line_width (cr, line_width);
gdk_cairo_set_source_rgba (cr, fg_color); gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
cairo_fill_preserve (cr); cairo_fill_preserve (cr);
gdk_cairo_set_source_rgba (cr, border_color); gdk_cairo_set_source_rgba (cr, &builtin->border_color);
cairo_stroke (cr); cairo_stroke (cr);
} }
@ -436,15 +433,15 @@ gtk_css_image_builtin_draw_grip (GtkCssImage *image,
cairo_t *cr, cairo_t *cr,
double width, double width,
double height, double height,
GtkCssImageBuiltinType image_type, GtkCssImageBuiltinType image_type)
const GdkRGBA *bg_color)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
GdkRGBA lighter, darker; GdkRGBA lighter, darker;
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
color_shade (bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 0.7, &darker);
color_shade (bg_color, 1.3, &lighter); color_shade (&builtin->bg_color, 1.3, &lighter);
/* align drawing area to the connected side */ /* align drawing area to the connected side */
if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT) if (image_type == GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT)
@ -686,16 +683,16 @@ void
gtk_css_image_builtin_draw_pane_separator (GtkCssImage *image, gtk_css_image_builtin_draw_pane_separator (GtkCssImage *image,
cairo_t *cr, cairo_t *cr,
double width, double width,
double height, double height)
const GdkRGBA *bg_color)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
GdkRGBA lighter, darker; GdkRGBA lighter, darker;
gint xx, yy; gint xx, yy;
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
color_shade (bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 0.7, &darker);
color_shade (bg_color, 1.3, &lighter); color_shade (&builtin->bg_color, 1.3, &lighter);
if (width > height) if (width > height)
for (xx = width / 2 - 15; xx <= width / 2 + 15; xx += 5) for (xx = width / 2 - 15; xx <= width / 2 + 15; xx += 5)
@ -709,16 +706,16 @@ void
gtk_css_image_builtin_draw_handle (GtkCssImage *image, gtk_css_image_builtin_draw_handle (GtkCssImage *image,
cairo_t *cr, cairo_t *cr,
double width, double width,
double height, double height)
const GdkRGBA *bg_color)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
GdkRGBA lighter, darker; GdkRGBA lighter, darker;
gint xx, yy; gint xx, yy;
cairo_set_line_width (cr, 1.0); cairo_set_line_width (cr, 1.0);
color_shade (bg_color, 0.7, &darker); color_shade (&builtin->bg_color, 0.7, &darker);
color_shade (bg_color, 1.3, &lighter); color_shade (&builtin->bg_color, 1.3, &lighter);
for (yy = 0; yy < height; yy += 3) for (yy = 0; yy < height; yy += 3)
for (xx = 0; xx < width; xx += 6) for (xx = 0; xx < width; xx += 6)
@ -732,9 +729,9 @@ static void
gtk_css_image_builtin_draw_spinner (GtkCssImage *image, gtk_css_image_builtin_draw_spinner (GtkCssImage *image,
cairo_t *cr, cairo_t *cr,
double width, double width,
double height, double height)
const GdkRGBA *color)
{ {
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
gdouble radius; gdouble radius;
radius = MIN (width / 2, height / 2); radius = MIN (width / 2, height / 2);
@ -742,7 +739,7 @@ gtk_css_image_builtin_draw_spinner (GtkCssImage *image,
cairo_save (cr); cairo_save (cr);
cairo_translate (cr, width / 2, height / 2); cairo_translate (cr, width / 2, height / 2);
gdk_cairo_set_source_rgba (cr, color); gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
gtk_render_paint_spinner (cr, radius, -1); gtk_render_paint_spinner (cr, radius, -1);
cairo_restore (cr); cairo_restore (cr);
@ -783,28 +780,50 @@ gtk_css_image_builtin_compute (GtkCssImage *image,
guint property_id, guint property_id,
GtkStyleProviderPrivate *provider, GtkStyleProviderPrivate *provider,
int scale, int scale,
GtkCssStyle *values, GtkCssStyle *style,
GtkCssStyle *parent_values, GtkCssStyle *parent_style,
GtkCssDependencies *dependencies) GtkCssDependencies *dependencies)
{ {
return g_object_ref (image); GtkCssImageBuiltin *result;
GtkBorderStyle border_style;
result = g_object_new (GTK_TYPE_CSS_IMAGE_BUILTIN, NULL);
border_style = _gtk_css_border_style_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_SOLID)
{
GtkBorder border;
border.top = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
result->border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
}
result->fg_color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_COLOR));
result->bg_color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
result->border_color = *_gtk_css_rgba_value_get_rgba (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
/* XXX: We also depend on other values, but I guess we cannot express that */
*dependencies = GTK_CSS_DEPENDS_ON_COLOR;
return GTK_CSS_IMAGE (result);
} }
static gboolean static gboolean
gtk_css_image_builtin_equal (GtkCssImage *image1, gtk_css_image_builtin_equal (GtkCssImage *image1,
GtkCssImage *image2) GtkCssImage *image2)
{ {
return TRUE; GtkCssImageBuiltin *builtin1 = GTK_CSS_IMAGE_BUILTIN (image1);
} GtkCssImageBuiltin *builtin2 = GTK_CSS_IMAGE_BUILTIN (image2);
static GtkCssImage * return gdk_rgba_equal (&builtin1->fg_color, &builtin2->fg_color)
gtk_css_image_builtin_transition (GtkCssImage *start, && gdk_rgba_equal (&builtin1->bg_color, &builtin2->bg_color)
GtkCssImage *end, && gdk_rgba_equal (&builtin1->border_color, &builtin2->border_color)
guint property_id, && builtin1->border_width == builtin2->border_width;
double progress)
{
/* builtin images always look the same, so start == end */
return g_object_ref (start);
} }
static void static void
@ -827,7 +846,6 @@ gtk_css_image_builtin_class_init (GtkCssImageBuiltinClass *klass)
image_class->print = gtk_css_image_builtin_print; image_class->print = gtk_css_image_builtin_print;
image_class->compute = gtk_css_image_builtin_compute; image_class->compute = gtk_css_image_builtin_compute;
image_class->equal = gtk_css_image_builtin_equal; image_class->equal = gtk_css_image_builtin_equal;
image_class->transition = gtk_css_image_builtin_transition;
object_class->dispose = gtk_css_image_builtin_dispose; object_class->dispose = gtk_css_image_builtin_dispose;
} }
@ -835,6 +853,10 @@ gtk_css_image_builtin_class_init (GtkCssImageBuiltinClass *klass)
static void static void
gtk_css_image_builtin_init (GtkCssImageBuiltin *builtin) gtk_css_image_builtin_init (GtkCssImageBuiltin *builtin)
{ {
/* white background */
builtin->bg_color.red = builtin->bg_color.green = builtin->bg_color.blue = builtin->bg_color.alpha = 1.0;
/* black foreground */
builtin->fg_color.alpha = 1.0;
} }
GtkCssImage * GtkCssImage *
@ -853,11 +875,7 @@ gtk_css_image_builtin_draw (GtkCssImage *image,
cairo_t *cr, cairo_t *cr,
double width, double width,
double height, double height,
GtkCssImageBuiltinType image_type, GtkCssImageBuiltinType image_type)
const GdkRGBA * fg_color,
const GdkRGBA * bg_color,
const GdkRGBA * border_color,
int border_width)
{ {
switch (image_type) switch (image_type)
{ {
@ -872,9 +890,7 @@ gtk_css_image_builtin_draw (GtkCssImage *image,
gtk_css_image_builtin_draw_check (image, cr, gtk_css_image_builtin_draw_check (image, cr,
width, height, width, height,
image_type == GTK_CSS_IMAGE_BUILTIN_CHECK_CHECKED, image_type == GTK_CSS_IMAGE_BUILTIN_CHECK_CHECKED,
image_type == GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT, image_type == GTK_CSS_IMAGE_BUILTIN_CHECK_INCONSISTENT);
fg_color, bg_color,
border_color, border_width);
break; break;
case GTK_CSS_IMAGE_BUILTIN_OPTION: case GTK_CSS_IMAGE_BUILTIN_OPTION:
case GTK_CSS_IMAGE_BUILTIN_OPTION_CHECKED: case GTK_CSS_IMAGE_BUILTIN_OPTION_CHECKED:
@ -882,9 +898,7 @@ gtk_css_image_builtin_draw (GtkCssImage *image,
gtk_css_image_builtin_draw_option (image, cr, gtk_css_image_builtin_draw_option (image, cr,
width, height, width, height,
image_type == GTK_CSS_IMAGE_BUILTIN_OPTION_CHECKED, image_type == GTK_CSS_IMAGE_BUILTIN_OPTION_CHECKED,
image_type == GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT, image_type == GTK_CSS_IMAGE_BUILTIN_OPTION_INCONSISTENT);
fg_color, bg_color,
border_color, border_width);
break; break;
case GTK_CSS_IMAGE_BUILTIN_ARROW_UP: case GTK_CSS_IMAGE_BUILTIN_ARROW_UP:
case GTK_CSS_IMAGE_BUILTIN_ARROW_DOWN: case GTK_CSS_IMAGE_BUILTIN_ARROW_DOWN:
@ -892,56 +906,47 @@ gtk_css_image_builtin_draw (GtkCssImage *image,
case GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT: case GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT:
gtk_css_image_builtin_draw_arrow (image, cr, gtk_css_image_builtin_draw_arrow (image, cr,
width, height, width, height,
image_type, image_type);
fg_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
TRUE, FALSE, FALSE, TRUE, FALSE, FALSE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
TRUE, TRUE, FALSE, TRUE, TRUE, FALSE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
FALSE, TRUE, FALSE, FALSE, TRUE, FALSE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT_EXPANDED: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_LEFT_EXPANDED:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
TRUE, FALSE, TRUE, TRUE, FALSE, TRUE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT_EXPANDED: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_LEFT_EXPANDED:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
FALSE, FALSE, TRUE, FALSE, FALSE, TRUE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT_EXPANDED: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_HORIZONTAL_RIGHT_EXPANDED:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT_EXPANDED: case GTK_CSS_IMAGE_BUILTIN_EXPANDER_VERTICAL_RIGHT_EXPANDED:
gtk_css_image_builtin_draw_expander (image, cr, gtk_css_image_builtin_draw_expander (image, cr,
width, height, width, height,
FALSE, TRUE, TRUE, FALSE, TRUE, TRUE);
fg_color, border_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_GRIP_TOPLEFT: case GTK_CSS_IMAGE_BUILTIN_GRIP_TOPLEFT:
case GTK_CSS_IMAGE_BUILTIN_GRIP_TOP: case GTK_CSS_IMAGE_BUILTIN_GRIP_TOP:
@ -953,23 +958,19 @@ gtk_css_image_builtin_draw (GtkCssImage *image,
case GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT: case GTK_CSS_IMAGE_BUILTIN_GRIP_LEFT:
gtk_css_image_builtin_draw_grip (image, cr, gtk_css_image_builtin_draw_grip (image, cr,
width, height, width, height,
image_type, image_type);
bg_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR: case GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR:
gtk_css_image_builtin_draw_pane_separator (image, cr, gtk_css_image_builtin_draw_pane_separator (image, cr,
width, height, width, height);
bg_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_HANDLE: case GTK_CSS_IMAGE_BUILTIN_HANDLE:
gtk_css_image_builtin_draw_handle (image, cr, gtk_css_image_builtin_draw_handle (image, cr,
width, height, width, height);
bg_color);
break; break;
case GTK_CSS_IMAGE_BUILTIN_SPINNER: case GTK_CSS_IMAGE_BUILTIN_SPINNER:
gtk_css_image_builtin_draw_spinner (image, cr, gtk_css_image_builtin_draw_spinner (image, cr,
width, height, width, height);
fg_color);
break; break;
} }
} }

View File

@ -71,6 +71,11 @@ typedef struct _GtkCssImageBuiltinClass GtkCssImageBuiltinClass;
struct _GtkCssImageBuiltin struct _GtkCssImageBuiltin
{ {
GtkCssImage parent; GtkCssImage parent;
GdkRGBA fg_color;
GdkRGBA bg_color;
GdkRGBA border_color;
int border_width;
}; };
struct _GtkCssImageBuiltinClass struct _GtkCssImageBuiltinClass
@ -86,11 +91,7 @@ void gtk_css_image_builtin_draw (GtkCssImage
cairo_t *cr, cairo_t *cr,
double width, double width,
double height, double height,
GtkCssImageBuiltinType image_type, GtkCssImageBuiltinType image_type);
const GdkRGBA *fg_color,
const GdkRGBA *bg_color,
const GdkRGBA *border_color,
int border_width);
G_END_DECLS G_END_DECLS

View File

@ -94,10 +94,8 @@ gtk_do_render_check (GtkStyleContext *context,
gdouble width, gdouble width,
gdouble height) gdouble height)
{ {
GtkBorderStyle border_style;
GtkStateFlags state; GtkStateFlags state;
GtkCssImageBuiltinType image_type; GtkCssImageBuiltinType image_type;
gint border_width;
state = gtk_style_context_get_state (context); state = gtk_style_context_get_state (context);
if (state & GTK_STATE_FLAG_INCONSISTENT) if (state & GTK_STATE_FLAG_INCONSISTENT)
@ -110,34 +108,12 @@ gtk_do_render_check (GtkStyleContext *context,
if (render_icon_image (context, cr, x, y, width, height)) if (render_icon_image (context, cr, x, y, width, height))
return; return;
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_SOLID)
{
GtkBorder border;
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
}
else
{
border_width = 0;
}
cairo_translate (cr, x, y); cairo_translate (cr, x, y);
gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)),
cr, cr,
width, height, width, height,
image_type, image_type);
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR)),
border_width);
} }
/** /**
@ -191,10 +167,8 @@ gtk_do_render_option (GtkStyleContext *context,
gdouble width, gdouble width,
gdouble height) gdouble height)
{ {
GtkBorderStyle border_style;
GtkStateFlags state; GtkStateFlags state;
GtkCssImageBuiltinType image_type; GtkCssImageBuiltinType image_type;
gint border_width;
state = gtk_style_context_get_state (context); state = gtk_style_context_get_state (context);
if (state & GTK_STATE_FLAG_INCONSISTENT) if (state & GTK_STATE_FLAG_INCONSISTENT)
@ -207,34 +181,12 @@ gtk_do_render_option (GtkStyleContext *context,
if (render_icon_image (context, cr, x, y, width, height)) if (render_icon_image (context, cr, x, y, width, height))
return; return;
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_SOLID)
{
GtkBorder border;
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
}
else
{
border_width = 0;
}
cairo_translate (cr, x, y); cairo_translate (cr, x, y);
gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)),
cr, cr,
width, height, width, height,
image_type, image_type);
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR)),
border_width);
} }
/** /**
@ -286,9 +238,7 @@ gtk_do_render_arrow (GtkStyleContext *context,
gdouble y, gdouble y,
gdouble size) gdouble size)
{ {
GtkBorderStyle border_style;
GtkCssImageBuiltinType image_type; GtkCssImageBuiltinType image_type;
gint border_width;
/* map [0, 2 * pi) to [0, 4) */ /* map [0, 2 * pi) to [0, 4) */
angle = round (2 * angle / G_PI); angle = round (2 * angle / G_PI);
@ -316,34 +266,12 @@ gtk_do_render_arrow (GtkStyleContext *context,
if (render_icon_image (context, cr, x, y, size, size)) if (render_icon_image (context, cr, x, y, size, size))
return; return;
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_SOLID)
{
GtkBorder border;
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
}
else
{
border_width = 0;
}
cairo_translate (cr, x, y); cairo_translate (cr, x, y);
gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)),
cr, cr,
size, size, size, size,
image_type, image_type);
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR)),
border_width);
} }
/** /**
@ -484,10 +412,8 @@ gtk_do_render_expander (GtkStyleContext *context,
gdouble width, gdouble width,
gdouble height) gdouble height)
{ {
GtkBorderStyle border_style;
GtkCssImageBuiltinType image_type; GtkCssImageBuiltinType image_type;
GtkStateFlags state; GtkStateFlags state;
gint border_width;
state = gtk_style_context_get_state (context); state = gtk_style_context_get_state (context);
if (gtk_style_context_has_class (context, "horizontal")) if (gtk_style_context_has_class (context, "horizontal"))
@ -516,34 +442,12 @@ gtk_do_render_expander (GtkStyleContext *context,
if (render_icon_image (context, cr, x, y, width, height)) if (render_icon_image (context, cr, x, y, width, height))
return; return;
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_SOLID)
{
GtkBorder border;
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
}
else
{
border_width = 0;
}
cairo_translate (cr, x, y); cairo_translate (cr, x, y);
gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)),
cr, cr,
width, height, width, height,
image_type, image_type);
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR)),
border_width);
} }
/** /**
@ -1093,8 +997,6 @@ gtk_do_render_handle (GtkStyleContext *context,
gdouble height) gdouble height)
{ {
GtkCssImageBuiltinType type; GtkCssImageBuiltinType type;
GtkBorderStyle border_style;
gint border_width;
gtk_render_background (context, cr, x, y, width, height); gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height); gtk_render_frame (context, cr, x, y, width, height);
@ -1102,24 +1004,6 @@ gtk_do_render_handle (GtkStyleContext *context,
if (render_icon_image (context, cr, x, y, width, height)) if (render_icon_image (context, cr, x, y, width, height))
return; return;
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_SOLID)
{
GtkBorder border;
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
}
else
{
border_width = 0;
}
cairo_translate (cr, x, y); cairo_translate (cr, x, y);
if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_GRIP)) if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_GRIP))
@ -1158,11 +1042,7 @@ gtk_do_render_handle (GtkStyleContext *context,
gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)),
cr, cr,
width, height, width, height,
type, type);
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR)),
border_width);
} }
/** /**
@ -1264,40 +1144,15 @@ gtk_do_render_activity (GtkStyleContext *context,
gdouble width, gdouble width,
gdouble height) gdouble height)
{ {
GtkBorderStyle border_style;
gint border_width;
if (render_icon_image (context, cr, x, y, width, height)) if (render_icon_image (context, cr, x, y, width, height))
return; return;
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
if (border_style == GTK_BORDER_STYLE_SOLID)
{
GtkBorder border;
border.top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
border.right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
border.bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
border.left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
border_width = MIN (MIN (border.top, border.bottom),
MIN (border.left, border.right));
}
else
{
border_width = 0;
}
cairo_translate (cr, x, y); cairo_translate (cr, x, y);
gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)),
cr, cr,
width, height, width, height,
GTK_CSS_IMAGE_BUILTIN_SPINNER, GTK_CSS_IMAGE_BUILTIN_SPINNER);
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR)),
_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_COLOR)),
border_width);
} }
/** /**