summaryrefslogtreecommitdiff
path: root/src
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
parent9df0ea3ab0faeb3e9fce71dccb76624d7737798f (diff)
downloadmana-011133ef09dd4340c7649100cea170e2595b6b2f.tar.gz
mana-011133ef09dd4340c7649100cea170e2595b6b2f.tar.bz2
mana-011133ef09dd4340c7649100cea170e2595b6b2f.tar.xz
mana-011133ef09dd4340c7649100cea170e2595b6b2f.zip
Made the TextPreview widget respect alpha values.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/setup_colors.cpp3
-rw-r--r--src/gui/widgets/textpreview.cpp24
-rw-r--r--src/gui/widgets/textpreview.h1
3 files changed, 20 insertions, 8 deletions
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index f0f7a529..038b21c6 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -180,6 +180,7 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
mTextPreview->setTextColor(
&guiPalette->getColor(Palette::TEXT));
mTextPreview->setTextBGColor(NULL);
+ mTextPreview->setOpaque(false);
mTextPreview->setShadow(true);
mTextPreview->setOutline(true);
@@ -197,6 +198,7 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
case Palette::HIGHLIGHT:
case Palette::SHOP_WARNING:
mTextPreview->setTextBGColor(col);
+ //mTextPreview->setOpaque(true);
mTextPreview->setOutline(false);
mTextPreview->setShadow(false);
mPreview->addRow(rawmsg);
@@ -221,7 +223,6 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
{
msg = "##" + toString(ch) + rawmsg;
}
- //std::cout << msg << std::endl;
mPreview->addRow(msg);
break;
case Palette::PARTICLE:
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,
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
index 7e7e461c..a73eb638 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -122,6 +122,7 @@ class TextPreview : public gcn::Widget
const gcn::Color* mTextColor;
const gcn::Color* mBGColor;
const gcn::Color* mTextBGColor;
+ static float mAlpha;
bool mOpaque;
bool mShadow;
bool mOutline;