diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-02 16:47:16 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-02 17:04:04 +0200 |
commit | 0e864eefd0bae4fa861ce1b41a0707bb262665bd (patch) | |
tree | ef80b1af56ef23e778909347cd18d37e0048c176 /src/gui/itempopup.cpp | |
parent | 515a97fe15a81e355e402e32b4978a5c4efa8bb0 (diff) | |
download | mana-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/gui/itempopup.cpp')
-rw-r--r-- | src/gui/itempopup.cpp | 20 |
1 files changed, 12 insertions, 8 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(); } |