From 26eac61ddfa80d27916220237efed1858f00abc9 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 23 May 2023 13:20:35 +0200 Subject: [PATCH] feat: Allow themes to set the background blur color --- main/source/window/win_window.cpp | 18 +++++++++--------- plugins/builtin/romfs/themes/classic.json | 1 + plugins/builtin/romfs/themes/dark.json | 1 + plugins/builtin/romfs/themes/light.json | 1 + plugins/builtin/source/content/themes.cpp | 3 ++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/main/source/window/win_window.cpp b/main/source/window/win_window.cpp index 0dc72ce7c..1ed2043c2 100644 --- a/main/source/window/win_window.cpp +++ b/main/source/window/win_window.cpp @@ -338,21 +338,21 @@ namespace hex { } struct ACCENTPOLICY { - int na; - int nf; - int nc; - int nA; + u32 accentState; + u32 accentFlags; + u32 gradientColor; + u32 animationId; }; struct WINCOMPATTRDATA { - int na; - PVOID pd; - ULONG ul; + int attribute; + PVOID pData; + ULONG dataSize; }; EventManager::subscribe([this]{ auto hwnd = glfwGetWin32Window(this->m_window); - const auto user32Dll = WinUniquePtr(LoadLibraryA("user32.dll"), FreeLibrary); + static auto user32Dll = WinUniquePtr(LoadLibraryA("user32.dll"), FreeLibrary); if (user32Dll != nullptr) { using SetWindowCompositionAttributeFunc = BOOL(WINAPI*)(HWND, WINCOMPATTRDATA*); @@ -362,7 +362,7 @@ namespace hex { GetProcAddress(user32Dll.get(), "SetWindowCompositionAttribute"); if (SetWindowCompositionAttribute != nullptr) { - ACCENTPOLICY policy = { ImGui::GetCustomStyle().WindowBlur > 0.5F ? 3 : 0, 0, 0, 0 }; + ACCENTPOLICY policy = { ImGui::GetCustomStyle().WindowBlur > 0.5F ? 4U : 0U, 0, ImGui::GetCustomColorU32(ImGuiCustomCol_BlurBackground), 0 }; WINCOMPATTRDATA data = { 19, &policy, sizeof(ACCENTPOLICY) }; SetWindowCompositionAttribute(hwnd, &data); } diff --git a/plugins/builtin/romfs/themes/classic.json b/plugins/builtin/romfs/themes/classic.json index 72ad2bca9..d63718a96 100644 --- a/plugins/builtin/romfs/themes/classic.json +++ b/plugins/builtin/romfs/themes/classic.json @@ -59,6 +59,7 @@ "window-background": "#000000FF" }, "imhex": { + "blur-background": "#00000000", "desc-button": "#282850FF", "desc-button-active": "#505078FF", "desc-button-hovered": "#3C3C64FF", diff --git a/plugins/builtin/romfs/themes/dark.json b/plugins/builtin/romfs/themes/dark.json index 86bfffabe..e8beea84f 100644 --- a/plugins/builtin/romfs/themes/dark.json +++ b/plugins/builtin/romfs/themes/dark.json @@ -59,6 +59,7 @@ "window-background": "#0F0F0FFF" }, "imhex": { + "blur-background": "#00000000", "desc-button": "#141414FF", "desc-button-active": "#3C3C3CFF", "desc-button-hovered": "#282828FF", diff --git a/plugins/builtin/romfs/themes/light.json b/plugins/builtin/romfs/themes/light.json index 46960347a..48a5041f5 100644 --- a/plugins/builtin/romfs/themes/light.json +++ b/plugins/builtin/romfs/themes/light.json @@ -59,6 +59,7 @@ "window-background": "#EFEFEFFF" }, "imhex": { + "blur-background": "#00000000", "desc-button": "#E6E6E6FF", "desc-button-active": "#BEBEBEFF", "desc-button-hovered": "#D2D2D2FF", diff --git a/plugins/builtin/source/content/themes.cpp b/plugins/builtin/source/content/themes.cpp index 7e56e442f..276d26d44 100644 --- a/plugins/builtin/source/content/themes.cpp +++ b/plugins/builtin/source/content/themes.cpp @@ -181,7 +181,8 @@ namespace hex::plugin::builtin { { "highlight", ImGuiCustomCol_Highlight }, { "IEEE-tool-sign", ImGuiCustomCol_IEEEToolSign }, { "IEEE-tool-exp", ImGuiCustomCol_IEEEToolExp }, - { "IEEE-tool-mantissa", ImGuiCustomCol_IEEEToolMantissa } + { "IEEE-tool-mantissa", ImGuiCustomCol_IEEEToolMantissa }, + { "blur-background", ImGuiCustomCol_BlurBackground } };