annotate system/os-win10.cpp @ 1883:e5d0ea9ac8f1

OK I give in, we are going to have to put this in a separate DLL so we can deploy a version on Win7 that doesn't have the WinRT dependency
author Chris Cannam
date Tue, 21 Jul 2020 13:59:14 +0100
parents
children
rev   line source
Chris@1883 1
Chris@1883 2 #ifndef AVOID_WINRT_DEPENDENCY
Chris@1883 3 #ifdef _MSC_VER
Chris@1883 4 #include <winrt/Windows.UI.ViewManagement.h>
Chris@1883 5 #endif
Chris@1883 6 #endif
Chris@1883 7
Chris@1883 8 extern "C" {
Chris@1883 9
Chris@1883 10 bool
Chris@1883 11 OSReportsDarkThemeActive()
Chris@1883 12 {
Chris@1883 13 #ifndef AVOID_WINRT_DEPENDENCY
Chris@1883 14 #ifdef _MSC_VER
Chris@1883 15 using namespace winrt::Windows::UI::ViewManagement;
Chris@1883 16 UISettings settings;
Chris@1883 17 auto background = settings.GetColorValue(UIColorType::Background);
Chris@1883 18 if (int(background.R) + int(background.G) + int(background.B) < 384) {
Chris@1883 19 return true;
Chris@1883 20 }
Chris@1883 21 #endif
Chris@1883 22 #endif
Chris@1883 23 return false;
Chris@1883 24 }
Chris@1883 25
Chris@1883 26 bool
Chris@1883 27 OSQueryAccentColour(int *r, int *g, int *b)
Chris@1883 28 {
Chris@1883 29 #ifndef AVOID_WINRT_DEPENDENCY
Chris@1883 30 #ifdef _MSC_VER
Chris@1883 31 using namespace winrt::Windows::UI::ViewManagement;
Chris@1883 32 bool dark = OSReportsDarkThemeActive();
Chris@1883 33 UISettings settings;
Chris@1883 34 auto accent = settings.GetColorValue
Chris@1883 35 (dark ? UIColorType::AccentLight1 : UIColorType::Accent);
Chris@1883 36 *r = accent.R;
Chris@1883 37 *g = accent.G;
Chris@1883 38 *b = accent.B;
Chris@1883 39 return true;
Chris@1883 40 #endif
Chris@1883 41 #endif
Chris@1883 42 (void)r;
Chris@1883 43 (void)g;
Chris@1883 44 (void)b;
Chris@1883 45 return false;
Chris@1883 46 }
Chris@1883 47
Chris@1883 48 }
Chris@1883 49