diff options
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(); } |