summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-10-14 00:26:24 +0000
committerbelugas <belugas@openttd.org>2007-10-14 00:26:24 +0000
commitc78c96a8ad9e0670ad74c2e27caa8915b4dfa07b (patch)
tree73c9cfa2c3e5413519763ef72ca91dc97ce52a0e /src
parentd47e51c246fda12c29596598d7d7f8a030fc8b63 (diff)
downloadopenttd-c78c96a8ad9e0670ad74c2e27caa8915b4dfa07b.tar.xz
(svn r11256) -Codechange: Make opening a new toolbar not overlapping its parent one, by locating it under the parent, and aligned with the left side of it.
FS#1310, by BigBB
Diffstat (limited to 'src')
-rw-r--r--src/window.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/window.cpp b/src/window.cpp
index ba105839a..82458879b 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -843,23 +843,35 @@ restart:
}
}
+/**
+ * Set the x and y coordinates of a new window.
+ *
+ * @param *desc The pointer to the WindowDesc to be created
+ * @param window_number the window number of the new window
+ * @param data arbitrary data that is send with the WE_CREATE message
+ *
+ * @return see Window pointer of the newly created window
+ */
static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number, void *data)
{
Point pt;
Window *w;
/* By default position a child window at an offset of 10/10 of its parent.
+ * With the exception of WC_BUILD_TOOLBAR (build railway/roads/ship docks/airports)
+ * and WC_SCEN_LAND_GEN (landscaping). Whose child window has an offset of 0/36 of
+ * its parent. So it's exactly under the parent toolbar and no buttons will be covered.
* However if it falls too extremely outside window positions, reposition
* it to an automatic place */
if (desc->parent_cls != 0 /* WC_MAIN_WINDOW */ &&
(w = FindWindowById(desc->parent_cls, window_number)) != NULL &&
w->left < _screen.width - 20 && w->left > -60 && w->top < _screen.height - 20) {
- pt.x = w->left + 10;
+ pt.x = w->left + ((desc->parent_cls == WC_BUILD_TOOLBAR || desc->parent_cls == WC_SCEN_LAND_GEN) ? 0 : 10);
if (pt.x > _screen.width + 10 - desc->default_width) {
pt.x = (_screen.width + 10 - desc->default_width) - 20;
}
- pt.y = w->top + 10;
+ pt.y = w->top + ((desc->parent_cls == WC_BUILD_TOOLBAR || desc->parent_cls == WC_SCEN_LAND_GEN) ? 36 : 10);
} else {
switch (desc->left) {
case WDP_ALIGN_TBR: { /* Align the right side with the top toolbar */