Changeset - r7464:e57bd91228a2
[Not reviewed]
master
0 1 0
truelight - 17 years ago 2007-08-23 11:08:59
truelight@openttd.org
(svn r10967) -Fix: in case of moving the window on create (because it doesn't fit in the screen), make sure to move the viewport too if we are an extra viewport (spotted by Maedhros)
1 file changed with 13 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/window.cpp
Show inline comments
 
@@ -684,29 +684,39 @@ static Window *LocalAllocateWindow(
 

	
 
		ResizeWindow(w, enlarge_x, enlarge_y);
 

	
 
		WindowEvent e;
 
		e.event = WE_RESIZE;
 
		e.we.sizing.size.x = w->width;
 
		e.we.sizing.size.y = w->height;
 
		e.we.sizing.diff.x = enlarge_x;
 
		e.we.sizing.diff.y = enlarge_y;
 
		w->wndproc(w, &e);
 
	}
 

	
 
	if (w->left + w->width > _screen.width) w->left -= (w->left + w->width - _screen.width);
 
	int nx = w->left;
 
	int ny = w->top;
 

	
 
	if (nx + w->width > _screen.width) nx -= (nx + w->width - _screen.width);
 

	
 
	const Window *wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
 
	w->top  = max(w->top, (wt == NULL || w == wt || y == 0) ? 0 : wt->height);
 
	w->left = max(w->left, 0);
 
	ny = max(ny, (wt == NULL || w == wt || y == 0) ? 0 : wt->height);
 
	nx = max(nx, 0);
 

	
 
	if (w->viewport != NULL) {
 
		w->viewport->left += nx - w->left;
 
		w->viewport->top  += ny - w->top;
 
	}
 
	w->left = nx;
 
	w->top = ny;
 

	
 
	SetWindowDirty(w);
 

	
 
	return w;
 
}
 

	
 
/**
 
 * Open a new window. If there is no space for a new window, close an open
 
 * window. Try to avoid stickied windows, but if there is no else, close one of
 
 * those as well. Then make sure all created windows are below some always-on-top
 
 * ones. Finally set all variables and call the WE_CREATE event
 
 * @param x offset in pixels from the left of the screen
0 comments (0 inline, 0 general)