From 16c90ed48bf8e840d303ff3f52984e91d6e22776 Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 18 Nov 2010 19:24:40 +0000 Subject: (svn r21244) -Fix [FS#4240] (r21179): the news message always stayed in the middle; let it follow the setting of the statusbar instead --- src/window.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/window.cpp') diff --git a/src/window.cpp b/src/window.cpp index 0d4b1f80f..1e85a42c0 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2654,12 +2654,15 @@ static int PositionWindow(Window *w, WindowClass clss, int setting) if (w == NULL || w->window_class != clss) { w = FindWindowById(clss, 0); } + if (w == NULL) return 0; + int old_left = w->left; 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; break; } + if (w->viewport != NULL) w->viewport->left += w->left - old_left; SetDirtyBlocks(0, w->top, _screen.width, w->top + w->height); // invalidate the whole row return w->left; } @@ -2686,6 +2689,17 @@ int PositionStatusbar(Window *w) return PositionWindow(w, WC_STATUS_BAR, _settings_client.gui.statusbar_pos); } +/** + * (Re)position news message window at the screen. + * @param w Window structure of the news message window, may also be \c NULL. + * @return X coordinate of left edge of the repositioned news message. + */ +int PositionNewsMessage(Window *w) +{ + DEBUG(misc, 5, "Repositioning news message..."); + return PositionWindow(w, WC_NEWS_WINDOW, _settings_client.gui.statusbar_pos); +} + /** * Switches viewports following vehicles, which get autoreplaced @@ -2737,7 +2751,7 @@ void RelocateAllWindows(int neww, int newh) case WC_NEWS_WINDOW: top = newh - w->height; - left = (neww - w->width) >> 1; + left = PositionNewsMessage(w); break; case WC_STATUS_BAR: -- cgit v1.2.3-54-g00ecf