summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-04-04 20:47:51 +0000
committerrubidium <rubidium@openttd.org>2010-04-04 20:47:51 +0000
commitbd629ad7c093a73ffbb4fd6a98e953172681bacc (patch)
tree81ab98b019a4d2a38dd60c132f27c1562822d7ca /src
parentb966bdc23cc0ee5d5a8b6bd11bd76b306d8e470f (diff)
downloadopenttd-bd629ad7c093a73ffbb4fd6a98e953172681bacc.tar.xz
(svn r19563) -Fix [FS#3733] (r19558): OnResize wasn't called often enough so scrollbars were in some cases not properly updated causing division by zero
Diffstat (limited to 'src')
-rw-r--r--src/window.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/window.cpp b/src/window.cpp
index ba3d7f0eb..78fbd1ac5 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1413,18 +1413,20 @@ static bool HandleMouseOver()
*/
void ResizeWindow(Window *w, int delta_x, int delta_y)
{
- if (delta_x == 0 && delta_y == 0) return;
+ if (delta_x != 0 || delta_y != 0) {
+ w->SetDirty();
- w->SetDirty();
+ uint new_xinc = max(0, (w->nested_root->resize_x == 0) ? 0 : (int)(w->nested_root->current_x - w->nested_root->smallest_x) + delta_x);
+ uint new_yinc = max(0, (w->nested_root->resize_y == 0) ? 0 : (int)(w->nested_root->current_y - w->nested_root->smallest_y) + delta_y);
+ assert(w->nested_root->resize_x == 0 || new_xinc % w->nested_root->resize_x == 0);
+ assert(w->nested_root->resize_y == 0 || new_yinc % w->nested_root->resize_y == 0);
- uint new_xinc = max(0, (w->nested_root->resize_x == 0) ? 0 : (int)(w->nested_root->current_x - w->nested_root->smallest_x) + delta_x);
- uint new_yinc = max(0, (w->nested_root->resize_y == 0) ? 0 : (int)(w->nested_root->current_y - w->nested_root->smallest_y) + delta_y);
- assert(w->nested_root->resize_x == 0 || new_xinc % w->nested_root->resize_x == 0);
- assert(w->nested_root->resize_y == 0 || new_yinc % w->nested_root->resize_y == 0);
+ w->nested_root->AssignSizePosition(ST_RESIZE, 0, 0, w->nested_root->smallest_x + new_xinc, w->nested_root->smallest_y + new_yinc, _dynlang.text_dir == TD_RTL);
+ w->width = w->nested_root->current_x;
+ w->height = w->nested_root->current_y;
+ }
- w->nested_root->AssignSizePosition(ST_RESIZE, 0, 0, w->nested_root->smallest_x + new_xinc, w->nested_root->smallest_y + new_yinc, _dynlang.text_dir == TD_RTL);
- w->width = w->nested_root->current_x;
- w->height = w->nested_root->current_y;
+ /* Always call OnResize to make sure everything is initialised correctly if it needs to be. */
w->OnResize();
w->SetDirty();
}