From a2c2444d9eb4b43fb73339ae1cc3b7464f33409e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 5 May 2013 23:56:48 +0300 Subject: add outline color to listbox. --- src/gui/serverdialog.cpp | 10 ++++++++-- src/gui/theme.cpp | 2 ++ src/gui/theme.h | 2 ++ src/gui/widgets/listbox.cpp | 8 ++++++-- src/gui/widgets/listbox.h | 2 ++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 8bc1ad804..acf81ace5 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -171,6 +171,7 @@ public: ServersListModel *const model = static_cast( mListModel); + Graphics *const g = static_cast(graphics); updateAlpha(); @@ -201,9 +202,14 @@ public: ServerInfo info = model->getServer(i); if (mSelected == i) - graphics->setColor(mForegroundSelectedColor); + { + g->setColorAll(mForegroundSelectedColor, + mForegroundSelectedColor2); + } else - graphics->setColor(mForegroundColor); + { + g->setColorAll(mForegroundColor, mForegroundColor2); + } int top; int x = mPadding; diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index c5d358cab..1077dc1ff 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -789,7 +789,9 @@ static int readColorType(const std::string &type) "LABEL", "LABEL_OUTLINE", "LISTBOX", + "LISTBOX_OUTLINE", "LISTBOX_SELECTED", + "LISTBOX_SELECTED_OUTLINE", "RADIOBUTTON", "POPUP", "POPUP_OUTLINE", diff --git a/src/gui/theme.h b/src/gui/theme.h index 084868ef2..7cc5ce592 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -229,7 +229,9 @@ class Theme final : public Palette, public ConfigListener LABEL, LABEL_OUTLINE, LISTBOX, + LISTBOX_OUTLINE, LISTBOX_SELECTED, + LISTBOX_SELECTED_OUTLINE, RADIOBUTTON, POPUP, POPUP_OUTLINE, diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 2e84bb1a2..d2b7eb712 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -45,7 +45,9 @@ ListBox::ListBox(const Widget2 *const widget, gcn::ListBox(listModel), Widget2(widget), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), + mForegroundColor2(getThemeColor(Theme::LISTBOX_OUTLINE)), mForegroundSelectedColor(getThemeColor(Theme::LISTBOX_SELECTED)), + mForegroundSelectedColor2(getThemeColor(Theme::LISTBOX_SELECTED_OUTLINE)), mDistributeMousePressed(true), mOldSelected(-1), mPadding(0), @@ -88,6 +90,7 @@ void ListBox::draw(gcn::Graphics *graphics) BLOCK_START("ListBox::draw") updateAlpha(); + Graphics *const g = static_cast(graphics); mHighlightColor.a = static_cast(mAlpha * 255.0f); graphics->setColor(mHighlightColor); @@ -105,12 +108,13 @@ void ListBox::draw(gcn::Graphics *graphics) const int sel = getSelected(); if (sel >= 0) { - graphics->setColor(mForegroundSelectedColor); + g->setColorAll(mForegroundSelectedColor, + mForegroundSelectedColor2); font->drawString(graphics, mListModel->getElementAt(sel), mPadding, sel * height + mPadding); } // Draw the list elements - graphics->setColor(mForegroundColor); + g->setColorAll(mForegroundColor, mForegroundColor2); for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += height) { diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 8296d90e4..ea48c6f16 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -91,7 +91,9 @@ class ListBox : public gcn::ListBox, protected: gcn::Color mHighlightColor; + gcn::Color mForegroundColor2; gcn::Color mForegroundSelectedColor; + gcn::Color mForegroundSelectedColor2; bool mDistributeMousePressed; int mOldSelected; int mPadding; -- cgit v1.2.3-60-g2f50