diff options
author | Benjamin Otte <otte@redhat.com> | 2015-01-19 17:14:55 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-01-20 06:30:19 +0100 |
commit | 45541cbf10a13716680df52c6a214495fb8243d7 (patch) | |
tree | 45b034b9e0c19144300e8b9ce4f90879c607be4b /gtk/gtkrender.c | |
parent | 9ce8ce119853635692139a13c3b85602696486ef (diff) | |
download | gtk+-45541cbf10a13716680df52c6a214495fb8243d7.tar.gz |
render: Don't require passing CSS properties to builtin images
Instead, make the buiultin image get those properties itself in the
compute vfunc.
Diffstat (limited to 'gtk/gtkrender.c')
-rw-r--r-- | gtk/gtkrender.c | 157 |
1 files changed, 6 insertions, 151 deletions
diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c index 54bc410036..6b03ac4985 100644 --- a/gtk/gtkrender.c +++ b/gtk/gtkrender.c @@ -94,10 +94,8 @@ gtk_do_render_check (GtkStyleContext *context, gdouble width, gdouble height) { - GtkBorderStyle border_style; GtkStateFlags state; GtkCssImageBuiltinType image_type; - gint border_width; state = gtk_style_context_get_state (context); 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)) 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); gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), cr, width, height, - 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); + image_type); } /** @@ -191,10 +167,8 @@ gtk_do_render_option (GtkStyleContext *context, gdouble width, gdouble height) { - GtkBorderStyle border_style; GtkStateFlags state; GtkCssImageBuiltinType image_type; - gint border_width; state = gtk_style_context_get_state (context); 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)) 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); gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), cr, width, height, - 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); + image_type); } /** @@ -286,9 +238,7 @@ gtk_do_render_arrow (GtkStyleContext *context, gdouble y, gdouble size) { - GtkBorderStyle border_style; GtkCssImageBuiltinType image_type; - gint border_width; /* map [0, 2 * pi) to [0, 4) */ 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)) 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); gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), cr, size, size, - 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); + image_type); } /** @@ -484,10 +412,8 @@ gtk_do_render_expander (GtkStyleContext *context, gdouble width, gdouble height) { - GtkBorderStyle border_style; GtkCssImageBuiltinType image_type; GtkStateFlags state; - gint border_width; state = gtk_style_context_get_state (context); 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)) 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); gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), cr, width, height, - 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); + image_type); } /** @@ -1093,8 +997,6 @@ gtk_do_render_handle (GtkStyleContext *context, gdouble height) { GtkCssImageBuiltinType type; - GtkBorderStyle border_style; - gint border_width; gtk_render_background (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)) 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); 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)), cr, width, height, - 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); + type); } /** @@ -1264,40 +1144,15 @@ gtk_do_render_activity (GtkStyleContext *context, gdouble width, gdouble height) { - GtkBorderStyle border_style; - gint border_width; - if (render_icon_image (context, cr, x, y, width, height)) 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); gtk_css_image_builtin_draw (_gtk_css_image_value_get_image (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_SOURCE)), cr, width, height, - 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); + GTK_CSS_IMAGE_BUILTIN_SPINNER); } /** |