summaryrefslogtreecommitdiff
path: root/src/widget.cpp
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-08-03 17:35:08 +0000
committerpeter1138 <peter1138@openttd.org>2008-08-03 17:35:08 +0000
commit92b63e38f0a43c6f1bbea8d507fd6617ecbb920e (patch)
treea8259257d2fec8e54da382e9da4625c42cfb0b9e /src/widget.cpp
parentb92c4cfc92f53259dd8f108d7cbb29a19bdc61d6 (diff)
downloadopenttd-92b63e38f0a43c6f1bbea8d507fd6617ecbb920e.tar.xz
(svn r13977) -Codechange: Let ResizeWindowForWidget() handle hidden (zero height or zero width) widgets.
Diffstat (limited to 'src/widget.cpp')
-rw-r--r--src/widget.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 04540d64a..aa93317d2 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -590,18 +590,23 @@ void ResizeButtons(Window *w, byte left, byte right)
}
/** Resize a widget and shuffle other widgets around to fit. */
-void ResizeWindowForWidget(Window *w, int widget, int delta_x, int delta_y)
+void ResizeWindowForWidget(Window *w, uint widget, int delta_x, int delta_y)
{
int right = w->widget[widget].right;
int bottom = w->widget[widget].bottom;
for (uint i = 0; i < w->widget_count; i++) {
- if (w->widget[i].left >= right) w->widget[i].left += delta_x;
+ if (w->widget[i].left >= right && i != widget) w->widget[i].left += delta_x;
if (w->widget[i].right >= right) w->widget[i].right += delta_x;
- if (w->widget[i].top >= bottom) w->widget[i].top += delta_y;
+ if (w->widget[i].top >= bottom && i != widget) w->widget[i].top += delta_y;
if (w->widget[i].bottom >= bottom) w->widget[i].bottom += delta_y;
}
+ /* A hidden widget has bottom == top or right == left, we need to make it
+ * one less to fit in its new gap. */
+ if (right == w->widget[widget].left) w->widget[widget].right--;
+ if (bottom == w->widget[widget].top) w->widget[widget].bottom--;
+
w->width += delta_x;
w->height += delta_y;
w->resize.width += delta_x;