summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2017-03-08 22:38:23 +0000
committerGitHub <noreply@github.com>2017-03-08 22:38:23 +0000
commit883bec873fd1e74e090331d437a84af43126bcbe (patch)
tree5207c9fd25598982ac83c93d06ab54be849ba24a /Source
parent5acf2c87dd4727f13c9ebddebc33e2a1288837a6 (diff)
parent28f47937857fcf28a21247084d086884b8b22ac7 (diff)
Merge pull request #4939 from sjnewbury/gamelist-text
Always use visible text in GameList
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinWX/GameListCtrl.cpp17
-rw-r--r--Source/Core/DolphinWX/GameListCtrl.h2
2 files changed, 14 insertions, 5 deletions
diff --git a/Source/Core/DolphinWX/GameListCtrl.cpp b/Source/Core/DolphinWX/GameListCtrl.cpp
index a6ea42048f..625ee8e09b 100644
--- a/Source/Core/DolphinWX/GameListCtrl.cpp
+++ b/Source/Core/DolphinWX/GameListCtrl.cpp
@@ -624,8 +624,8 @@ void CGameListCtrl::InsertItemInReportView(long index)
UpdateItemAtColumn(item_index, i);
}
- // Background color
- SetBackgroundColor();
+ // List colors
+ SetColors();
}
static wxColour blend50(const wxColour& c1, const wxColour& c2)
@@ -638,7 +638,15 @@ static wxColour blend50(const wxColour& c1, const wxColour& c2)
return a << 24 | b << 16 | g << 8 | r;
}
-void CGameListCtrl::SetBackgroundColor()
+static wxColour ContrastText(const wxColour& bgc)
+{
+ // Luminance threshold to determine whether to use black text on light background
+ static constexpr int LUM_THRESHOLD = 186;
+ int lum = 0.299 * bgc.Red() + 0.587 * bgc.Green() + 0.114 * bgc.Blue();
+ return (lum > LUM_THRESHOLD) ? *wxBLACK : *wxWHITE;
+}
+
+void CGameListCtrl::SetColors()
{
for (long i = 0; i < GetItemCount(); i++)
{
@@ -646,6 +654,7 @@ void CGameListCtrl::SetBackgroundColor()
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)) :
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
CGameListCtrl::SetItemBackgroundColour(i, color);
+ SetItemTextColour(i, ContrastText(color));
}
}
@@ -796,7 +805,7 @@ void CGameListCtrl::OnColumnClick(wxListEvent& event)
SortItems(wxListCompare, last_sort);
}
- SetBackgroundColor();
+ SetColors();
event.Skip();
}
diff --git a/Source/Core/DolphinWX/GameListCtrl.h b/Source/Core/DolphinWX/GameListCtrl.h
index 7854c7972f..3f5763588a 100644
--- a/Source/Core/DolphinWX/GameListCtrl.h
+++ b/Source/Core/DolphinWX/GameListCtrl.h
@@ -73,7 +73,7 @@ private:
void InitBitmaps();
void UpdateItemAtColumn(long _Index, int column);
void InsertItemInReportView(long _Index);
- void SetBackgroundColor();
+ void SetColors();
void ScanForISOs();
// events