From c9f1d14eee45827832e1297d88ca62b0f01003ac Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 18 Jun 2013 13:28:50 +0300 Subject: improve textpreview. --- src/gui/widgets/textpreview.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/gui/widgets/textpreview.cpp') diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index bea96e72a..11de5b553 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -44,16 +44,17 @@ TextPreview::TextPreview(const Widget2 *const widget, mTextColor2(&getThemeColor(Theme::TEXT_OUTLINE)), mBGColor(&getThemeColor(Theme::BACKGROUND)), mTextBGColor(nullptr), + mPadding(0), mTextAlpha(false), mOpaque(false), mShadow(false), - mOutline(false), - mPadding(0) + mOutline(false) { if (instances == 0) { - if (Theme::instance()) - mSkin = Theme::instance()->load("textpreview.xml", ""); + Theme *const theme = Theme::instance(); + if (theme) + mSkin = theme->load("textpreview.xml", ""); } instances++; @@ -86,7 +87,8 @@ void TextPreview::draw(gcn::Graphics* graphics) mAlpha = Client::getGuiAlpha(); Graphics *const g = static_cast(graphics); - const int alpha = mTextAlpha ? static_cast(mAlpha * 255.0f) : 255; + const int intAlpha = static_cast(mAlpha * 255.0f); + const int alpha = mTextAlpha ? intAlpha : 255; if (mOpaque) { @@ -94,7 +96,8 @@ void TextPreview::draw(gcn::Graphics* graphics) static_cast(mBGColor->g), static_cast(mBGColor->b), static_cast(mAlpha * 255.0f))); - g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); + g->fillRectangle(gcn::Rectangle(0, 0, + mDimension.width, mDimension.height)); } if (mTextBGColor) @@ -109,7 +112,7 @@ void TextPreview::draw(gcn::Graphics* graphics) g->setColor(gcn::Color(static_cast(mTextBGColor->r), static_cast(mTextBGColor->g), static_cast(mTextBGColor->b), - static_cast(mAlpha * 255.0f))); + intAlpha)); g->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y)); } } -- cgit v1.2.3-70-g09d2