# HG changeset patch # User Chris Cannam # Date 1579878635 0 # Node ID 0bc6caf87658eb1e4b00a1b0511c1e9b7b7e5560 # Parent 23d5cb3f9f381c859df8253f62a0bbd0065b8408# Parent 472865574b1ab51dfb752e635dc8d7acd4747332 Merge from branch background-mode diff -r 23d5cb3f9f38 -r 0bc6caf87658 system/System.cpp --- a/system/System.cpp Tue Jan 14 15:48:22 2020 +0000 +++ b/system/System.cpp Fri Jan 24 15:10:35 2020 +0000 @@ -27,6 +27,10 @@ #include #endif +#ifdef _MSC_VER +#include +#endif + #ifdef __APPLE__ #include #include @@ -334,6 +338,39 @@ } } +bool +OSReportsDarkThemeActive() +{ + SVCERR << "OSReportsDarkThemeActive() called" << endl; +#ifdef _MSC_VER + using namespace winrt::Windows::UI::ViewManagement; + UISettings settings; + auto background = settings.GetColorValue(UIColorType::Background); + if (int(background.R) + int(background.G) + int(background.B) < 384) { + return true; + } +#endif + return false; +} + +bool +OSQueryAccentColour(int &r, int &g, int &b) +{ + SVCERR << "OSQueryAccentColour() called" << endl; +#ifdef _MSC_VER + using namespace winrt::Windows::UI::ViewManagement; + bool dark = OSReportsDarkThemeActive(); + UISettings settings; + auto accent = settings.GetColorValue + (dark ? UIColorType::AccentLight1 : UIColorType::Accent); + r = accent.R; + g = accent.G; + b = accent.B; + return true; +#endif + return false; +} + double mod(double x, double y) { return x - (y * floor(x / y)); } float modf(float x, float y) { return x - (y * floorf(x / y)); } diff -r 23d5cb3f9f38 -r 0bc6caf87658 system/System.h --- a/system/System.h Tue Jan 14 15:48:22 2020 +0000 +++ b/system/System.h Fri Jan 24 15:10:35 2020 +0000 @@ -163,6 +163,17 @@ // if unknown. (Hence signed return type) extern ssize_t GetDiscSpaceMBAvailable(const char *path); +// Return true if the OS desktop is set to use a dark mode +// theme. Return false if it is set to a light theme or if the theme +// is unknown. +extern bool OSReportsDarkThemeActive(); + +// Return true if the OS desktop reports an accent colour to go with +// the current theme; if so, also return by reference the r, g, and b +// components of the colour (range 0-255). Return false if we can't +// query such a thing. +extern bool OSQueryAccentColour(int &r, int &g, int &b); + extern void StoreStartupLocale(); extern void RestoreStartupLocale();