Mercurial > hg > svcore
changeset 1884:bdab3a921d5d
Merge
author | Chris Cannam |
---|---|
date | Tue, 21 Jul 2020 13:59:29 +0100 |
parents | e5d0ea9ac8f1 (diff) 38be2fa29efd (current diff) |
children | 1adbeb52d761 |
files | |
diffstat | 5 files changed, 74 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/files.pri Fri Jun 26 12:13:13 2020 +0100 +++ b/files.pri Tue Jul 21 13:59:29 2020 +0100 @@ -253,6 +253,7 @@ rdf/RDFTransformFactory.cpp \ system/Init.cpp \ system/System.cpp \ + system/os-other.cpp \ transform/CSVFeatureWriter.cpp \ transform/FeatureExtractionModelTransformer.cpp \ transform/FileFeatureWriter.cpp \
--- a/system/System.cpp Fri Jun 26 12:13:13 2020 +0100 +++ b/system/System.cpp Tue Jul 21 13:59:29 2020 +0100 @@ -27,12 +27,6 @@ #include <unistd.h> #endif -#ifndef AVOID_WINRT_DEPENDENCY -#ifdef _MSC_VER -#include <winrt/Windows.UI.ViewManagement.h> -#endif -#endif - #ifdef __APPLE__ #include <sys/param.h> #include <sys/sysctl.h> @@ -340,45 +334,6 @@ } } -bool -OSReportsDarkThemeActive() -{ -#ifndef AVOID_WINRT_DEPENDENCY -#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 -#endif - return false; -} - -bool -OSQueryAccentColour(int &r, int &g, int &b) -{ - SVCERR << "OSQueryAccentColour() called" << endl; -#ifndef AVOID_WINRT_DEPENDENCY -#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 -#endif - (void)r; - (void)g; - (void)b; - 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)); }
--- a/system/System.h Fri Jun 26 12:13:13 2020 +0100 +++ b/system/System.h Tue Jul 21 13:59:29 2020 +0100 @@ -163,6 +163,8 @@ // if unknown. (Hence signed return type) extern ssize_t GetDiscSpaceMBAvailable(const char *path); +extern "C" { + // 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. @@ -172,7 +174,9 @@ // 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 bool OSQueryAccentColour(int *r, int *g, int *b); + +} extern void StoreStartupLocale(); extern void RestoreStartupLocale();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/system/os-other.cpp Tue Jul 21 13:59:29 2020 +0100 @@ -0,0 +1,19 @@ + +extern "C" { + +bool +OSReportsDarkThemeActive() +{ + return false; +} + +bool +OSQueryAccentColour(int &r, int &g, int &b) +{ + (void)r; + (void)g; + (void)b; + return false; +} + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/system/os-win10.cpp Tue Jul 21 13:59:29 2020 +0100 @@ -0,0 +1,49 @@ + +#ifndef AVOID_WINRT_DEPENDENCY +#ifdef _MSC_VER +#include <winrt/Windows.UI.ViewManagement.h> +#endif +#endif + +extern "C" { + +bool +OSReportsDarkThemeActive() +{ +#ifndef AVOID_WINRT_DEPENDENCY +#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 +#endif + return false; +} + +bool +OSQueryAccentColour(int *r, int *g, int *b) +{ +#ifndef AVOID_WINRT_DEPENDENCY +#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 +#endif + (void)r; + (void)g; + (void)b; + return false; +} + +} +