diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-27 20:23:48 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-27 20:23:48 +0000 |
commit | 97bbe57e21a28544646da087e2a522390bf2ce5c (patch) | |
tree | a1899345f3b3928b3b0747b2429a45d08f79ae59 /src/gui/window.cpp | |
parent | ee15a808a1e0d36167f80d9f96147103ba5583de (diff) | |
download | mana-97bbe57e21a28544646da087e2a522390bf2ce5c.tar.gz mana-97bbe57e21a28544646da087e2a522390bf2ce5c.tar.bz2 mana-97bbe57e21a28544646da087e2a522390bf2ce5c.tar.xz mana-97bbe57e21a28544646da087e2a522390bf2ce5c.zip |
Improved layout handler to support trees of nested arrays. Needed for converting and fixing the trade window.
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r-- | src/gui/window.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 68b79367..7629e2e7 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -22,6 +22,7 @@ */ #include <algorithm> +#include <cassert> #include <climits> #include <guichan/exception.hpp> @@ -234,9 +235,8 @@ void Window::setSize(int width, int height) if (mLayout) { - mLayout->setWidth(width - 2 * getPadding()); - mLayout->setHeight(height - getPadding() - getTitleBarHeight()); - int w, h; + int w = width - 2 * getPadding(), + h = height - getPadding() - getTitleBarHeight(); mLayout->reflow(w, h); } @@ -520,7 +520,6 @@ void Window::mouseDragged(gcn::MouseEvent &event) // Set the new window and content dimensions setDimension(newDim); - updateContentSize(); } } @@ -555,7 +554,6 @@ void Window::resetToDefaultSize() { setPosition(mDefaultX, mDefaultY); setContentSize(mDefaultWidth, mDefaultHeight); - updateContentSize(); } int Window::getResizeHandles(gcn::MouseEvent &event) @@ -611,28 +609,22 @@ Layout &Window::getLayout() return *mLayout; } -void Window::forgetLayout() +LayoutCell &Window::place(int x, int y, gcn::Widget *wg, int w, int h) { - delete mLayout; - mLayout = 0; + add(wg); + return getLayout().place(wg, x, y, w, h); } -Cell &Window::place(int x, int y, gcn::Widget *wg, int w, int h) +ContainerPlacer Window::getPlacer(int x, int y) { - add(wg); - return getLayout().place(wg, x, y, w, h); + return ContainerPlacer(this, &getLayout().at(x, y)); } -void Window::reflowLayout() +void Window::reflowLayout(int w, int h) { - if (!mLayout) return; - int w, h; + assert(mLayout); mLayout->reflow(w, h); - w += mLayout->getX(); - h += mLayout->getY(); - Layout *tmp = mLayout; - // Hide it so that the incoming resize does not reflow the layout again. + delete mLayout; mLayout = NULL; setContentSize(w, h); - mLayout = tmp; } |