summaryrefslogtreecommitdiff
path: root/src/gui/widgets/textpreview.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-13 00:47:50 -0600
committerIra Rice <irarice@gmail.com>2009-03-13 00:47:50 -0600
commit011133ef09dd4340c7649100cea170e2595b6b2f (patch)
treee740199aa0f4edc3cba38d4b61c2239110e63e7d /src/gui/widgets/textpreview.cpp
parent9df0ea3ab0faeb3e9fce71dccb76624d7737798f (diff)
downloadmana-client-011133ef09dd4340c7649100cea170e2595b6b2f.tar.gz
mana-client-011133ef09dd4340c7649100cea170e2595b6b2f.tar.bz2
mana-client-011133ef09dd4340c7649100cea170e2595b6b2f.tar.xz
mana-client-011133ef09dd4340c7649100cea170e2595b6b2f.zip
Made the TextPreview widget respect alpha values.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/widgets/textpreview.cpp')
-rw-r--r--src/gui/widgets/textpreview.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index b13d12e4..e34bb5cb 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -28,6 +28,10 @@
#include "../textrenderer.h"
#include "../truetypefont.h"
+#include "../../configuration.h"
+
+float TextPreview::mAlpha = config.getValue("guialpha", 0.8);
+
TextPreview::TextPreview(const std::string* text)
{
mText = text;
@@ -40,22 +44,28 @@ TextPreview::TextPreview(const std::string* text)
void TextPreview::draw(gcn::Graphics* graphics)
{
+ if (config.getValue("guialpha", 0.8) != mAlpha)
+ mAlpha = config.getValue("guialpha", 0.8);
+
if (mOpaque)
{
- graphics->setColor(*mBGColor);
+ graphics->setColor(gcn::Color((int) mBGColor->r,
+ (int) mBGColor->g,
+ (int) mBGColor->b,
+ (int)(mAlpha * 255.0f)));
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
- const std::string ttf = "TrueTypeFont";
-
- if (mTextBGColor && typeid(*mFont).name() == ttf)
+ if (mTextBGColor && typeid(*mFont) == typeid(TrueTypeFont))
{
TrueTypeFont *font = static_cast<TrueTypeFont*>(mFont);
- graphics->setColor(*mTextBGColor);
int x = font->getWidth(*mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0);
int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0);
- if (mOpaque)
- graphics->fillRectangle(gcn::Rectangle(1, 1, x, y));
+ graphics->setColor(gcn::Color((int) mTextBGColor->r,
+ (int) mTextBGColor->g,
+ (int) mTextBGColor->b,
+ (int)(mAlpha * 255.0f)));
+ graphics->fillRectangle(gcn::Rectangle(1, 1, x, y));
}
TextRenderer::renderText(graphics, *mText, 2, 2, gcn::Graphics::LEFT,