diff options
author | belugas <belugas@openttd.org> | 2007-10-14 00:26:24 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2007-10-14 00:26:24 +0000 |
commit | 5a64bb79d89b9b02ebee39a8eee6895ca7d0c85d (patch) | |
tree | 73c9cfa2c3e5413519763ef72ca91dc97ce52a0e | |
parent | 748d5141cd4fc87fe1ed5dec2478fa51e9f22803 (diff) | |
download | openttd-5a64bb79d89b9b02ebee39a8eee6895ca7d0c85d.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
-rw-r--r-- | src/window.cpp | 16 |
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 */ |