From 306e345adab33a67e3fc12aad2f7ae7c6c86302c Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Mon, 26 Jan 2009 19:48:33 -0700 Subject: Slight bit of code cleanup, as well as minor fixes to logic. For some reason, the windows will gladly shrink when resizeable, but not grow. This will need to get resolved some time later. Signed-off-by: Ira Rice --- src/gui/minimap.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/gui/minimap.cpp') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index e52a20ac..7802b583 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -33,14 +33,16 @@ #include "../utils/gettext.h" -bool Minimap::mShow = config.getValue("MinimapVisible", true); +bool Minimap::mShow = true; Minimap::Minimap(): - Window(_("Map")), + Window(_("MiniMap")), mMapImage(NULL), mProportion(0.5) { setWindowName(_("MiniMap")); + mShow = config.getValue(getWindowName() + "Visible", true); + setDefaultSize(5, 25, 100, 100); setResizable(true); } @@ -59,8 +61,8 @@ void Minimap::setMapImage(Image *img) if (mMapImage) { - const int offsetX = getPadding() + 4; - const int offsetY = getTitleBarHeight() + 4; + const int offsetX = 2 * getPadding(); + const int offsetY = getTitleBarHeight() + getPadding(); const int titleWidth = getFont()->getWidth(getCaption()) + 15; const int mapWidth = mMapImage->getWidth() < 100 ? mMapImage->getWidth() + offsetX : 100; @@ -73,10 +75,18 @@ void Minimap::setMapImage(Image *img) setMaxHeight(mMapImage->getHeight() + offsetY); mMapImage->setAlpha(config.getValue("guialpha", 0.8)); - setDefaultSize(offsetX, offsetY, getMinWidth() > getWidth() ? - getMinWidth() : getWidth(), - getMaxHeight() < getHeight() ? - getMaxHeight() : getHeight()); + + // Set content size to be within the minimum and maximum boundaries + setWidth(getMinWidth() < getWidth() ? getWidth() : getMinWidth()); + if (getMaxWidth() > getWidth()) + setWidth(getMaxWidth()); + setHeight(getMinHeight() < getHeight() ? getHeight() : getMinHeight()); + if (getMaxHeight() > getHeight()) + setHeight(getMaxHeight()); + + setDefaultSize(getX(), getY(), getWidth(), getHeight()); + resetToDefaultSize(); + loadWindowState(); setVisible(mShow); } @@ -89,7 +99,7 @@ void Minimap::setMapImage(Image *img) void Minimap::toggle() { mShow = !mShow; - config.setValue("MinimapVisible", mShow); + config.setValue(getWindowName() + "Visible", mShow); } void Minimap::draw(gcn::Graphics *graphics) -- cgit v1.2.3-70-g09d2