summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-12 22:07:29 -0600
committerIra Rice <irarice@gmail.com>2009-03-12 22:07:29 -0600
commit14fbd95172a6c41abc8e985680c684c40e9e50a8 (patch)
tree1a8a5c36af80a6a5ebd328cf9fbca025f020b625 /src/gui
parentf0d5e3da15a308fcc962590330e7d8e39e8874b9 (diff)
downloadmana-14fbd95172a6c41abc8e985680c684c40e9e50a8.tar.gz
mana-14fbd95172a6c41abc8e985680c684c40e9e50a8.tar.bz2
mana-14fbd95172a6c41abc8e985680c684c40e9e50a8.tar.xz
mana-14fbd95172a6c41abc8e985680c684c40e9e50a8.zip
Added in option for opacity for the text preview widget, which all of
the other widgets have as well. Also set the preview widget to have opacity off, like all of the other widgets (if it is on, then opacity can't be applied to it. Also looks rather tacky with it) Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/setup_colors.cpp4
-rw-r--r--src/gui/widgets/textpreview.cpp13
-rw-r--r--src/gui/widgets/textpreview.h17
3 files changed, 26 insertions, 8 deletions
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 5019a61a..f0f7a529 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -60,7 +60,7 @@ Setup_Colors::Setup_Colors() :
mTextPreview = new TextPreview(&rawmsg);
mPreview = new BrowserBox(BrowserBox::AUTO_WRAP);
- mPreview->setOpaque(true);
+ mPreview->setOpaque(false);
// Replace this later with a more appropriate link handler. For now, this'll
// do, as it'll do nothing when clicked on.
@@ -212,8 +212,6 @@ void Setup_Colors::action(const gcn::ActionEvent &event)
case Palette::HYPERLINK:
mPreviewBox->setContent(mPreview);
mPreview->clearRows();
- //char ch = guiPalette->getColorCharAt(mSelected);
- //std::string msg;
if (ch == '<')
{
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index f77657c2..b13d12e4 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -2,7 +2,7 @@
* The Mana World
* Copyright (C) 2006 The Mana World Development Team
*
- * This file is part of The Mana World.
+ * This file is part of Aethyra based on code from The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,12 +35,16 @@ TextPreview::TextPreview(const std::string* text)
mTextColor = &guiPalette->getColor(Palette::TEXT);
mTextBGColor = NULL;
mBGColor = &guiPalette->getColor(Palette::BACKGROUND);
+ mOpaque = false;
}
void TextPreview::draw(gcn::Graphics* graphics)
{
- graphics->setColor(*mBGColor);
- graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ if (mOpaque)
+ {
+ graphics->setColor(*mBGColor);
+ graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ }
const std::string ttf = "TrueTypeFont";
@@ -50,7 +54,8 @@ void TextPreview::draw(gcn::Graphics* graphics)
graphics->setColor(*mTextBGColor);
int x = font->getWidth(*mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0);
int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0);
- graphics->fillRectangle(gcn::Rectangle(1, 1, x, y));
+ if (mOpaque)
+ 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 12db9f3f..7e7e461c 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -2,7 +2,7 @@
* The Mana World
* Copyright (C) 2006 The Mana World Development Team
*
- * This file is part of The Mana World.
+ * This file is part of Aethyra based on code from The Mana World.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -102,12 +102,27 @@ class TextPreview : public gcn::Widget
*/
void draw(gcn::Graphics *graphics);
+ /**
+ * Set opacity for this widget (whether or not to show the background
+ * color)
+ *
+ * @param opaque Whether the widget should be opaque or not
+ */
+ void setOpaque(bool opaque) { mOpaque = opaque; }
+
+ /**
+ * Gets opacity for this widget (whether or not the background color
+ * is shown below the widget)
+ */
+ bool isOpaque() { return mOpaque; }
+
private:
gcn::Font *mFont;
const std::string* mText;
const gcn::Color* mTextColor;
const gcn::Color* mBGColor;
const gcn::Color* mTextBGColor;
+ bool mOpaque;
bool mShadow;
bool mOutline;
};