From 60add2c149c9c61bfbede5ae92cfe216927aca8a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Dec 2012 14:42:15 +0300 Subject: Improve a bit draw speed in other controls. --- src/gui/widgets/label.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/gui/widgets/label.cpp') 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") } -- cgit v1.2.3-70-g09d2