summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-02 16:47:16 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-02 17:04:04 +0200
commit0e864eefd0bae4fa861ce1b41a0707bb262665bd (patch)
treeef80b1af56ef23e778909347cd18d37e0048c176 /src
parent515a97fe15a81e355e402e32b4978a5c4efa8bb0 (diff)
downloadmana-0e864eefd0bae4fa861ce1b41a0707bb262665bd.tar.gz
mana-0e864eefd0bae4fa861ce1b41a0707bb262665bd.tar.bz2
mana-0e864eefd0bae4fa861ce1b41a0707bb262665bd.tar.xz
mana-0e864eefd0bae4fa861ce1b41a0707bb262665bd.zip
Attempt to put item popup in a less annoying place
Diffstat (limited to 'src')
-rw-r--r--src/gui/itempopup.cpp20
-rw-r--r--src/gui/itempopup.h2
2 files changed, 13 insertions, 9 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 8d51c765..f2ef2111 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -199,7 +199,7 @@ gcn::Color ItemPopup::getColor(short type)
}
}
-std::string ItemPopup::getItemName()
+std::string ItemPopup::getItemName() const
{
return mItemName->getCaption();
}
@@ -212,13 +212,17 @@ unsigned int ItemPopup::getNumRows()
void ItemPopup::view(int x, int y)
{
- if (graphics->getWidth() < (x + getWidth() + 5))
- x = graphics->getWidth() - getWidth();
- if ((y - getHeight() - 10) < 0)
- y = 0;
- else
- y = y - getHeight() - 10;
- setPosition(x, y);
+ const int distance = 20;
+
+ int posX = std::max(0, x - getWidth() / 2);
+ int posY = y + distance;
+
+ if (posX > graphics->getWidth() - getWidth())
+ posX = graphics->getWidth() - getWidth();
+ if (posY > graphics->getHeight() - getHeight())
+ posY = y - getHeight() - distance;
+
+ setPosition(posX, posY);
setVisible(true);
requestMoveToTop();
}
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index 37f6f81b..816e7ab2 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -55,7 +55,7 @@ class ItemPopup : public Popup
/**
* Gets the name of the currently stored item in this popup.
*/
- std::string getItemName();
+ std::string getItemName() const;
/**
* Updates the colors used within the item popup.