From 0e864eefd0bae4fa861ce1b41a0707bb262665bd Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 2 Apr 2009 16:47:16 +0200 Subject: Attempt to put item popup in a less annoying place --- src/gui/itempopup.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/gui/itempopup.cpp') 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(); } -- cgit v1.2.3-70-g09d2