Changeset - r7342:9fce1b52a36a
[Not reviewed]
master
0 1 0
rubidium - 17 years ago 2007-07-27 19:09:31
rubidium@openttd.org
(svn r10705) -Fix (r10704): some windows were not correctly initialized as they resized the window themselves and that should be interfered by making sure the window is resized in the right "step" size.
-Fix (r10704): call the WE_RESIZE when resizing during initialization of the windows.
1 file changed with 9 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/window.cpp
Show inline comments
 
@@ -659,24 +659,33 @@ static Window *LocalAllocateWindow(
 
	/* Try to make windows smaller when our window is too small */
 
	if (min_width != def_width || min_height != def_height) {
 
		int enlarge_x = max(min(def_width  - min_width,  _screen.width  - min_width),  0);
 
		int enlarge_y = max(min(def_height - min_height, _screen.height - min_height), 0);
 

	
 
		/* X and Y has to go by step.. calculate it.
 
		 * The cast to int is necessary else x/y are implicitly casted to
 
		 * unsigned int, which won't work. */
 
		if (w->resize.step_width  > 1) enlarge_x -= enlarge_x % (int)w->resize.step_width;
 
		if (w->resize.step_height > 1) enlarge_y -= enlarge_y % (int)w->resize.step_height;
 

	
 
		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 < 0) w->left = 0;
 
		if (w->top  < 0) w->top  = 0;
 
	}
 

	
 
	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
 
@@ -1084,30 +1093,24 @@ static bool HandleMouseOver()
 
/** Update all the widgets of a window based on their resize flags
 
 * Both the areas of the old window and the new sized window are set dirty
 
 * ensuring proper redrawal.
 
 * @param w Window to resize
 
 * @param x delta x-size of changed window (positive if larger, etc.)
 
 * @param y delta y-size of changed window */
 
void ResizeWindow(Window *w, int x, int y)
 
{
 
	Widget *wi;
 
	bool resize_height = false;
 
	bool resize_width = false;
 

	
 
	/* X and Y has to go by step.. calculate it.
 
	 * The cast to int is necessary else x/y are implicitly casted to
 
	 * unsigned int, which won't work. */
 
	if (w->resize.step_width  > 1) x -= x % (int)w->resize.step_width;
 
	if (w->resize.step_height > 1) y -= y % (int)w->resize.step_height;
 

	
 
	if (x == 0 && y == 0) return;
 

	
 
	SetWindowDirty(w);
 
	for (wi = w->widget; wi->type != WWT_LAST; wi++) {
 
		/* Isolate the resizing flags */
 
		byte rsizeflag = GB(wi->display_flags, 0, 4);
 

	
 
		if (rsizeflag == RESIZE_NONE) continue;
 

	
 
		/* Resize the widget based on its resize-flag */
 
		if (rsizeflag & RESIZE_LEFT) {
 
			wi->left += x;
0 comments (0 inline, 0 general)