(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
pull/155/head
belugas 17 years ago
parent 748d5141cd
commit 5a64bb79d8

@ -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 */

Loading…
Cancel
Save