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::kUIHideMenuBar, &gopts.hide_menu_bar),
Option(OptionID::kUISuspendScreenSaver, &gopts.suspend_screensaver),
Option(OptionID::kUIForceDarkMode, &gopts.force_dark_mode),
/// Sound
Option(OptionID::kSoundAudioAPI, &gopts.audio_api),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,6 +18,13 @@
<flag>wxALL</flag>
<border>5</border>
</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">
<flag>wxALL|wxEXPAND</flag>
<border>5</border>