diff options
author | Benjamin Otte <otte@redhat.com> | 2014-10-07 23:24:51 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2014-10-08 05:20:30 +0200 |
commit | c39bd623f648dab0da290fbe9b3a3bafde20fd21 (patch) | |
tree | fd9d728abb0e7609393cd1e1e8f9430cef887e53 /gtk/gtkrender.c | |
parent | 7295c8f12bddc081a4736eb45d9bad1e45d8cdd3 (diff) | |
download | gtk+-c39bd623f648dab0da290fbe9b3a3bafde20fd21.tar.gz |
colorswatch: Render background properly
We want to render a background *and* the current color (if there is
one).
This also adds a custom function gtk_render_add_content_path() which
adds the path of the current content area to a cairo_t.
Diffstat (limited to 'gtk/gtkrender.c')
-rw-r--r-- | gtk/gtkrender.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gtk/gtkrender.c b/gtk/gtkrender.c index 3f6bc17dbd..2f3f542209 100644 --- a/gtk/gtkrender.c +++ b/gtk/gtkrender.c @@ -2446,3 +2446,47 @@ gtk_render_icon_surface (GtkStyleContext *context, cairo_restore (cr); } +/* + * gtk_render_content_path: + * @context: style context to get style information from + * @cr: cairo context to add path to + * @x: x coordinate of CSS box + * @y: y coordinate of CSS box + * @width: width of CSS box + * @height: height of CSS box + * + * Adds the path of the content box to @cr for a given border box. + * This function respects rounded corners. + * + * This is useful if you are drawing content that is supposed to + * fill the whole content area, like the color buttons in + * #GtkColorChooserDialog. + **/ +void +gtk_render_content_path (GtkStyleContext *context, + cairo_t *cr, + double x, + double y, + double width, + double height) +{ + GtkRoundedBox box; + + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + g_return_if_fail (cr != NULL); + + _gtk_rounded_box_init_rect (&box, x, y, width, height); + _gtk_rounded_box_apply_border_radius_for_context (&box, context, 0); + + _gtk_rounded_box_shrink (&box, + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100) + + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_TOP), 100), + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100) + + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_RIGHT), 100), + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100) + + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_BOTTOM), 100), + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100) + + _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_LEFT), 100)); + + _gtk_rounded_box_path (&box, cr); +} |