comparison system/System.cpp @ 1822:0bc6caf87658

Merge from branch background-mode
author Chris Cannam
date Fri, 24 Jan 2020 15:10:35 +0000
parents 472865574b1a
children 029d7d3f0a3a
comparison
equal deleted inserted replaced
1817:23d5cb3f9f38 1822:0bc6caf87658
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 OSReportsDarkThemeActive()
343 {
344 SVCERR << "OSReportsDarkThemeActive() 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
356 bool
357 OSQueryAccentColour(int &r, int &g, int &b)
358 {
359 SVCERR << "OSQueryAccentColour() called" << endl;
360 #ifdef _MSC_VER
361 using namespace winrt::Windows::UI::ViewManagement;
362 bool dark = OSReportsDarkThemeActive();
363 UISettings settings;
364 auto accent = settings.GetColorValue
365 (dark ? UIColorType::AccentLight1 : UIColorType::Accent);
366 r = accent.R;
367 g = accent.G;
368 b = accent.B;
369 return true;
370 #endif
371 return false;
372 }
373
337 double mod(double x, double y) { return x - (y * floor(x / y)); } 374 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)); } 375 float modf(float x, float y) { return x - (y * floorf(x / y)); }
339 376
340 double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; } 377 double princarg(double a) { return mod(a + M_PI, -2 * M_PI) + M_PI; }
341 float princargf(float a) { return float(princarg(a)); } 378 float princargf(float a) { return float(princarg(a)); }