summaryrefslogtreecommitdiff
path: root/src/gui/widgets/popup.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-22 00:02:09 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-22 00:02:09 -0700
commit4406b2fd90a5d4656bc923bf5c751e4c5250a0d2 (patch)
treebf25813b8711fb1dd51a77104a63a9c9647a60df /src/gui/widgets/popup.cpp
parent7c925545419eeda0b0b26b290a9ec0412960fbd8 (diff)
downloadmana-client-4406b2fd90a5d4656bc923bf5c751e4c5250a0d2.tar.gz
mana-client-4406b2fd90a5d4656bc923bf5c751e4c5250a0d2.tar.bz2
mana-client-4406b2fd90a5d4656bc923bf5c751e4c5250a0d2.tar.xz
mana-client-4406b2fd90a5d4656bc923bf5c751e4c5250a0d2.zip
Cleanup some popup-related code and make sure BeingPopup is included
Diffstat (limited to 'src/gui/widgets/popup.cpp')
-rw-r--r--src/gui/widgets/popup.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 6f551317..391b0eed 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -170,3 +170,19 @@ void Popup::scheduleDelete()
windowContainer->scheduleDelete(this);
}
+void Popup::position(int x, int 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();
+}