diff options
author | Benjamin Otte <otte@redhat.com> | 2016-12-19 19:19:15 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-12-20 18:01:12 +0100 |
commit | 4d9eedafcd13423d4ccb3530fad29bda75701879 (patch) | |
tree | 12a19f366d0268ba98c91861ec37191b619679aa /gtk/gtkrenderbackground.c | |
parent | 95a2a5c54c6480b62be482145ee40c58a15b4bd8 (diff) | |
download | gtk+-4d9eedafcd13423d4ccb3530fad29bda75701879.tar.gz |
roundedbox: Add gtk_rounded_boxes_init_for_style()
Instead of making people intiialize a rectangle and then applying border
radius manually, provide a constructor that does it for them.
While doing that, also allow people to instead request the padding box
or the content box.
Refactor all relevant code to use this new constructor.
Diffstat (limited to 'gtk/gtkrenderbackground.c')
-rw-r--r-- | gtk/gtkrenderbackground.c | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c index ae80f5fefc..051a9fddd1 100644 --- a/gtk/gtkrenderbackground.c +++ b/gtk/gtkrenderbackground.c @@ -529,39 +529,13 @@ gtk_theming_background_init (GtkThemingBackground *bg, double width, double height) { - GtkBorder border, padding; - bg->style = style; - border.top = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100); - border.right = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100); - border.bottom = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100); - border.left = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100); - padding.top = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_TOP), 100); - padding.right = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_RIGHT), 100); - padding.bottom = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_BOTTOM), 100); - padding.left = _gtk_css_number_value_get (gtk_css_style_get_value (bg->style, GTK_CSS_PROPERTY_PADDING_LEFT), 100); - - /* In the CSS box model, by default the background positioning area is - * the padding-box, i.e. all the border-box minus the borders themselves, - * which determines also its default size, see - * http://dev.w3.org/csswg/css3-background/#background-origin - * - * In the future we might want to support different origins or clips, but - * right now we just shrink to the default. - */ - _gtk_rounded_box_init_rect (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], 0, 0, width, height); - _gtk_rounded_box_apply_border_radius_for_style (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], bg->style); - - bg->boxes[GTK_CSS_AREA_PADDING_BOX] = bg->boxes[GTK_CSS_AREA_BORDER_BOX]; - gsk_rounded_rect_shrink (&bg->boxes[GTK_CSS_AREA_PADDING_BOX], - border.top, border.right, - border.bottom, border.left); - - bg->boxes[GTK_CSS_AREA_CONTENT_BOX] = bg->boxes[GTK_CSS_AREA_PADDING_BOX]; - gsk_rounded_rect_shrink (&bg->boxes[GTK_CSS_AREA_CONTENT_BOX], - padding.top, padding.right, - padding.bottom, padding.left); + gtk_rounded_boxes_init_for_style (&bg->boxes[GTK_CSS_AREA_BORDER_BOX], + &bg->boxes[GTK_CSS_AREA_PADDING_BOX], + &bg->boxes[GTK_CSS_AREA_CONTENT_BOX], + style, + 0, 0, width, height); } void |