Skip to content

Commit

Permalink
Mimic wxSystemAppearance::IsUsingDarkBackground() behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
vslavik committed Jan 31, 2024
1 parent cb07222 commit 4433ef7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/colorscheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ ColorScheme::Mode ColorScheme::GetAppMode()
#else
auto colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
auto colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
s_appMode = (colFg.GetLuminance() > colBg.GetLuminance()) ? Dark : Light;
s_appMode = (colFg.GetLuminance() - colBg.GetLuminance() > 0.2) ? Dark : Light;
#endif
s_appModeDetermined = true;
}
Expand All @@ -268,14 +268,16 @@ ColorScheme::Mode ColorScheme::GetAppMode()

ColorScheme::Mode ColorScheme::GetWindowMode(wxWindow *win)
{
// TODO: Migrate to using wxSystemAppearance. That is only app-wide, not per-window,
// but I don't think Poedit actually requires per-window handling.
#ifdef __WXOSX__
NSView *view = win->GetHandle();
return IsDarkAppearance(view.effectiveAppearance) ? Dark : Light;
#else
// Use dark scheme for very dark backgrounds:
auto colBg = win->GetDefaultAttributes().colBg;
auto colFg = win->GetDefaultAttributes().colFg;
return (colFg.GetLuminance() > colBg.GetLuminance()) ? Dark : Light;
return (colFg.GetLuminance() - colBg.GetLuminance() > 0.2) ? Dark : Light;
#endif
}

Expand Down

0 comments on commit 4433ef7

Please sign in to comment.