comparison system/System.cpp @ 1818:c5ee0746bdef background-mode

Determine whether a dark background is indicated
author Chris Cannam
date Fri, 17 Jan 2020 21:36:07 +0000
parents 85903b0e9b42
children 4eda6ba5b5d8
comparison
equal deleted inserted replaced
1817:23d5cb3f9f38 1818:c5ee0746bdef
23 #ifndef _WIN32 23 #ifndef _WIN32
24 #include <signal.h> 24 #include <signal.h>
25 #include <sys/statvfs.h> 25 #include <sys/statvfs.h>
26 #include <locale.h> 26 #include <locale.h>
27 #include <unistd.h> 27 #include <unistd.h>
28 #endif
29
30 #ifdef _MSC_VER
31 #include <winrt/Windows.UI.ViewManagement.h>
28 #endif 32 #endif
29 33
30 #ifdef __APPLE__ 34 #ifdef __APPLE__
31 #include <sys/param.h> 35 #include <sys/param.h>
32 #include <sys/sysctl.h> 36 #include <sys/sysctl.h>
332 } else { 336 } else {
333 setlocale(LC_ALL, startupLocale); 337 setlocale(LC_ALL, startupLocale);
334 } 338 }
335 } 339 }
336 340
341 bool
342 OSThemeIsDark()
343 {
344 SVCERR << "OSThemeIsDark() called" << endl;
345 #ifdef _MSC_VER
346 using namespace winrt::Windows::UI::ViewManagement;
347 UISettings settings;
348 auto background = settings.GetColorValue(UIColorType::Background);
349 if (int(background.R) + int(background.G) + int(background.B) < 384) {
350 return true;
351 }
352 #endif
353 return false;
354 }
355
337 double mod(double x, double y) { return x - (y * floor(x / y)); } 356 double mod(double x, double y) { return x - (y * floor(x / y)); }
338 float modf(float x, float y) { return x - (y * floorf(x / y)); } 357 float modf(float x, float y) { return x - (y * floorf(x / y)); }
339 358
340 double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; } 359 double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; }
341 float princargf(float a) { return float(princarg(a)); } 360 float princargf(float a) { return float(princarg(a)); }