summarylogtreecommitdiffstats
path: root/dark.diff
blob: 2baab80882565963cc923da5d4f2b0899159ef42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
--- a/src/gui/components/wxGameList.cpp
+++ b/src/gui/components/wxGameList.cpp
@@ -71,8 +71,8 @@ wxGameList::wxGameList(wxWindow* parent, wxWindowID id)
 	m_tooltip_window->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK));
 	m_tooltip_window->SetSizerAndFit(tooltip_sizer);
 	m_tooltip_window->Hide();
-	
-	m_tooltip_timer = new wxTimer(this);	
+
+	m_tooltip_timer = new wxTimer(this);
 
 	Bind(wxEVT_CLOSE_WINDOW, &wxGameList::OnClose, this);
 	Bind(wxEVT_MOTION, &wxGameList::OnMouseMove, this);
@@ -125,16 +125,16 @@ void wxGameList::LoadConfig()
 	{
 		wxArrayInt order;
 		order.reserve(ColumnFavorite);
-		
+
 		const auto order_string = std::string_view(config.game_list_column_order).substr(1);
-		
+
 		const boost::char_separator<char> sep(",");
 		boost::tokenizer tokens(order_string.begin(), order_string.end(), sep);
 		for(const auto& token : tokens)
 		{
 			order.push_back(ConvertString<int>(token, 10));
 		}
-		
+
 		#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
 		if(order.GetCount() == ColumnFavorite)
 			SetColumnsOrder(order);
@@ -209,10 +209,10 @@ void wxGameList::SetStyle(Style style, bool save)
 		return;
 
 	wxWindowUpdateLocker updatelock(this);
-	
+
 	m_style = style;
 	SetWindowStyleFlag(GetStyleFlags(m_style));
-	
+
 	uint64 selected_title_id = 0;
 	auto selection = GetNextItem(wxNOT_FOUND, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
 	if (selection != wxNOT_FOUND)
@@ -230,7 +230,7 @@ void wxGameList::SetStyle(Style style, bool save)
 		wxListCtrl::SetImageList(m_image_list_small, wxIMAGE_LIST_NORMAL);
 		break;
 	}
-	
+
 	ReloadGameEntries();
 	SortEntries();
 	UpdateItemColors();
@@ -269,16 +269,42 @@ long wxGameList::GetStyleFlags(Style style) const
 
 void wxGameList::UpdateItemColors(sint32 startIndex)
 {
+
 	wxWindowUpdateLocker lock(this);
+
+	// Get the background color so we can determine the theme in use
+	const wxColour bgColour = GetBackgroundColour();
+
 	for (int i = startIndex; i < GetItemCount(); ++i)
 	{
 		const auto titleId = (uint64)GetItemData(i);
 		if (GetConfig().IsGameListFavorite(titleId))//entry->favorite)
+		{
 			SetItemBackgroundColour(i, kFavoriteColor);
+			SetItemTextColour(i, 0x000000UL);
+		}
 		else if ((i&1) != 0)
-			SetItemBackgroundColour(i, kSecondColor);
+		{
+			// Depending on the background RGB value:
+			// Light theme row color will be 10% darker (90)
+			// Dark theme row color will be 10% brighter (110)
+			int alpha = bgColour.GetRGB() > 0x808080 ? 90 : 110;
+			SetItemBackgroundColour(i, bgColour.ChangeLightness(alpha));
+
+			// Text can be changed to other values for alternating rows if needed
+			SetItemTextColour(i, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
+		}
 		else
-			SetItemBackgroundColour(i, 0xFFFFFFUL);
+		{
+			// Depending on the background RGB value:
+			// Light theme row color will be 0% darker (100)
+			// Dark theme row color will be 0% brighter (100)
+			int alpha = bgColour.GetRGB() > 0x808080 ? 100 : 100;
+			SetItemBackgroundColour(i, bgColour.ChangeLightness(alpha));
+
+			// Text color can be modified to other values for alternating rows if needed
+			 SetItemTextColour(i, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
+		}
 	}
 }
 
@@ -309,7 +335,7 @@ int wxGameList::SortFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
 {
 	const auto sort_data = (SortData*)sortData;
 	const int dir = sort_data->dir;
-	
+
 	return sort_data->thisptr->SortComparator((uint64)item1, (uint64)item2, sort_data);
 }
 
@@ -331,7 +357,7 @@ void wxGameList::SortEntries(int column)
 			s_direction = 1;
 		}
 	}
-	
+
 	switch (column)
 	{
 	case ColumnName:
@@ -349,7 +375,7 @@ void wxGameList::SortEntries(int column)
 void wxGameList::CreateListColumns()
 {
 	DeleteAllColumns();
-	
+
 	const auto& config = GetConfig();
 	wxListItem col0;
 	col0.SetId(ColumnHiddenName);
@@ -392,7 +418,7 @@ void wxGameList::CreateListColumns()
 	col6.SetText(_("Last played"));
 	col6.SetWidth(config.column_width.game_started);
 	InsertColumn(ColumnGameStarted, col6);
-	
+
 	wxListItem col7;
 	col7.SetId(ColumnRegion);
 	col7.SetText(_("Region"));
@@ -405,7 +431,7 @@ void wxGameList::OnKeyDown(wxListEvent& event)
 	event.Skip();
 	if (m_style != Style::kList)
 		return;
-	
+
 	const auto keycode = std::tolower(event.m_code);
 	if (keycode == WXK_LEFT)
 	{
@@ -445,12 +471,12 @@ void wxGameList::OnKeyDown(wxListEvent& event)
 enum ContextMenuEntries
 {
 	kContextMenuRefreshGames = wxID_HIGHEST + 1,
-	
+
 	kContextMenuStart,
 	kWikiPage,
 	kContextMenuFavorite,
 	kContextMenuEditName,
-	
+
 	kContextMenuGameFolder,
 	kContextMenuSaveFolder,
 	kContextMenuUpdateFolder,
@@ -465,10 +491,10 @@ enum ContextMenuEntries
 void wxGameList::OnContextMenu(wxContextMenuEvent& event)
 {
 	auto& config = GetConfig();
-	
+
 	wxMenu menu;
 	menu.Bind(wxEVT_COMMAND_MENU_SELECTED, &wxGameList::OnContextMenuSelected, this);
-	
+
 	const auto selection = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
 	if (selection != wxNOT_FOUND)
 	{
@@ -486,18 +512,18 @@ void wxGameList::OnContextMenu(wxContextMenuEvent& event)
 			menu.AppendSeparator();
 			menu.AppendCheckItem(kContextMenuFavorite, _("&Favorite"))->Check(isFavorite);
 			menu.Append(kContextMenuEditName, _("&Edit name"));
-			
+
 			menu.AppendSeparator();
 			menu.Append(kWikiPage, _("&Wiki page"));
 			menu.Append(kContextMenuGameFolder, _("&Game directory"));
 			menu.Append(kContextMenuSaveFolder, _("&Save directory"))->Enable(fs::is_directory(gameInfo.GetSaveFolder(), ec));
 			menu.Append(kContextMenuUpdateFolder, _("&Update directory"))->Enable(gameInfo.HasUpdate());
 			menu.Append(kContextMenuDLCFolder, _("&DLC directory"))->Enable(gameInfo.HasAOC());
-			
+
 			menu.AppendSeparator();
 			menu.Append(kContextMenuEditGraphicPacks, _("&Edit graphic packs"));
 			menu.Append(kContextMenuEditGameProfile, _("&Edit game profile"));
-			
+
 			menu.AppendSeparator();
 		}
 	}
@@ -581,7 +607,7 @@ void wxGameList::OnContextMenuSelected(wxCommandEvent& event)
 				}
 				break;
 				}
-				
+
 			case kContextMenuSaveFolder:
 			{
 				wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _pathToUtf8(gameInfo.GetSaveFolder()))));
@@ -647,7 +673,7 @@ void wxGameList::OnColumnRightClick(wxListEvent& event)
 	{
 		ResetWidth = wxID_HIGHEST + 1,
 		ResetOrder,
-		
+
 		ShowName,
 		ShowVersion,
 		ShowDlc,
@@ -658,10 +684,10 @@ void wxGameList::OnColumnRightClick(wxListEvent& event)
 	const int column = event.GetColumn();
 	wxMenu menu;
 	menu.SetClientObject(new wxCustomData(column));
-	
+
 	menu.Append(ResetWidth, _("Reset &width"));
 	menu.Append(ResetOrder, _("Reset &order"))	;
-	
+
 	menu.AppendSeparator();
 	menu.AppendCheckItem(ShowName, _("Show &name"))->Check(GetColumnWidth(ColumnName) > 0);
 	menu.AppendCheckItem(ShowVersion, _("Show &version"))->Check(GetColumnWidth(ColumnVersion) > 0);
@@ -758,7 +784,7 @@ void wxGameList::ApplyGameListColumnWidths()
 		else
 			this->SetColumnWidth(id, width);
 	};
-	
+
 	const auto& config = GetConfig();
 	wxWindowUpdateLocker lock(this);
 	set_width(ColumnName, config.column_width.name);
@@ -943,7 +969,7 @@ void wxGameList::OnItemActivated(wxListEvent& event)
 		wxPostEvent(this, open_settings_event);
 		return;
 	}
-	
+
 	TitleInfo titleInfo;
 	if (!CafeTitleList::GetFirstByTitleId(item_data, titleInfo))
 		return;
@@ -974,7 +1000,7 @@ void wxGameList::OnTimer(wxTimerEvent& event)
 			//}
 		}
 	}
-		
+
 }
 
 void wxGameList::OnMouseMove(wxMouseEvent& event)