diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-09-19 03:02:05 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-09-19 03:08:53 +0300 |
commit | de33cd794955254a166d932e91de0b72d9dc20fd (patch) | |
tree | 3d85c63202e148e4e4dbde2fe412d49f740758b9 /src | |
parent | 9847915fafee7fc3872aafb4395543b12174a1ae (diff) | |
download | plus-de33cd794955254a166d932e91de0b72d9dc20fd.tar.gz plus-de33cd794955254a166d932e91de0b72d9dc20fd.tar.bz2 plus-de33cd794955254a166d932e91de0b72d9dc20fd.tar.xz plus-de33cd794955254a166d932e91de0b72d9dc20fd.zip |
Dont resize minimap window if map name very big.
Also show map name in minimap tooltip.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/minimap.cpp | 26 | ||||
-rw-r--r-- | src/gui/minimap.h | 6 |
2 files changed, 27 insertions, 5 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index d928e6f8c..5ed18f84e 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -30,6 +30,7 @@ #include "gui/setup.h" #include "gui/viewport.h" +#include "gui/textpopup.h" #include "resources/image.h" #include "resources/imagehelper.h" @@ -50,7 +51,8 @@ Minimap::Minimap(): mHeightProportion(0.5), mCustomMapImage(false), mMapOriginX(0), - mMapOriginY(0) + mMapOriginY(0), + mTextPopup(new TextPopup) { setWindowName("Minimap"); mShow = config.getValueBool(getWindowName() + "Show", true); @@ -82,6 +84,8 @@ Minimap::~Minimap() mMapImage->decRef(); mMapImage = nullptr; } + delete mTextPopup; + mTextPopup = nullptr; } void Minimap::setMap(const Map *const map) @@ -164,13 +168,12 @@ void Minimap::setMap(const Map *const map) { const int offsetX = 2 * getPadding(); const int offsetY = getTitleBarHeight() + getPadding(); - const int titleWidth = getFont()->getWidth(getCaption()) + 15; const int mapWidth = mMapImage->mBounds.w < 100 ? mMapImage->mBounds.w + offsetX : 100; const int mapHeight = mMapImage->mBounds.h < 100 ? mMapImage->mBounds.h + offsetY : 100; - setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth); + setMinWidth(mapWidth); setMinHeight(mapHeight); mWidthProportion = static_cast<float>( @@ -178,8 +181,7 @@ void Minimap::setMap(const Map *const map) mHeightProportion = static_cast<float>( mMapImage->mBounds.h) / static_cast<float>(map->getHeight()); - setMaxWidth(mMapImage->mBounds.w > titleWidth ? - mMapImage->mBounds.w + offsetX : titleWidth); + setMaxWidth(mMapImage->mBounds.w + offsetX); setMaxHeight(mMapImage->mBounds.h + offsetY); setDefaultSize(getX(), getY(), getWidth(), getHeight()); @@ -419,6 +421,20 @@ void Minimap::mouseReleased(gcn::MouseEvent &event) } } +void Minimap::mouseMoved(gcn::MouseEvent &event) +{ + Window::mouseMoved(event); + const int x = event.getX(); + const int y = event.getY(); + mTextPopup->show(x + getX(), y + getY(), mCaption); +} + +void Minimap::mouseExited(gcn::MouseEvent &event) +{ + Window::mouseExited(event); + mTextPopup->hide(); +} + void Minimap::screenToMap(int &x, int &y) { const gcn::Rectangle a = getChildrenArea(); diff --git a/src/gui/minimap.h b/src/gui/minimap.h index 7a6f865f8..ee5a63f6a 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -27,6 +27,7 @@ class Image; class Map; +class TextPopup; /** * Minimap window. Shows a minimap image and the name of the current map. @@ -58,8 +59,12 @@ class Minimap : public Window */ void draw(gcn::Graphics *graphics); + void mouseMoved(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event); + void screenToMap(int &x, int &y); private: @@ -70,6 +75,7 @@ class Minimap : public Window bool mCustomMapImage; int mMapOriginX; int mMapOriginY; + TextPopup *mTextPopup; }; extern Minimap *minimap; |