summaryrefslogtreecommitdiff
path: root/gtk/gtkroundedbox.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-06-12 03:42:29 +0200
committerBenjamin Otte <otte@redhat.com>2011-06-12 03:42:29 +0200
commitdeed7175ca81f2ee3d57c88a525c3be403055079 (patch)
tree7cefda460aed93858d8766c0db679efc0fc8013a /gtk/gtkroundedbox.c
parent61c253a13230ad2d7ff07e6e082ef8d47d35784c (diff)
downloadgtk+-deed7175ca81f2ee3d57c88a525c3be403055079.tar.gz
roundedbox: Handle shrinking to zero
We need it for wide separators.
Diffstat (limited to 'gtk/gtkroundedbox.c')
-rw-r--r--gtk/gtkroundedbox.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/gtk/gtkroundedbox.c b/gtk/gtkroundedbox.c
index 001a5c29ba..843328257e 100644
--- a/gtk/gtkroundedbox.c
+++ b/gtk/gtkroundedbox.c
@@ -88,13 +88,27 @@ _gtk_rounded_box_grow (GtkRoundedBox *box,
double bottom,
double left)
{
+ if (box->box.width + left + right < 0)
+ {
+ box->box.x -= left * box->box.width / (left + right);
+ box->box.width = 0;
+ }
+ else
+ {
+ box->box.x -= left;
+ box->box.width += left + right;
+ }
- box->box.x -= left;
- box->box.width += left + right;
- g_warn_if_fail (box->box.width > 0);
- box->box.y -= top;
- box->box.height += top + bottom;
- g_warn_if_fail (box->box.height > 0);
+ if (box->box.height + bottom + right < 0)
+ {
+ box->box.y -= top * box->box.height / (top + bottom);
+ box->box.height = 0;
+ }
+ else
+ {
+ box->box.y -= top;
+ 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);