diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-18 13:28:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-18 13:28:50 +0300 |
commit | c9f1d14eee45827832e1297d88ca62b0f01003ac (patch) | |
tree | d486fddf6d245e428629238e9620f655ef07f7cd /src | |
parent | 4a137325c501fe143197f2fcb97b0ad63ba4bbab (diff) | |
download | manaplus-c9f1d14eee45827832e1297d88ca62b0f01003ac.tar.gz manaplus-c9f1d14eee45827832e1297d88ca62b0f01003ac.tar.bz2 manaplus-c9f1d14eee45827832e1297d88ca62b0f01003ac.tar.xz manaplus-c9f1d14eee45827832e1297d88ca62b0f01003ac.zip |
improve textpreview.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/textpreview.cpp | 17 | ||||
-rw-r--r-- | src/gui/widgets/textpreview.h | 18 |
2 files changed, 19 insertions, 16 deletions
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*>(graphics); - const int alpha = mTextAlpha ? static_cast<int>(mAlpha * 255.0f) : 255; + const int intAlpha = static_cast<int>(mAlpha * 255.0f); + const int alpha = mTextAlpha ? intAlpha : 255; if (mOpaque) { @@ -94,7 +96,8 @@ void TextPreview::draw(gcn::Graphics* graphics) static_cast<int>(mBGColor->g), static_cast<int>(mBGColor->b), static_cast<int>(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<int>(mTextBGColor->r), static_cast<int>(mTextBGColor->g), static_cast<int>(mTextBGColor->b), - static_cast<int>(mAlpha * 255.0f))); + intAlpha)); g->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y)); } } diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 59f14bb9a..675d0fd73 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -55,7 +55,7 @@ class TextPreview final : public gcn::Widget, * * @param alpha whether to use alpha values for the text or not */ - inline void useTextAlpha(bool alpha) + inline void useTextAlpha(const bool alpha) { mTextAlpha = alpha; } /** @@ -80,7 +80,7 @@ class TextPreview final : public gcn::Widget, * * @param font the font to use. */ - inline void setFont(gcn::Font *font) + inline void setFont(gcn::Font *const font) { mFont = font; } /** @@ -88,7 +88,7 @@ class TextPreview final : public gcn::Widget, * * @param shadow true, if a shadow is wanted, false else */ - inline void setShadow(bool shadow) + inline void setShadow(const bool shadow) { mShadow = shadow; } /** @@ -96,7 +96,7 @@ class TextPreview final : public gcn::Widget, * * @param outline true, if an outline is wanted, false else */ - inline void setOutline(bool outline) + inline void setOutline(const bool outline) { mOutline = outline; } /** @@ -112,7 +112,7 @@ class TextPreview final : public gcn::Widget, * * @param opaque Whether the widget should be opaque or not */ - void setOpaque(bool opaque) + void setOpaque(const bool opaque) { mOpaque = opaque; } /** @@ -131,14 +131,14 @@ class TextPreview final : public gcn::Widget, const gcn::Color *mTextColor2; const gcn::Color *mBGColor; const gcn::Color *mTextBGColor; - bool mTextAlpha; - bool mOpaque; - bool mShadow; - bool mOutline; int mPadding; static int instances; static float mAlpha; static Skin *mSkin; + bool mTextAlpha; + bool mOpaque; + bool mShadow; + bool mOutline; }; #endif // GUI_WIDGETS_TEXTPREVIEW_H |