summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-24 22:32:04 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-24 22:32:04 +0300
commit4e95f451a793dbac5dbc31361cdc5049de48c3cc (patch)
tree02a1cc506638edd2deb2074abd97330a74435c3a
parent22e4c80cc35e552ef39639a874f3c54f11fde747 (diff)
downloadplus-4e95f451a793dbac5dbc31361cdc5049de48c3cc.tar.gz
plus-4e95f451a793dbac5dbc31361cdc5049de48c3cc.tar.bz2
plus-4e95f451a793dbac5dbc31361cdc5049de48c3cc.tar.xz
plus-4e95f451a793dbac5dbc31361cdc5049de48c3cc.zip
Add color for selected text in listboxes.
New theme color: LISTBOX_SELECTED
-rw-r--r--data/graphics/gui/colors.xml1
-rw-r--r--data/themes/blacknblack/colors.xml1
-rw-r--r--data/themes/blackwood/colors.xml1
-rw-r--r--data/themes/enchilado/colors.xml1
-rw-r--r--data/themes/jewelry/colors.xml3
-rw-r--r--data/themes/mana/colors.xml1
-rw-r--r--data/themes/pink/colors.xml1
-rw-r--r--data/themes/unity/colors.xml1
-rw-r--r--data/themes/wood/colors.xml1
-rw-r--r--src/gui/serverdialog.cpp7
-rw-r--r--src/gui/theme.cpp1
-rw-r--r--src/gui/theme.h1
-rw-r--r--src/gui/widgets/extendedlistbox.cpp33
-rw-r--r--src/gui/widgets/listbox.cpp15
-rw-r--r--src/gui/widgets/listbox.h1
-rw-r--r--src/gui/widgets/shoplistbox.cpp5
16 files changed, 61 insertions, 13 deletions
diff --git a/data/graphics/gui/colors.xml b/data/graphics/gui/colors.xml
index 089ff9429..0f0358897 100644
--- a/data/graphics/gui/colors.xml
+++ b/data/graphics/gui/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#000000" />
<color id="TAB" color="#000000" />
diff --git a/data/themes/blacknblack/colors.xml b/data/themes/blacknblack/colors.xml
index 939583dce..ab428f763 100644
--- a/data/themes/blacknblack/colors.xml
+++ b/data/themes/blacknblack/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#ffffff" />
<color id="LABEL" color="#ffffff" />
<color id="LISTBOX" color="#ffffff" />
+ <color id="LISTBOX_SELECTED" color="#ffffff" />
<color id="RADIOBUTTON" color="#ffffff" />
<color id="POPUP" color="#ffffff" />
<color id="TAB" color="#13f00d" />
diff --git a/data/themes/blackwood/colors.xml b/data/themes/blackwood/colors.xml
index 6e2ccdde5..16ab31193 100644
--- a/data/themes/blackwood/colors.xml
+++ b/data/themes/blackwood/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#000000" />
<color id="TAB" color="#000000" />
diff --git a/data/themes/enchilado/colors.xml b/data/themes/enchilado/colors.xml
index 97cd521f4..a070e0fce 100644
--- a/data/themes/enchilado/colors.xml
+++ b/data/themes/enchilado/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#000000" />
<color id="TAB" color="#000000" />
diff --git a/data/themes/jewelry/colors.xml b/data/themes/jewelry/colors.xml
index 2cb064f16..189b7d07b 100644
--- a/data/themes/jewelry/colors.xml
+++ b/data/themes/jewelry/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#f9eabc" />
<color id="TAB" color="#efd7a7" />
@@ -105,6 +106,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#f9eabc" />
<color id="TAB" color="#efd7a7" />
@@ -195,6 +197,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#f9eabc" />
<color id="TAB" color="#efd7a7" />
diff --git a/data/themes/mana/colors.xml b/data/themes/mana/colors.xml
index f37fce9ad..020ac3ef1 100644
--- a/data/themes/mana/colors.xml
+++ b/data/themes/mana/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#000000" />
<color id="TAB" color="#000000" />
diff --git a/data/themes/pink/colors.xml b/data/themes/pink/colors.xml
index dc7f00f0b..938d9d7ca 100644
--- a/data/themes/pink/colors.xml
+++ b/data/themes/pink/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#FF00FF" />
<color id="LABEL" color="#FF00FF" />
<color id="LISTBOX" color="#FF00FF" />
+ <color id="LISTBOX_SELECTED" color="#FF00FF" />
<color id="RADIOBUTTON" color="#FF00FF" />
<color id="POPUP" color="#FF00FF" />
<color id="TAB" color="#FF32FF" />
diff --git a/data/themes/unity/colors.xml b/data/themes/unity/colors.xml
index fa1b95e03..08b9ce1e4 100644
--- a/data/themes/unity/colors.xml
+++ b/data/themes/unity/colors.xml
@@ -14,6 +14,7 @@
<color id="DROPDOWN" color="#E0E0E0" />
<color id="LABEL" color="#E0E0E0" />
<color id="LISTBOX" color="#E0E0E0" />
+ <color id="LISTBOX_SELECTED" color="#E0E0E0" />
<color id="RADIOBUTTON" color="#E0E0E0" />
<color id="POPUP" color="#E0E0E0" />
<color id="TAB" color="#E0E0E0" />
diff --git a/data/themes/wood/colors.xml b/data/themes/wood/colors.xml
index 6add6431d..fa3cc89be 100644
--- a/data/themes/wood/colors.xml
+++ b/data/themes/wood/colors.xml
@@ -15,6 +15,7 @@
<color id="DROPDOWN" color="#000000" />
<color id="LABEL" color="#000000" />
<color id="LISTBOX" color="#000000" />
+ <color id="LISTBOX_SELECTED" color="#000000" />
<color id="RADIOBUTTON" color="#000000" />
<color id="POPUP" color="#000000" />
<color id="TAB" color="#000000" />
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 5cc1c2acb..2f0610999 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -160,7 +160,6 @@ public:
ServersListModel *const model) :
ListBox(widget, model),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
- mTextColor(getThemeColor(Theme::LISTBOX)),
mNotSupportedColor(getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED))
{
}
@@ -196,7 +195,10 @@ public:
{
ServerInfo info = model->getServer(i);
- graphics->setColor(mTextColor);
+ if (mSelected == i)
+ graphics->setColor(mForegroundSelectedColor);
+ else
+ graphics->setColor(mForegroundColor);
int top;
int x = mPadding;
@@ -235,7 +237,6 @@ public:
}
private:
gcn::Color mHighlightColor;
- gcn::Color mTextColor;
gcn::Color mNotSupportedColor;
};
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 46506ecb4..8a4f3573c 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -725,6 +725,7 @@ static int readColorType(const std::string &type)
"DROPDOWN",
"LABEL",
"LISTBOX",
+ "LISTBOX_SELECTED",
"RADIOBUTTON",
"POPUP",
"TAB",
diff --git a/src/gui/theme.h b/src/gui/theme.h
index bd5e27708..741f3be44 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -203,6 +203,7 @@ class Theme final : public Palette, public ConfigListener
DROPDOWN,
LABEL,
LISTBOX,
+ LISTBOX_SELECTED,
RADIOBUTTON,
POPUP,
TAB,
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index bb138b456..bad1472ac 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -82,18 +82,37 @@ void ExtendedListBox::draw(gcn::Graphics *graphics)
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
- const Image *const image = model->getImageAt(i);
+ if (i != mSelected)
+ {
+ const Image *const image = model->getImageAt(i);
+ if (!image)
+ {
+ graphics->drawText(mListModel->getElementAt(i),
+ mPadding, y + textPos);
+ }
+ else
+ {
+ g->drawImage(image, mImagePadding, y + (height
+ - image->getHeight()) / 2 + mPadding);
+ graphics->drawText(mListModel->getElementAt(i),
+ image->getWidth() + mImagePadding + mSpacing, y + textPos);
+ }
+ }
+ }
+ if (mSelected >= 0)
+ {
+ const Image *const image = model->getImageAt(mSelected);
if (!image)
{
- graphics->drawText(mListModel->getElementAt(i),
- mPadding, y + textPos);
+ graphics->drawText(mListModel->getElementAt(mSelected),
+ mPadding, mSelected * height + textPos);
}
else
{
- g->drawImage(image, mImagePadding, y + (height
- - image->getHeight()) / 2 + mPadding);
- graphics->drawText(mListModel->getElementAt(i),
- image->getWidth() + mImagePadding + mSpacing, y + textPos);
+ graphics->setColor(mForegroundSelectedColor);
+ graphics->drawText(mListModel->getElementAt(mSelected),
+ image->getWidth() + mImagePadding + mSpacing,
+ mSelected * height + textPos);
}
}
BLOCK_END("ExtendedListBox::draw")
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 4de4e360f..87ecc9460 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -46,6 +46,7 @@ ListBox::ListBox(const Widget2 *const widget,
gcn::ListBox(listModel),
Widget2(widget),
mHighlightColor(getThemeColor(Theme::HIGHLIGHT)),
+ mForegroundSelectedColor(getThemeColor(Theme::LISTBOX_SELECTED)),
mDistributeMousePressed(true),
mOldSelected(-1),
mPadding(0)
@@ -102,13 +103,23 @@ void ListBox::draw(gcn::Graphics *graphics)
height * mSelected + mPadding, getWidth() - 2 * mPadding, height));
}
+ const int sel = getSelected();
+ if (sel >= 0)
+ {
+ graphics->setColor(mForegroundSelectedColor);
+ graphics->drawText(mListModel->getElementAt(sel),
+ mPadding, sel * height + mPadding);
+ }
// Draw the list elements
graphics->setColor(mForegroundColor);
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
- graphics->drawText(mListModel->getElementAt(i),
- mPadding, y + mPadding);
+ if (i != sel)
+ {
+ graphics->drawText(mListModel->getElementAt(i),
+ mPadding, y + mPadding);
+ }
}
BLOCK_END("ListBox::draw")
}
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index 442840a29..36f48e7b7 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -89,6 +89,7 @@ class ListBox : public gcn::ListBox,
protected:
gcn::Color mHighlightColor;
+ gcn::Color mForegroundSelectedColor;
bool mDistributeMousePressed;
int mOldSelected;
int mPadding;
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 86c2e2e67..7d23189d1 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -155,7 +155,10 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
graphics->drawImage(icon, mPadding, y + mPadding);
}
}
- graphics->setColor(mForegroundColor);
+ if (mSelected == i)
+ graphics->setColor(mForegroundSelectedColor);
+ else
+ graphics->setColor(mForegroundColor);
graphics->drawText(mListModel->getElementAt(i),
ITEM_ICON_SIZE + mPadding,
y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2 + mPadding);