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/browserbox.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'src/gui/widgets/browserbox.cpp') diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index d553312b..8c678805 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -37,6 +37,8 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque): gcn::Widget(), mMode(mode), mHighMode(UNDERLINE | BACKGROUND), + mShadows(false), + mOutline(false), mOpaque(opaque), mUseLinksAndUserColors(true), mSelectedLink(-1), @@ -304,8 +306,6 @@ void BrowserBox::draw(gcn::Graphics *graphics) } } - gcn::Font *font = getFont(); - for (LinePartIterator i = mLineParts.begin(); i != mLineParts.end(); i ++) @@ -315,8 +315,41 @@ void BrowserBox::draw(gcn::Graphics *graphics) continue; if (part.getY() > yEnd) break; + + // Use the correct font + graphics->setFont(getFont()); + + // Handle text shadows + if (mShadows) + { + graphics->setColor(Theme::getThemeColor(Theme::SHADOW, + part.getColor().a / 2)); + if (mOutline) + { + graphics->drawText(part.getText(), part.getX() + 2, + part.getY() + 2); + } + else + { + graphics->drawText(part.getText(), part.getX() + 1, + part.getY() + 1); + } + } + + if (mOutline) + { + // Text outline + graphics->setColor(Theme::getThemeColor(Theme::OUTLINE, + part.getColor().a / 4)); + graphics->drawText(part.getText(), part.getX() + 1, part.getY()); + graphics->drawText(part.getText(), part.getX() - 1, part.getY()); + graphics->drawText(part.getText(), part.getX(), part.getY() + 1); + graphics->drawText(part.getText(), part.getX(), part.getY() - 1); + } + + // the main text graphics->setColor(part.getColor()); - font->drawString(graphics, part.getText(), part.getX(), part.getY()); + graphics->drawText(part.getText(), part.getX(), part.getY()); } return; -- cgit v1.2.3-70-g09d2