diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-22 13:58:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-22 13:58:57 +0300 |
commit | 0d09f7657fd66febe1866a38e19a29f5eda1cdbe (patch) | |
tree | cdf8ec499b99e4d972e447f00a7dc8a4dcf1bbe8 /src | |
parent | a0248fbd9a859ac66771565e6d0cefb61179e833 (diff) | |
download | manaverse-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.tar.gz manaverse-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.tar.bz2 manaverse-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.tar.xz manaverse-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.zip |
Improve spellpopup.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/spellpopup.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index 96c82b7a9..f80282959 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -77,12 +77,12 @@ void SpellPopup::setItem(const TextCommand *const spell) minWidth = mItemComment->getWidth(); mItemName->setPosition(0, 0); - mItemComment->setPosition(0, mItemName->getHeight()); - - if (mItemComment->getCaption() != "") - setContentSize(minWidth, 2 * getFont()->getHeight()); + const int fontHeight = mItemName->getHeight(); + mItemComment->setPosition(0, fontHeight); + if (!mItemComment->getCaption().empty()) + setContentSize(minWidth, 2 * fontHeight); else - setContentSize(minWidth, getFont()->getHeight()); + setContentSize(minWidth, fontHeight); } void SpellPopup::view(const int x, const int y) @@ -92,17 +92,20 @@ void SpellPopup::view(const int x, const int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > mainGraphics->mWidth) + const gcn::Rectangle &rect = mDimension; + const int w = rect.width; + const int h = rect.height; + if (posX + w > mainGraphics->mWidth) { - if (mainGraphics->mWidth > getWidth()) - posX = mainGraphics->mWidth - getWidth(); + if (mainGraphics->mWidth > w) + posX = mainGraphics->mWidth - w; else posX = 0; } - if (posY + getHeight() > mainGraphics->mHeight) + if (posY + h > mainGraphics->mHeight) { - if (y > getHeight() + distance) - posY = y - getHeight() - distance; + if (y > h + distance) + posY = y - h - distance; } setPosition(posX, posY); |