Support for Windows dark mode and force option WIP

Use the new experimental wxWidgets API for dark mode on Windows. Also
add an option to force dark mode on all platforms.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2023-10-20 19:13:38 +00:00
parent 7e1afcd37c
commit 08665c36c6
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
8 changed files with 223 additions and 202 deletions

File diff suppressed because it is too large Load Diff

View File

@ -348,6 +348,7 @@ std::array<Option, kNbOptions>& Option::All() {
Option(OptionID::kUIAllowJoystickBackgroundInput, &g_owned_opts.allow_joystick_background_input), Option(OptionID::kUIAllowJoystickBackgroundInput, &g_owned_opts.allow_joystick_background_input),
Option(OptionID::kUIHideMenuBar, &gopts.hide_menu_bar), Option(OptionID::kUIHideMenuBar, &gopts.hide_menu_bar),
Option(OptionID::kUISuspendScreenSaver, &gopts.suspend_screensaver), Option(OptionID::kUISuspendScreenSaver, &gopts.suspend_screensaver),
Option(OptionID::kUIForceDarkMode, &gopts.force_dark_mode),
/// Sound /// Sound
Option(OptionID::kSoundAudioAPI, &gopts.audio_api), Option(OptionID::kSoundAudioAPI, &gopts.audio_api),

View File

@ -116,6 +116,7 @@ enum class OptionID {
kUIAllowJoystickBackgroundInput, kUIAllowJoystickBackgroundInput,
kUIHideMenuBar, kUIHideMenuBar,
kUISuspendScreenSaver, kUISuspendScreenSaver,
kUIForceDarkMode,
/// Sound /// Sound
kSoundAudioAPI, kSoundAudioAPI,

View File

@ -120,6 +120,7 @@ static constexpr std::array<Option::Type, kNbOptions> kOptionsTypes = {
/*kUIAllowJoystickBackgroundInput*/ Option::Type::kBool, /*kUIAllowJoystickBackgroundInput*/ Option::Type::kBool,
/*kUIHideMenuBar*/ Option::Type::kBool, /*kUIHideMenuBar*/ Option::Type::kBool,
/*kUISuspendScreenSaver*/ Option::Type::kBool, /*kUISuspendScreenSaver*/ Option::Type::kBool,
/*kUIForceDarkMode*/ Option::Type::kBool,
/// Sound /// Sound
/*kSoundAudioAPI*/ Option::Type::kAudioApi, /*kSoundAudioAPI*/ Option::Type::kAudioApi,

View File

@ -2622,6 +2622,7 @@ bool MainFrame::BindControls()
cb->Hide(); cb->Hide();
#endif // !HAVE_XSS #endif // !HAVE_XSS
} }
{ getcbb("ForceDarkMode", gopts.force_dark_mode); }
wxFilePickerCtrl* fp; wxFilePickerCtrl* fp;
#define getfp(n, o, l) \ #define getfp(n, o, l) \
do { \ do { \

View File

@ -72,6 +72,7 @@ extern struct opts_t {
/// UI Config /// UI Config
bool hide_menu_bar = true; bool hide_menu_bar = true;
bool suspend_screensaver = false; bool suspend_screensaver = false;
bool force_dark_mode = false;
/// wxWindows /// wxWindows
// wxWidgets-generated options (opaque) // wxWidgets-generated options (opaque)

View File

@ -434,6 +434,11 @@ bool wxvbamApp::OnInit() {
} }
#endif #endif
#if defined(__WXMSW__) && wxCHECK_VERSION(3, 2, 3)
if (wxSystemAppearance::IsSystemDark())
MSWEnableDarkMode();
#endif
// process command-line options // process command-line options
for (size_t i = 0; i < pending_optset.size(); i++) { for (size_t i = 0; i < pending_optset.size(); i++) {
auto parts = strutils::split(pending_optset[i], wxT('=')); auto parts = strutils::split(pending_optset[i], wxT('='));

View File

@ -18,6 +18,13 @@
<flag>wxALL</flag> <flag>wxALL</flag>
<border>5</border> <border>5</border>
</object> </object>
<object class="sizeritem">
<object class="wxCheckBox" name="ForceDarkMode">
<label>Force Dark Mode (requires restart)</label>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem"> <object class="sizeritem">
<flag>wxALL|wxEXPAND</flag> <flag>wxALL|wxEXPAND</flag>
<border>5</border> <border>5</border>