mirror of
https://github.com/glfw/glfw.git
synced 2025-04-08 18:02:03 +00:00
Add a function to get the system accent color
This commit is contained in:
parent
c6b0894c57
commit
14d3920f6a
@ -42,8 +42,12 @@
|
|||||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void applySystemTheme(HWND handle) {
|
// Apply the system default theme
|
||||||
if (_glfw.win32.uxtheme.uxThemeAvailable && _glfw.win32.uxtheme.darkTitleAvailable) {
|
//
|
||||||
|
static void applySystemTheme(HWND handle)
|
||||||
|
{
|
||||||
|
if (_glfw.win32.uxtheme.uxThemeAvailable && _glfw.win32.uxtheme.darkTitleAvailable)
|
||||||
|
{
|
||||||
GLFWbool value = _glfw.win32.uxtheme.ShouldAppsUseDarkMode() & 0x1;
|
GLFWbool value = _glfw.win32.uxtheme.ShouldAppsUseDarkMode() & 0x1;
|
||||||
DwmSetWindowAttribute(handle,
|
DwmSetWindowAttribute(handle,
|
||||||
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||||
@ -52,6 +56,27 @@ static void applySystemTheme(HWND handle) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void getAccentColor(float color[4])
|
||||||
|
{
|
||||||
|
if (!_glfw.win32.uxtheme.uxThemeAvailable)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT dwImmersiveColorType = _glfw.win32.uxtheme.GetImmersiveColorTypeFromName(L"ImmersiveSystemAccent");
|
||||||
|
UINT dwImmersiveColorSet = _glfw.win32.uxtheme.GetImmersiveUserColorSetPreference(FALSE, FALSE);
|
||||||
|
|
||||||
|
UINT rgba = _glfw.win32.uxtheme.GetImmersiveColorFromColorSetEx(dwImmersiveColorSet,
|
||||||
|
dwImmersiveColorType,
|
||||||
|
FALSE,
|
||||||
|
0);
|
||||||
|
|
||||||
|
color[0] = (0xFF & rgba);
|
||||||
|
color[1] = ((0xFF00 & rgba) >> 8) ;
|
||||||
|
color[2] = ((0xFF0000 & rgba) >> 16);
|
||||||
|
color[3] = ((0xFF000000 & rgba) >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the window style for the specified window
|
// Returns the window style for the specified window
|
||||||
//
|
//
|
||||||
static DWORD getWindowStyle(const _GLFWwindow* window)
|
static DWORD getWindowStyle(const _GLFWwindow* window)
|
||||||
@ -1458,9 +1483,8 @@ static int createNativeWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
_glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height);
|
_glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height);
|
||||||
|
|
||||||
if (window->theme.variation == GLFW_THEME_DEFAULT) {
|
// Use the system default when creating a window
|
||||||
applySystemTheme(window->win32.handle);
|
applySystemTheme(window->win32.handle);
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
@ -2422,10 +2446,14 @@ _GLFWtheme* _glfwGetThemeWin32(_GLFWwindow* window)
|
|||||||
theme->variation = GLFW_THEME_LIGHT;
|
theme->variation = GLFW_THEME_LIGHT;
|
||||||
theme->flags = 0;
|
theme->flags = 0;
|
||||||
|
|
||||||
if (_glfw.win32.uxtheme.uxThemeAvailable && _glfw.win32.uxtheme.darkTitleAvailable) {
|
if (_glfw.win32.uxtheme.uxThemeAvailable && _glfw.win32.uxtheme.darkTitleAvailable)
|
||||||
|
{
|
||||||
theme->variation = GLFW_THEME_DARK;
|
theme->variation = GLFW_THEME_DARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(theme->color, 0, sizeof(float) * 4);
|
||||||
|
getAccentColor(theme->color);
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user