Skip to content

Commit 2842615

Browse files
Fix various colour values for dark themes (#439)
1 parent 94b179e commit 2842615

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

src/gui/MainWindow.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1696,8 +1696,6 @@ class CemuAboutDialog : public wxDialog
16961696
{
16971697
SetIcon(wxICON(M_WND_ICON128));
16981698

1699-
this->SetBackgroundColour(wxColour(0xFFFFFFFF));
1700-
17011699
wxScrolledWindow* scrolledWindow = new wxScrolledWindow(this);
17021700

17031701
wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);

src/gui/components/wxGameList.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,9 @@ long wxGameList::GetStyleFlags(Style style) const
358358
void wxGameList::UpdateItemColors(sint32 startIndex)
359359
{
360360
wxWindowUpdateLocker lock(this);
361-
// get the background color so we can determine the theme in use
362-
wxColour bgColour = GetBackgroundColour();
363-
uint32 bgLightness = (bgColour.GetRed() + bgColour.GetGreen() + bgColour.GetBlue()) / 3;
364-
bool isDarkTheme = bgLightness < 128;
365-
wxColour bgColourPrimary = bgColour; // color for odd rows
366-
wxColour bgColourSecondary = bgColour.ChangeLightness(isDarkTheme ? 110 : 90); // color for even rows
367361

368-
// for very light themes we'll use a blue tint to match the older Windows Cemu look
369-
if (bgLightness > 250)
370-
bgColourSecondary = wxColour(bgColour.Red() - 13, bgColour.Green() - 6, bgColour.Blue() - 2);
362+
wxColour bgColourPrimary = GetBackgroundColour();
363+
wxColour bgColourSecondary = wxHelper::CalculateAccentColour(bgColourPrimary);
371364

372365
for (int i = startIndex; i < GetItemCount(); ++i)
373366
{
@@ -1143,4 +1136,4 @@ bool wxGameList::QueryIconForTitle(TitleId titleId, int& icon, int& iconSmall)
11431136
void wxGameList::DeleteCachedStrings()
11441137
{
11451138
m_name_cache.clear();
1146-
}
1139+
}

src/gui/components/wxTitleManagerList.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ wxString wxTitleManagerList::OnGetItemText(long item, long column) const
172172

173173
wxItemAttr* wxTitleManagerList::OnGetItemAttr(long item) const
174174
{
175-
const auto entry = GetTitleEntry(item);
176-
const wxColour kSecondColor{ 0xFDF9F2 };
177-
static wxListItemAttr s_coloured_attr(GetTextColour(), kSecondColor, GetFont());
178-
return item % 2 == 0 ? nullptr : &s_coloured_attr;
175+
static wxColour bgColourPrimary = GetBackgroundColour();
176+
static wxColour bgColourSecondary = wxHelper::CalculateAccentColour(bgColourPrimary);
177+
static wxListItemAttr s_primary_attr(GetTextColour(), bgColourPrimary, GetFont());
178+
static wxListItemAttr s_secondary_attr(GetTextColour(), bgColourSecondary, GetFont());
179+
return item % 2 == 0 ? &s_primary_attr : &s_secondary_attr;
179180
}
180181

181182
boost::optional<wxTitleManagerList::TitleEntry&> wxTitleManagerList::GetTitleEntry(long item)
@@ -1274,4 +1275,4 @@ void wxTitleManagerList::ClearItems()
12741275
void wxTitleManagerList::AutosizeColumns()
12751276
{
12761277
wxAutosizeColumns(this, ColumnTitleId, ColumnMAX - 1);
1277-
}
1278+
}

src/gui/input/panels/InputPanel.h

+8
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@
55
#include "input/emulated/EmulatedController.h"
66
#include "input/api/Controller.h"
77

8+
#include "gui/wxHelper.h"
9+
810
class ControllerBase;
911
class wxTextCtrl;
1012
class wxComboBox;
1113

1214
class InputPanel : public wxPanel
1315
{
1416
public:
17+
#if BOOST_OS_WINDOWS
1518
const wxColour kKeyColourNormalMode = 0xfafafa;
1619
const wxColour kKeyColourEditMode = 0x99ccff;
1720
const wxColour kKeyColourActiveMode = 0xE0E0E0;
21+
#else
22+
const wxColour kKeyColourNormalMode = GetBackgroundColour();
23+
const wxColour kKeyColourEditMode = GetBackgroundColour();
24+
const wxColour kKeyColourActiveMode = wxHelper::CalculateAccentColour(kKeyColourNormalMode);
25+
#endif
1826

1927
InputPanel(wxWindow* parent);
2028

src/gui/wxHelper.h

+11
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,16 @@ namespace wxHelper
2222
return wxString::FromUTF8(str.data(), str.size());
2323
}
2424

25+
inline wxColour CalculateAccentColour(const wxColour& bgColour)
26+
{
27+
wxColour bgColourSecondary;
28+
const uint32 bgLightness = (bgColour.GetRed() + bgColour.GetGreen() + bgColour.GetBlue()) / 3;
29+
const bool isDarkTheme = bgLightness < 128;
30+
bgColourSecondary = bgColour.ChangeLightness(isDarkTheme ? 110 : 90); // color for even rows
31+
// for very light themes we'll use a blue tint to match the older Windows Cemu look
32+
if (bgLightness > 250)
33+
bgColourSecondary = wxColour(bgColour.Red() - 13, bgColour.Green() - 6, bgColour.Blue() - 2);
34+
return bgColourSecondary;
35+
}
2536

2637
};

0 commit comments

Comments
 (0)