summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/textpreview.cpp10
-rw-r--r--src/gui/widgets/textpreview.h11
2 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index e34bb5cb..5408eebe 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -35,6 +35,7 @@ float TextPreview::mAlpha = config.getValue("guialpha", 0.8);
TextPreview::TextPreview(const std::string* text)
{
mText = text;
+ mTextAlpha = false;
mFont = gui->getFont();
mTextColor = &guiPalette->getColor(Palette::TEXT);
mTextBGColor = NULL;
@@ -47,6 +48,11 @@ void TextPreview::draw(gcn::Graphics* graphics)
if (config.getValue("guialpha", 0.8) != mAlpha)
mAlpha = config.getValue("guialpha", 0.8);
+ int alpha = (int) (mAlpha * 255.0f);
+
+ if (!mTextAlpha)
+ alpha = 255;
+
if (mOpaque)
{
graphics->setColor(gcn::Color((int) mBGColor->r,
@@ -69,5 +75,7 @@ void TextPreview::draw(gcn::Graphics* graphics)
}
TextRenderer::renderText(graphics, *mText, 2, 2, gcn::Graphics::LEFT,
- mTextColor, mFont, mOutline, mShadow);
+ gcn::Color(mTextColor->r, mTextColor->g,
+ mTextColor->b, alpha),
+ mFont, mOutline, mShadow, alpha);
}
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
index a73eb638..8e116262 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -45,6 +45,16 @@ class TextPreview : public gcn::Widget
}
/**
+ * Sets the text to use the set alpha value.
+ *
+ * @param alpha whether to use alpha values for the text or not
+ */
+ inline void useTextAlpha(bool alpha)
+ {
+ mTextAlpha = alpha;
+ }
+
+ /**
* Sets the color the text background is drawn in. This is only the
* rectangle directly behind the text, not to full widget.
*
@@ -123,6 +133,7 @@ class TextPreview : public gcn::Widget
const gcn::Color* mBGColor;
const gcn::Color* mTextBGColor;
static float mAlpha;
+ bool mTextAlpha;
bool mOpaque;
bool mShadow;
bool mOutline;