From e0b1943c97a0becc239d22283835a3cbead0d5bc Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 13 Jun 2011 05:49:12 +0200 Subject: [PATCH] roundedbox: Fix border radius grow algorithm When one radius gets to 0, the other should be set to 0, too. Otherwise the paths constructed from it will not be correct. --- gtk/gtkroundedbox.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/gtk/gtkroundedbox.c b/gtk/gtkroundedbox.c index 843328257e..3414e484f3 100644 --- a/gtk/gtkroundedbox.c +++ b/gtk/gtkroundedbox.c @@ -81,6 +81,20 @@ _gtk_rounded_box_apply_border_radius (GtkRoundedBox *box, g_free (bottom_left_radius); } +static void +gtk_css_border_radius_grow (GtkCssBorderCornerRadius *corner, + double horizontal, + double vertical) +{ + corner->horizontal += horizontal; + corner->vertical += vertical; + + if (corner->horizontal <= 0 || corner->vertical <= 0) + { + corner->horizontal = 0; + corner->vertical = 0; + } +} void _gtk_rounded_box_grow (GtkRoundedBox *box, double top, @@ -110,22 +124,10 @@ _gtk_rounded_box_grow (GtkRoundedBox *box, box->box.height += top + bottom; } - if (box->border_radius.top_left.horizontal) - box->border_radius.top_left.horizontal = MAX (0, box->border_radius.top_left.horizontal + left); - if (box->border_radius.top_left.vertical) - box->border_radius.top_left.vertical = MAX (0, box->border_radius.top_left.vertical + top); - if (box->border_radius.top_right.horizontal) - box->border_radius.top_right.horizontal = MAX (0, box->border_radius.top_right.horizontal + right); - if (box->border_radius.top_right.vertical) - box->border_radius.top_right.vertical = MAX (0, box->border_radius.top_right.vertical + top); - if (box->border_radius.bottom_right.horizontal) - box->border_radius.bottom_right.horizontal = MAX (0, box->border_radius.bottom_right.horizontal + right); - if (box->border_radius.bottom_right.vertical) - box->border_radius.bottom_right.vertical = MAX (0, box->border_radius.bottom_right.vertical + bottom); - if (box->border_radius.bottom_left.horizontal) - box->border_radius.bottom_left.horizontal = MAX (0, box->border_radius.bottom_left.horizontal + left); - if (box->border_radius.bottom_left.vertical) - box->border_radius.bottom_left.vertical = MAX (0, box->border_radius.bottom_left.vertical + bottom); + gtk_css_border_radius_grow (&box->border_radius.top_left, left, top); + gtk_css_border_radius_grow (&box->border_radius.top_right, right, bottom); + gtk_css_border_radius_grow (&box->border_radius.bottom_right, right, top); + gtk_css_border_radius_grow (&box->border_radius.bottom_left, left, bottom); } void