mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
7563432119
commit
68c1213efa
|
@ -835,22 +835,22 @@ static void BringWindowToFront(Window *w)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the data (except the position and initial size) of a new Window.
|
* 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 window_number Number being assigned to the new window
|
||||||
* @param desc_flags Window flags. @see WindowDefaultFlag
|
|
||||||
* @return Window pointer of the newly created window
|
* @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.
|
* @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.
|
* 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 */
|
/* 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
|
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->owner = INVALID_OWNER;
|
||||||
this->nested_focus = NULL;
|
this->nested_focus = NULL;
|
||||||
this->window_number = window_number;
|
this->window_number = window_number;
|
||||||
this->desc_flags = desc_flags;
|
this->desc_flags = desc->flags;
|
||||||
|
|
||||||
this->OnInit();
|
this->OnInit();
|
||||||
/* Initialize nested widget tree. */
|
/* 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)
|
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);
|
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->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y);
|
||||||
this->FindWindowPlacementAndResize(desc->default_width, desc->default_height);
|
this->FindWindowPlacementAndResize(desc->default_width, desc->default_height);
|
||||||
|
@ -1702,6 +1702,7 @@ static bool HandleWindowDragging()
|
||||||
static void StartWindowDrag(Window *w)
|
static void StartWindowDrag(Window *w)
|
||||||
{
|
{
|
||||||
w->flags4 |= WF_DRAGGING;
|
w->flags4 |= WF_DRAGGING;
|
||||||
|
w->flags4 &= ~WF_CENTERED;
|
||||||
_dragging_window = true;
|
_dragging_window = true;
|
||||||
|
|
||||||
_drag_delta.x = w->left - _cursor.pos.x;
|
_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)
|
static void StartWindowSizing(Window *w, bool to_left)
|
||||||
{
|
{
|
||||||
w->flags4 |= to_left ? WF_SIZING_LEFT : WF_SIZING_RIGHT;
|
w->flags4 |= to_left ? WF_SIZING_LEFT : WF_SIZING_RIGHT;
|
||||||
|
w->flags4 &= ~WF_CENTERED;
|
||||||
_dragging_window = true;
|
_dragging_window = true;
|
||||||
|
|
||||||
_drag_delta.x = _cursor.pos.x;
|
_drag_delta.x = _cursor.pos.x;
|
||||||
|
@ -2578,13 +2580,6 @@ void RelocateAllWindows(int neww, int newh)
|
||||||
left = PositionMainToolbar(w); // changes toolbar orientation
|
left = PositionMainToolbar(w); // changes toolbar orientation
|
||||||
break;
|
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:
|
case WC_NEWS_WINDOW:
|
||||||
top = newh - w->height;
|
top = newh - w->height;
|
||||||
left = (neww - w->width) >> 1;
|
left = (neww - w->width) >> 1;
|
||||||
|
@ -2607,6 +2602,12 @@ void RelocateAllWindows(int neww, int newh)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
if (w->flags4 & WF_CENTERED) {
|
||||||
|
top = (newh - w->height) >> 1;
|
||||||
|
left = (neww - w->width) >> 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
left = w->left;
|
left = w->left;
|
||||||
if (left + (w->width >> 1) >= neww) left = neww - w->width;
|
if (left + (w->width >> 1) >= neww) left = neww - w->width;
|
||||||
if (left < 0) left = 0;
|
if (left < 0) left = 0;
|
||||||
|
|
|
@ -341,7 +341,7 @@ struct Window : ZeroedMemoryAllocator {
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
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 InitializePositionSize(int x, int y, int min_width, int min_height);
|
||||||
void FindWindowPlacementAndResize(int def_width, int def_height);
|
void FindWindowPlacementAndResize(int def_width, int def_height);
|
||||||
|
|
||||||
|
@ -863,6 +863,8 @@ enum WindowFlags {
|
||||||
|
|
||||||
WF_WHITE_BORDER_ONE = 1 << 13,
|
WF_WHITE_BORDER_ONE = 1 << 13,
|
||||||
WF_WHITE_BORDER_MASK = 1 << 14 | WF_WHITE_BORDER_ONE,
|
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);
|
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
|
||||||
|
|
Loading…
Reference in New Issue