From f54cd905f49d08116bf988bcb4451beb168cbd48 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sun, 13 Nov 2011 05:44:22 +0100 Subject: 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. --- src/gui/widgets/chattab.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/gui/widgets/chattab.cpp') 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 -- cgit v1.2.3-60-g2f50