comparison 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
comparison
equal deleted inserted replaced
1880:5671836cdac7 1883:e5d0ea9ac8f1
1
2 #ifndef AVOID_WINRT_DEPENDENCY
3 #ifdef _MSC_VER
4 #include <winrt/Windows.UI.ViewManagement.h>
5 #endif
6 #endif
7
8 extern "C" {
9
10 bool
11 OSReportsDarkThemeActive()
12 {
13 #ifndef AVOID_WINRT_DEPENDENCY
14 #ifdef _MSC_VER
15 using namespace winrt::Windows::UI::ViewManagement;
16 UISettings settings;
17 auto background = settings.GetColorValue(UIColorType::Background);
18 if (int(background.R) + int(background.G) + int(background.B) < 384) {
19 return true;
20 }
21 #endif
22 #endif
23 return false;
24 }
25
26 bool
27 OSQueryAccentColour(int *r, int *g, int *b)
28 {
29 #ifndef AVOID_WINRT_DEPENDENCY
30 #ifdef _MSC_VER
31 using namespace winrt::Windows::UI::ViewManagement;
32 bool dark = OSReportsDarkThemeActive();
33 UISettings settings;
34 auto accent = settings.GetColorValue
35 (dark ? UIColorType::AccentLight1 : UIColorType::Accent);
36 *r = accent.R;
37 *g = accent.G;
38 *b = accent.B;
39 return true;
40 #endif
41 #endif
42 (void)r;
43 (void)g;
44 (void)b;
45 return false;
46 }
47
48 }
49