comparison src/window.cpp @ 14951:9437b4726bac draft

(svn r19558) -Fix [FS#3730]: Window::OnResize() was not always called while resizing a window.
author alberth <alberth@openttd.org>
date Sun, 04 Apr 2010 11:21:56 +0000
parents 4e80238218ca
children ed91b4c7075f
comparison
equal deleted inserted replaced
14950:0fb1f46923ad 14951:9437b4726bac
546 * The cast to int is necessary else dx/dy are implicitly casted to unsigned int, which won't work. */ 546 * The cast to int is necessary else dx/dy are implicitly casted to unsigned int, which won't work. */
547 if (this->resize.step_width > 1) dx -= dx % (int)this->resize.step_width; 547 if (this->resize.step_width > 1) dx -= dx % (int)this->resize.step_width;
548 if (this->resize.step_height > 1) dy -= dy % (int)this->resize.step_height; 548 if (this->resize.step_height > 1) dy -= dy % (int)this->resize.step_height;
549 549
550 ResizeWindow(this, dx, dy); 550 ResizeWindow(this, dx, dy);
551 this->OnResize(); 551 /* ResizeWindow() does this->SetDirty() already, no need to do it again here. */
552 this->SetDirty();
553 } 552 }
554 553
555 /** Set the shaded state of the window to \a make_shaded. 554 /** Set the shaded state of the window to \a make_shaded.
556 * @param make_shaded If \c true, shade the window (roll up until just the title bar is visible), else unshade/unroll the window to its original size. 555 * @param make_shaded If \c true, shade the window (roll up until just the title bar is visible), else unshade/unroll the window to its original size.
557 * @note The method uses #Window::ReInit(), thus after the call, the whole window should be considered changed. 556 * @note The method uses #Window::ReInit(), thus after the call, the whole window should be considered changed.
960 * unsigned int, which won't work. */ 959 * unsigned int, which won't work. */
961 if (this->resize.step_width > 1) enlarge_x -= enlarge_x % (int)this->resize.step_width; 960 if (this->resize.step_width > 1) enlarge_x -= enlarge_x % (int)this->resize.step_width;
962 if (this->resize.step_height > 1) enlarge_y -= enlarge_y % (int)this->resize.step_height; 961 if (this->resize.step_height > 1) enlarge_y -= enlarge_y % (int)this->resize.step_height;
963 962
964 ResizeWindow(this, enlarge_x, enlarge_y); 963 ResizeWindow(this, enlarge_x, enlarge_y);
965 } 964 /* ResizeWindow() calls this->OnResize(). */
966 965 } else {
967 /* Always call OnResize; that way the scrollbars and matrices get initialized */ 966 /* Always call OnResize; that way the scrollbars and matrices get initialized. */
968 this->OnResize(); 967 this->OnResize();
968 }
969 969
970 int nx = this->left; 970 int nx = this->left;
971 int ny = this->top; 971 int ny = this->top;
972 972
973 if (nx + this->width > _screen.width) nx -= (nx + this->width - _screen.width); 973 if (nx + this->width > _screen.width) nx -= (nx + this->width - _screen.width);
1423 assert(w->nested_root->resize_y == 0 || new_yinc % w->nested_root->resize_y == 0); 1423 assert(w->nested_root->resize_y == 0 || new_yinc % w->nested_root->resize_y == 0);
1424 1424
1425 w->nested_root->AssignSizePosition(ST_RESIZE, 0, 0, w->nested_root->smallest_x + new_xinc, w->nested_root->smallest_y + new_yinc, _dynlang.text_dir == TD_RTL); 1425 w->nested_root->AssignSizePosition(ST_RESIZE, 0, 0, w->nested_root->smallest_x + new_xinc, w->nested_root->smallest_y + new_yinc, _dynlang.text_dir == TD_RTL);
1426 w->width = w->nested_root->current_x; 1426 w->width = w->nested_root->current_x;
1427 w->height = w->nested_root->current_y; 1427 w->height = w->nested_root->current_y;
1428 w->OnResize();
1428 w->SetDirty(); 1429 w->SetDirty();
1429 } 1430 }
1430 1431
1431 /** Return the top of the main view available for general use. 1432 /** Return the top of the main view available for general use.
1432 * @return Uppermost vertical coordinate available. 1433 * @return Uppermost vertical coordinate available.
1677 _drag_delta.x += x; 1678 _drag_delta.x += x;
1678 } 1679 }
1679 1680
1680 /* ResizeWindow sets both pre- and after-size to dirty for redrawal */ 1681 /* ResizeWindow sets both pre- and after-size to dirty for redrawal */
1681 ResizeWindow(w, x, y); 1682 ResizeWindow(w, x, y);
1682 w->OnResize();
1683 return false; 1683 return false;
1684 } 1684 }
1685 } 1685 }
1686 1686
1687 _dragging_window = false; 1687 _dragging_window = false;
2546 2546
2547 /* XXX - this probably needs something more sane. For example specying 2547 /* XXX - this probably needs something more sane. For example specying
2548 * in a 'backup'-desc that the window should always be centred. */ 2548 * in a 'backup'-desc that the window should always be centred. */
2549 switch (w->window_class) { 2549 switch (w->window_class) {
2550 case WC_MAIN_TOOLBAR: 2550 case WC_MAIN_TOOLBAR:
2551 if (neww - w->width != 0) { 2551 if (neww - w->width != 0) ResizeWindow(w, min(neww, 640) - w->width, 0);
2552 ResizeWindow(w, min(neww, 640) - w->width, 0);
2553 w->OnResize();
2554 }
2555 2552
2556 top = w->top; 2553 top = w->top;
2557 left = PositionMainToolbar(w); // changes toolbar orientation 2554 left = PositionMainToolbar(w); // changes toolbar orientation
2558 break; 2555 break;
2559 2556