summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-11-08 15:22:04 +0000
committeralberth <alberth@openttd.org>2009-11-08 15:22:04 +0000
commita2e6035f16ac7486b16b10f800bd0d93ec7329e1 (patch)
tree9fd30e5237093210115df5c43a8f5fba0c5bc104
parent4c06a9e549b938c6cea3d0fa6283447320ac89a3 (diff)
downloadopenttd-a2e6035f16ac7486b16b10f800bd0d93ec7329e1.tar.xz
(svn r18013) -Codechange: Add possibility to change window size during ReInit().
-rw-r--r--src/window.cpp14
-rw-r--r--src/window_gui.h2
2 files changed, 10 insertions, 6 deletions
diff --git a/src/window.cpp b/src/window.cpp
index e39e6cbe0..a336d6585 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -599,8 +599,12 @@ void Window::SetDirty() const
SetDirtyBlocks(this->left, this->top, this->left + this->width, this->top + this->height);
}
-/** Re-initialize a window. */
-void Window::ReInit()
+/** Re-initialize a window, and optionally change its size.
+ * @param rx Horizontal resize of the window.
+ * @param ry Vertical resize of the window.
+ * @note For just resizing the window, use #ResizeWindow instead.
+ */
+void Window::ReInit(int rx, int ry)
{
if (this->nested_root == NULL) return; // Only nested widget windows can re-initialize.
@@ -620,9 +624,9 @@ void Window::ReInit()
this->resize.step_width = this->nested_root->resize_x;
this->resize.step_height = this->nested_root->resize_y;
- /* Resize as close to the original size as possible. */
- window_width = max(window_width, this->width);
- window_height = max(window_height, this->height);
+ /* Resize as close to the original size + requested resize as possible. */
+ window_width = max(window_width + rx, this->width);
+ window_height = max(window_height + ry, this->height);
int dx = (this->resize.step_width == 0) ? 0 : window_width - this->width;
int dy = (this->resize.step_height == 0) ? 0 : window_height - this->height;
/* dx and dy has to go by step.. calculate it.
diff --git a/src/window_gui.h b/src/window_gui.h
index a0b9bb824..ab6bee1da 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -598,7 +598,7 @@ public:
void DeleteChildWindows(WindowClass wc = WC_INVALID) const;
void SetDirty() const;
- void ReInit();
+ void ReInit(int rx = 0, int ry = 0);
/**
* Mark this window's data as invalid (in need of re-computing)