summaryrefslogtreecommitdiff
path: root/src/gui/widgets/chattab.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-11-13 05:44:22 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-01-09 06:55:07 +0100
commitf54cd905f49d08116bf988bcb4451beb168cbd48 (patch)
treefe1b9eebd4941fe44cee48cfd2818a7239b2ac07 /src/gui/widgets/chattab.cpp
parent734cf89900cde0526043429c3028cb69616f7cb8 (diff)
downloadmana-f54cd905f49d08116bf988bcb4451beb168cbd48.tar.gz
mana-f54cd905f49d08116bf988bcb4451beb168cbd48.tar.bz2
mana-f54cd905f49d08116bf988bcb4451beb168cbd48.tar.xz
mana-f54cd905f49d08116bf988bcb4451beb168cbd48.zip
Made the chat text much more readable in every opacity case.
I added text shadow and outline support to the browserbox, and made it adapt the text for the chattabs depending on the GUI opacity. Reviewed-by: Ablu.
Diffstat (limited to 'src/gui/widgets/chattab.cpp')
-rw-r--r--src/gui/widgets/chattab.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index c86eb2ea..bd4c5910 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -27,6 +27,7 @@
#include "configuration.h"
#include "localplayer.h"
+#include "gui/gui.h"
#include "gui/recorder.h"
#include "gui/widgets/browserbox.h"
@@ -63,6 +64,11 @@ ChatTab::ChatTab(const std::string &name) : Tab()
mScrollArea->setOpaque(false);
chatWindow->addTab(this);
+
+ listen(Event::ConfigChannel);
+
+ // Initiate the text format
+ updateTextFormat(((Window*)getParent())->getGuiAlpha());
}
ChatTab::~ChatTab()
@@ -74,6 +80,37 @@ ChatTab::~ChatTab()
delete mScrollArea;
}
+void ChatTab::updateTextFormat(int alpha)
+{
+ if (alpha > 200)
+ {
+ mTextOutput->setOutlinedText(false);
+ mTextOutput->setShadowedText(false);
+ }
+ else if (alpha <= 200 && alpha > 100)
+ {
+ mTextOutput->setOutlinedText(false);
+ mTextOutput->setShadowedText(true);
+ }
+ else
+ {
+ mTextOutput->setOutlinedText(true);
+ mTextOutput->setShadowedText(false);
+ }
+}
+
+void ChatTab::event(Event::Channel channel, const Event &event)
+{
+ // Update the text outline and shadow according to the gui opacity.
+ if (channel == Event::ConfigChannel &&
+ event.getType() == Event::ConfigOptionChanged &&
+ event.getString("option") == "guialpha")
+ {
+ int alpha = ((Window*)getParent())->getGuiAlpha();
+ updateTextFormat(alpha);
+ }
+}
+
void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord)
{
// Trim whitespace