(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.
authorbelugas
Sun, 14 Oct 2007 00:26:24 +0000
changeset 8217 ce7255c36b9e
parent 8216 12d1cff88d38
child 8218 498db432e926
(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
src/window.cpp
--- a/src/window.cpp	Sat Oct 13 16:56:29 2007 +0000
+++ b/src/window.cpp	Sun Oct 14 00:26:24 2007 +0000
@@ -843,23 +843,35 @@
 	}
 }
 
+/**
+ * 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 */