summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-13 23:40:36 +0000
committerrubidium <rubidium@openttd.org>2010-11-13 23:40:36 +0000
commita9da53c1068f9279ae82a557d46ece01f5beecd1 (patch)
tree783e7844b5a720f4601816bbeb8207e8d809e708 /src/window.cpp
parentfc75b00992dbf6f86a39aca1a2cda4e6378b6bba (diff)
downloadopenttd-a9da53c1068f9279ae82a557d46ece01f5beecd1.tar.xz
(svn r21179) -Fix [FS#4201] (r69): if the main toolbar's location is configurable, why isn't the statusbar's location configurable?
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 8d219ea45..0d4b1f80f 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -33,6 +33,7 @@
#include "newgrf_debug.h"
#include "hotkeys.h"
#include "toolbar_gui.h"
+#include "statusbar_gui.h"
#include "table/sprites.h"
@@ -2642,27 +2643,49 @@ void ReInitAllWindows()
}
/**
- * (Re)position main toolbar window at the screen
- * @param w Window structure of the main toolbar window, may also be \c NULL
- * @return X coordinate of left edge of the repositioned toolbar window
+ * (Re)position a window at the screen.
+ * @param w Window structure of the window, may also be \c NULL.
+ * @param clss The class of the window to position.
+ * @param setting The actual setting used for the window's position.
+ * @return X coordinate of left edge of the repositioned window.
*/
-int PositionMainToolbar(Window *w)
+static int PositionWindow(Window *w, WindowClass clss, int setting)
{
- DEBUG(misc, 5, "Repositioning Main Toolbar...");
-
- if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) {
- w = FindWindowById(WC_MAIN_TOOLBAR, 0);
+ if (w == NULL || w->window_class != clss) {
+ w = FindWindowById(clss, 0);
}
- switch (_settings_client.gui.toolbar_pos) {
+ switch (setting) {
case 1: w->left = (_screen.width - w->width) / 2; break;
case 2: w->left = _screen.width - w->width; break;
- default: w->left = 0;
+ default: w->left = 0; break;
}
- SetDirtyBlocks(0, 0, _screen.width, w->height); // invalidate the whole top part
+ SetDirtyBlocks(0, w->top, _screen.width, w->top + w->height); // invalidate the whole row
return w->left;
}
+/**
+ * (Re)position main toolbar window at the screen.
+ * @param w Window structure of the main toolbar window, may also be \c NULL.
+ * @return X coordinate of left edge of the repositioned toolbar window.
+ */
+int PositionMainToolbar(Window *w)
+{
+ DEBUG(misc, 5, "Repositioning Main Toolbar...");
+ return PositionWindow(w, WC_MAIN_TOOLBAR, _settings_client.gui.toolbar_pos);
+}
+
+/**
+ * (Re)position statusbar window at the screen.
+ * @param w Window structure of the statusbar window, may also be \c NULL.
+ * @return X coordinate of left edge of the repositioned statusbar.
+ */
+int PositionStatusbar(Window *w)
+{
+ DEBUG(misc, 5, "Repositioning statusbar...");
+ return PositionWindow(w, WC_STATUS_BAR, _settings_client.gui.statusbar_pos);
+}
+
/**
* Switches viewports following vehicles, which get autoreplaced
@@ -2718,9 +2741,10 @@ void RelocateAllWindows(int neww, int newh)
break;
case WC_STATUS_BAR:
- ResizeWindow(w, Clamp(neww, 320, 640) - w->width, 0);
+ ResizeWindow(w, min(neww, *_preferred_statusbar_size) - w->width, 0);
+
top = newh - w->height;
- left = (neww - w->width) >> 1;
+ left = PositionStatusbar(w);
break;
case WC_SEND_NETWORK_MSG: