summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-27 22:08:59 +0000
committerrubidium <rubidium@openttd.org>2007-07-27 22:08:59 +0000
commite68a3e9777ca0df7d6d995df6226a217c264fbdd (patch)
tree2587f3657838b9209b63ea34710dd8f78f16bb37 /src
parent705696f7365d3397fc2f691a7692630def1ac616 (diff)
downloadopenttd-e68a3e9777ca0df7d6d995df6226a217c264fbdd.tar.xz
(svn r10707) -Codechange: account for the main toolbar and status bar when determining the maximum height for a window.
Diffstat (limited to 'src')
-rw-r--r--src/window.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 7fdf5f516..3ba38a03a 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -658,8 +658,15 @@ static Window *LocalAllocateWindow(
/* Try to make windows smaller when our window is too small */
if (min_width != def_width || min_height != def_height) {
- int enlarge_x = max(min(def_width - min_width, _screen.width - min_width), 0);
- int enlarge_y = max(min(def_height - min_height, _screen.height - min_height), 0);
+ /* Think about the overlapping toolbars when determining the minimum window size */
+ int free_height = _screen.height;
+ const Window *wt = FindWindowById(WC_STATUS_BAR, 0);
+ if (wt != NULL) free_height -= wt->height;
+ wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
+ if (wt != NULL) free_height -= wt->height;
+
+ int enlarge_x = max(min(def_width - min_width, _screen.width - min_width), 0);
+ int enlarge_y = max(min(def_height - min_height, free_height - min_height), 0);
/* X and Y has to go by step.. calculate it.
* The cast to int is necessary else x/y are implicitly casted to
@@ -676,11 +683,12 @@ static Window *LocalAllocateWindow(
e.we.sizing.diff.x = enlarge_x;
e.we.sizing.diff.y = enlarge_y;
w->wndproc(w, &e);
-
- if (w->left < 0) w->left = 0;
- if (w->top < 0) w->top = 0;
}
+ const Window *wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
+ w->top = max(w->top, (wt == NULL || w == wt) ? 0 : wt->height);
+ w->left = max(w->left, 0);
+
SetWindowDirty(w);
return w;