Changeset - r15107:67b8f6adbfa8
[Not reviewed]
master
0 2 0
frosch - 14 years ago 2010-05-01 15:32:17
frosch@openttd.org
(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.
2 files changed with 17 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/window.cpp
Show inline comments
 
@@ -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 Wind
 
 */
 
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 ne
 
				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 ne
 
				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;
src/window_gui.h
Show inline comments
 
@@ -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);
0 comments (0 inline, 0 general)