Commit 45541cbf authored by Benjamin Otte's avatar Benjamin Otte

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

Instead, make the buiultin image get those properties itself in the
compute vfunc.
parent 9ce8ce11
This diff is collapsed.
...@@ -70,7 +70,12 @@ typedef struct _GtkCssImageBuiltinClass GtkCssImageBuiltinClass; ...@@ -70,7 +70,12 @@ 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 ...@@ -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
......
...@@ -94,10 +94,8 @@ gtk_do_render_check (GtkStyleContext *context, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment