summaryrefslogtreecommitdiff
path: root/src/gui/window.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-10 08:11:48 -0600
committerIra Rice <irarice@gmail.com>2009-03-10 08:11:48 -0600
commit443a10db52e909c4c2a33543795ec8837547e973 (patch)
treefc8fff5e1dbd5e171974919186f6356ffce7b6ff /src/gui/window.cpp
parent03507766fa4ee07491b7ee702093669de6222c9c (diff)
downloadmana-client-443a10db52e909c4c2a33543795ec8837547e973.tar.gz
mana-client-443a10db52e909c4c2a33543795ec8837547e973.tar.bz2
mana-client-443a10db52e909c4c2a33543795ec8837547e973.tar.xz
mana-client-443a10db52e909c4c2a33543795ec8837547e973.zip
Made it so that when windows load previous states, they are never
smaller than the minimum width and height (a check that should have been enforced in the first place), as well as modified the NPC list and text dialogs to remember where they were when they were moved or resized last. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/window.cpp')
-rw-r--r--src/gui/window.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 2b422f86..8faf63a0 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -118,21 +118,8 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std
Window::~Window()
{
logger->log("Window::~Window(\"%s\")", getCaption().c_str());
- const std::string &name = mWindowName;
- // Saving X, Y and Width and Height for resizables in the config
- if (!name.empty())
- {
- config.setValue(name + "WinX", getX());
- config.setValue(name + "WinY", getY());
- config.setValue(name + "Visible", isVisible());
-
- if (mGrip)
- {
- config.setValue(name + "WinWidth", getWidth());
- config.setValue(name + "WinHeight", getHeight());
- }
- }
+ saveWindowState();
delete mLayout;
@@ -478,8 +465,13 @@ void Window::loadWindowState()
if (mGrip)
{
- setSize((int) config.getValue(name + "WinWidth", mDefaultWidth),
- (int) config.getValue(name + "WinHeight", mDefaultHeight));
+ const int width = (int) config.getValue(name + "WinWidth",
+ mDefaultWidth);
+ const int height = (int) config.getValue(name + "WinHeight",
+ mDefaultHeight);
+
+ setSize(width < getMinWidth() ? getMinWidth() : width,
+ height < getMinHeight() ? getMinHeight() : height);
}
else
{
@@ -487,6 +479,23 @@ void Window::loadWindowState()
}
}
+void Window::saveWindowState()
+{
+ // Saving X, Y and Width and Height for resizables in the config
+ if (!mWindowName.empty())
+ {
+ config.setValue(mWindowName + "WinX", getX());
+ config.setValue(mWindowName + "WinY", getY());
+ config.setValue(mWindowName + "Visible", isVisible());
+
+ if (mGrip)
+ {
+ config.setValue(mWindowName + "WinWidth", getWidth());
+ config.setValue(mWindowName + "WinHeight", getHeight());
+ }
+ }
+}
+
void Window::setDefaultSize(int defaultX, int defaultY,
int defaultWidth, int defaultHeight)
{