From d3ac12d94f6ddb25866e10856ec47919a4b6d7a6 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 16:25:16 -0700 Subject: Fixed up minimap resizing code so that the minimum width is always long enough to contain the map's name. Also fixed an unnoticed logic flip that was done unintentionally. This class now manages to work perfectly when the config file has no previous dimensional influences, but still won't resize properly without removing the ability to resize or getting rid of those stored configs. TODO: Find out why loading window configuration for the default minimum width or height overrides the Minimap's supplied dimensions it wants. Signed-off-by: Ira Rice --- src/gui/minimap.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 7802b583..d68faa56 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -71,19 +71,25 @@ void Minimap::setMapImage(Image *img) setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth); setMinHeight(mapHeight); - setMaxWidth(mMapImage->getWidth() + offsetX); + setMaxWidth(mMapImage->getWidth() > titleWidth ? + mMapImage->getWidth() + offsetX : titleWidth); setMaxHeight(mMapImage->getHeight() + offsetY); mMapImage->setAlpha(config.getValue("guialpha", 0.8)); - // Set content size to be within the minimum and maximum boundaries - setWidth(getMinWidth() < getWidth() ? getWidth() : getMinWidth()); - if (getMaxWidth() > getWidth()) + // Make sure the window is within the minimum and maximum boundaries + // TODO: Shouldn't this be happening automatically within the Window + // class? + if (getMinWidth() > getWidth()) + setWidth(getMinWidth()); + else if (getMaxWidth() < getWidth()) setWidth(getMaxWidth()); - setHeight(getMinHeight() < getHeight() ? getHeight() : getMinHeight()); - if (getMaxHeight() > getHeight()) + if (getMinHeight() > getHeight()) + setHeight(getMinHeight()); + else if (getMaxHeight() < getHeight()) setHeight(getMaxHeight()); + setContentSize(getWidth() - offsetX, getHeight() - offsetY); setDefaultSize(getX(), getY(), getWidth(), getHeight()); resetToDefaultSize(); -- cgit v1.2.3-70-g09d2