comparison system/System.cpp @ 1825:029d7d3f0a3a

Add option to avoid pulling in the WinRT dependency for this very small feature
author Chris Cannam
date Fri, 06 Mar 2020 12:12:46 +0000
parents 472865574b1a
children a4dce53b3353
comparison
equal deleted inserted replaced
1824:1cd161242250 1825:029d7d3f0a3a
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 28 #endif
29 29
30 #ifndef AVOID_WINRT_DEPENDENCY
30 #ifdef _MSC_VER 31 #ifdef _MSC_VER
31 #include <winrt/Windows.UI.ViewManagement.h> 32 #include <winrt/Windows.UI.ViewManagement.h>
33 #endif
32 #endif 34 #endif
33 35
34 #ifdef __APPLE__ 36 #ifdef __APPLE__
35 #include <sys/param.h> 37 #include <sys/param.h>
36 #include <sys/sysctl.h> 38 #include <sys/sysctl.h>
340 342
341 bool 343 bool
342 OSReportsDarkThemeActive() 344 OSReportsDarkThemeActive()
343 { 345 {
344 SVCERR << "OSReportsDarkThemeActive() called" << endl; 346 SVCERR << "OSReportsDarkThemeActive() called" << endl;
347 #ifndef AVOID_WINRT_DEPENDENCY
345 #ifdef _MSC_VER 348 #ifdef _MSC_VER
346 using namespace winrt::Windows::UI::ViewManagement; 349 using namespace winrt::Windows::UI::ViewManagement;
347 UISettings settings; 350 UISettings settings;
348 auto background = settings.GetColorValue(UIColorType::Background); 351 auto background = settings.GetColorValue(UIColorType::Background);
349 if (int(background.R) + int(background.G) + int(background.B) < 384) { 352 if (int(background.R) + int(background.G) + int(background.B) < 384) {
350 return true; 353 return true;
351 } 354 }
352 #endif 355 #endif
356 #endif
353 return false; 357 return false;
354 } 358 }
355 359
356 bool 360 bool
357 OSQueryAccentColour(int &r, int &g, int &b) 361 OSQueryAccentColour(int &r, int &g, int &b)
358 { 362 {
359 SVCERR << "OSQueryAccentColour() called" << endl; 363 SVCERR << "OSQueryAccentColour() called" << endl;
364 #ifndef AVOID_WINRT_DEPENDENCY
360 #ifdef _MSC_VER 365 #ifdef _MSC_VER
361 using namespace winrt::Windows::UI::ViewManagement; 366 using namespace winrt::Windows::UI::ViewManagement;
362 bool dark = OSReportsDarkThemeActive(); 367 bool dark = OSReportsDarkThemeActive();
363 UISettings settings; 368 UISettings settings;
364 auto accent = settings.GetColorValue 369 auto accent = settings.GetColorValue
366 r = accent.R; 371 r = accent.R;
367 g = accent.G; 372 g = accent.G;
368 b = accent.B; 373 b = accent.B;
369 return true; 374 return true;
370 #endif 375 #endif
376 #endif
371 return false; 377 return false;
372 } 378 }
373 379
374 double mod(double x, double y) { return x - (y * floor(x / y)); } 380 double mod(double x, double y) { return x - (y * floor(x / y)); }
375 float modf(float x, float y) { return x - (y * floorf(x / y)); } 381 float modf(float x, float y) { return x - (y * floorf(x / y)); }