summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-22 13:58:57 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-22 13:58:57 +0300
commit0d09f7657fd66febe1866a38e19a29f5eda1cdbe (patch)
treecdf8ec499b99e4d972e447f00a7dc8a4dcf1bbe8 /src
parenta0248fbd9a859ac66771565e6d0cefb61179e833 (diff)
downloadmanaplus-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.tar.gz
manaplus-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.tar.bz2
manaplus-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.tar.xz
manaplus-0d09f7657fd66febe1866a38e19a29f5eda1cdbe.zip
Improve spellpopup.
Diffstat (limited to 'src')
-rw-r--r--src/gui/spellpopup.cpp25
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);