diff options
author | frosch <frosch@openttd.org> | 2010-05-01 15:32:17 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-05-01 15:32:17 +0000 |
commit | 68c1213efa1cbe051a5c0cf88a552bd741720d96 (patch) | |
tree | d2f3f4916f82098cbb0bb4179e4d45fb626d3721 | |
parent | 7563432119660a13ce47fc8779cef4da156c4bcd (diff) | |
download | openttd-68c1213efa1cbe051a5c0cf88a552bd741720d96.tar.xz |
(svn r19746) -Fix [FS#3675]: Do not recenter usually centered windows when resizing main window or changing language, if they have been moved/resized before.
-rw-r--r-- | src/window.cpp | 27 | ||||
-rw-r--r-- | src/window_gui.h | 4 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/window.cpp b/src/window.cpp index 4b824a775..447f247d6 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -835,22 +835,22 @@ static void BringWindowToFront(Window *w) /** * Initializes the data (except the position and initial size) of a new Window. - * @param cls Class of the window, used for identification and grouping. @see WindowClass + * @param desc Window description. * @param window_number Number being assigned to the new window - * @param desc_flags Window flags. @see WindowDefaultFlag * @return Window pointer of the newly created window * @pre If nested widgets are used (\a widget is \c NULL), #nested_root and #nested_array_size must be initialized. * In addition, #nested_array is either \c NULL, or already initialized. */ -void Window::InitializeData(WindowClass cls, int window_number, uint32 desc_flags) +void Window::InitializeData(const WindowDesc *desc, WindowNumber window_number) { /* Set up window properties; some of them are needed to set up smallest size below */ - this->window_class = cls; + this->window_class = desc->cls; this->flags4 |= WF_WHITE_BORDER_MASK; // just opened windows have a white border + if (desc->default_pos == WDP_CENTER) this->flags4 |= WF_CENTERED; this->owner = INVALID_OWNER; this->nested_focus = NULL; this->window_number = window_number; - this->desc_flags = desc_flags; + this->desc_flags = desc->flags; this->OnInit(); /* Initialize nested widget tree. */ @@ -1235,7 +1235,7 @@ void Window::CreateNestedTree(const WindowDesc *desc, bool fill_nested) */ void Window::FinishInitNested(const WindowDesc *desc, WindowNumber window_number) { - this->InitializeData(desc->cls, window_number, desc->flags); + this->InitializeData(desc, window_number); Point pt = this->OnInitialPosition(desc, this->nested_root->smallest_x, this->nested_root->smallest_y, window_number); this->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y); this->FindWindowPlacementAndResize(desc->default_width, desc->default_height); @@ -1702,6 +1702,7 @@ static bool HandleWindowDragging() static void StartWindowDrag(Window *w) { w->flags4 |= WF_DRAGGING; + w->flags4 &= ~WF_CENTERED; _dragging_window = true; _drag_delta.x = w->left - _cursor.pos.x; @@ -1719,6 +1720,7 @@ static void StartWindowDrag(Window *w) static void StartWindowSizing(Window *w, bool to_left) { w->flags4 |= to_left ? WF_SIZING_LEFT : WF_SIZING_RIGHT; + w->flags4 &= ~WF_CENTERED; _dragging_window = true; _drag_delta.x = _cursor.pos.x; @@ -2578,13 +2580,6 @@ void RelocateAllWindows(int neww, int newh) left = PositionMainToolbar(w); // changes toolbar orientation break; - case WC_SELECT_GAME: - case WC_GAME_OPTIONS: - case WC_NETWORK_WINDOW: - top = (newh - w->height) >> 1; - left = (neww - w->width) >> 1; - break; - case WC_NEWS_WINDOW: top = newh - w->height; left = (neww - w->width) >> 1; @@ -2607,6 +2602,12 @@ void RelocateAllWindows(int neww, int newh) continue; default: { + if (w->flags4 & WF_CENTERED) { + top = (newh - w->height) >> 1; + left = (neww - w->width) >> 1; + break; + } + left = w->left; if (left + (w->width >> 1) >= neww) left = neww - w->width; if (left < 0) left = 0; diff --git a/src/window_gui.h b/src/window_gui.h index 147811271..4e64cc5df 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -341,7 +341,7 @@ struct Window : ZeroedMemoryAllocator { }; protected: - void InitializeData(WindowClass cls, int window_number, uint32 desc_flags); + void InitializeData(const WindowDesc *desc, WindowNumber window_number); void InitializePositionSize(int x, int y, int min_width, int min_height); void FindWindowPlacementAndResize(int def_width, int def_height); @@ -863,6 +863,8 @@ enum WindowFlags { WF_WHITE_BORDER_ONE = 1 << 13, WF_WHITE_BORDER_MASK = 1 << 14 | WF_WHITE_BORDER_ONE, + + WF_CENTERED = 1 << 15, ///< Window is centered and shall stay centered after ReInit }; Window *BringWindowToFrontById(WindowClass cls, WindowNumber number); |