summaryrefslogtreecommitdiff
path: root/src/gui/widgets/label.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-27 14:42:15 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-27 23:15:05 +0300
commit60add2c149c9c61bfbede5ae92cfe216927aca8a (patch)
tree9ded097faa108eb07b9ca1c8ce4490882e238a44 /src/gui/widgets/label.cpp
parent2babe1d6491f5231b0e97349ccb198b92bb90ba9 (diff)
downloadmanaplus-60add2c149c9c61bfbede5ae92cfe216927aca8a.tar.gz
manaplus-60add2c149c9c61bfbede5ae92cfe216927aca8a.tar.bz2
manaplus-60add2c149c9c61bfbede5ae92cfe216927aca8a.tar.xz
manaplus-60add2c149c9c61bfbede5ae92cfe216927aca8a.zip
Improve a bit draw speed in other controls.
Diffstat (limited to 'src/gui/widgets/label.cpp')
-rw-r--r--src/gui/widgets/label.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 2d565a571..9efa375d7 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -72,27 +72,28 @@ void Label::draw(gcn::Graphics* graphics)
BLOCK_START("Label::draw")
int textX;
const int textY = getHeight() / 2 - getFont()->getHeight() / 2;
+ gcn::Font *const font = getFont();
+ graphics->setFont(font);
- switch (getAlignment())
+ switch (mAlignment)
{
case Graphics::LEFT:
default:
textX = mPadding;
break;
case Graphics::CENTER:
- textX = getWidth() / 2;
+ textX = (getWidth() - font->getWidth(mCaption)) / 2;
break;
case Graphics::RIGHT:
if (getWidth() > mPadding)
- textX = getWidth() - mPadding;
+ textX = getWidth() - mPadding - font->getWidth(mCaption);
else
textX = 0;
break;
}
- graphics->setFont(getFont());
graphics->setColor(mForegroundColor);
- graphics->drawText(getCaption(), textX, textY, getAlignment());
+ font->drawString(graphics, mCaption, textX, textY);
BLOCK_END("Label::draw")
}