Add system theme detection on Windows/SDL2
This commit is contained in:
parent
cbb731f68c
commit
f539ddcc3f
1 changed files with 21 additions and 0 deletions
|
@ -8,6 +8,11 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_vulkan.h>
|
#include <SDL_vulkan.h>
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WINDOWS
|
||||||
|
#include <winrt/Windows.UI.ViewManagement.h>
|
||||||
|
#pragma comment(lib, "windowsapp")
|
||||||
|
#endif
|
||||||
|
|
||||||
@APP_CLASS@* app = nullptr;
|
@APP_CLASS@* app = nullptr;
|
||||||
GFX* gfx_interface = nullptr;
|
GFX* gfx_interface = nullptr;
|
||||||
|
|
||||||
|
@ -310,9 +315,25 @@ int main(int argc, char* argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WINDOWS
|
||||||
|
PlatformTheme platform::get_theme() {
|
||||||
|
using namespace winrt::Windows::UI::ViewManagement;
|
||||||
|
|
||||||
|
// TODO: figure out if this works pre-anniversary update/other windows other than 10
|
||||||
|
UISettings settings;
|
||||||
|
auto background = settings.GetColorValue(UIColorType::Background);
|
||||||
|
auto foreground = settings.GetColorValue(UIColorType::Foreground);
|
||||||
|
|
||||||
|
if (background == winrt::Windows::UI::Colors::White())
|
||||||
|
return PlatformTheme::Light;
|
||||||
|
else
|
||||||
|
return PlatformTheme::Dark;
|
||||||
|
}
|
||||||
|
#else
|
||||||
PlatformTheme platform::get_theme() {
|
PlatformTheme platform::get_theme() {
|
||||||
return PlatformTheme::Light;
|
return PlatformTheme::Light;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void* platform::create_native_surface(int index, void* instance) {
|
void* platform::create_native_surface(int index, void* instance) {
|
||||||
auto window = get_window(index);
|
auto window = get_window(index);
|
||||||
|
|
Reference in a new issue