diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 4b4cbc4cf..1b87c6d75 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -10,7 +10,7 @@ extern ApplicationExeCustomization exe_customization = { "Wicked Editor ", wi::Color(130, 210, 220, 255), - wi::Color::Black() + wi::Color(17, 30, 43, 255) }; using namespace wi::graphics; @@ -301,7 +301,8 @@ void Editor::Initialize() wi::font::AddFontStyle(config.GetText("font")); } - wi::backlog::setFontColor(exe_customization.backlog_color); + wi::backlog::setFontColor(exe_customization.font_color); + wi::backlog::setBackgroundColor(exe_customization.background_color); XMFLOAT4 clearcol = exe_customization.background_color; swapChain.desc.clear_color[0] = clearcol.x; swapChain.desc.clear_color[1] = clearcol.y; @@ -434,7 +435,7 @@ void EditorComponent::ResizeLayout() contentBrowserWnd.SetSize(XMFLOAT2(screenW / 1.6f, screenH / 1.2f)); contentBrowserWnd.SetPos(XMFLOAT2(screenW / 2.0f - contentBrowserWnd.scale.x / 2.0f, screenH / 2.0f - contentBrowserWnd.scale.y / 2.0f)); - projectCreatorWnd.SetSize(XMFLOAT2(projectCreatorWnd.backgroundColorPicker.GetSize().x * 2 + 4 * 3, 780)); + projectCreatorWnd.SetSize(XMFLOAT2(projectCreatorWnd.backgroundColorPicker.GetSize().x * 2 + 4 * 3, std::min(780.0f, screenH * 0.8f))); projectCreatorWnd.SetPos(XMFLOAT2(screenW / 2.0f - projectCreatorWnd.scale.x / 2.0f, screenH / 2.0f - projectCreatorWnd.scale.y / 2.0f)); } diff --git a/Editor/Editor.h b/Editor/Editor.h index 8467f46e3..590c2652b 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -294,8 +294,8 @@ static_assert(arraysize(EditorLocalizationStrings) == size_t(EditorLocalization: struct ApplicationExeCustomization { - char name_256padded[256] = {}; - wi::Color backlog_color = wi::Color(130, 210, 220, 255); // color of backlog font (startup text) - wi::Color background_color = wi::Color(114, 170, 229); // color of startup background behind startup text + char name_256padded[256]; + wi::Color font_color; // color of backlog font (startup text) + wi::Color background_color; // color of startup background behind startup text }; extern ApplicationExeCustomization exe_customization; diff --git a/Editor/ProjectCreatorWindow.cpp b/Editor/ProjectCreatorWindow.cpp index 47ea7b7df..bf91b10bf 100644 --- a/Editor/ProjectCreatorWindow.cpp +++ b/Editor/ProjectCreatorWindow.cpp @@ -166,10 +166,10 @@ void ProjectCreatorWindow::Create(EditorComponent* _editor) }); AddWidget(&cursorButton); - backlogColorPicker.Create("backlog color", wi::gui::Window::WindowControls::NONE); - backlogColorPicker.SetSize(XMFLOAT2(256, 256)); - backlogColorPicker.SetPickColor(exe_customization.backlog_color); - AddWidget(&backlogColorPicker); + fontColorPicker.Create("font color", wi::gui::Window::WindowControls::NONE); + fontColorPicker.SetSize(XMFLOAT2(256, 256)); + fontColorPicker.SetPickColor(exe_customization.font_color); + AddWidget(&fontColorPicker); backgroundColorPicker.Create("background color", wi::gui::Window::WindowControls::NONE); backgroundColorPicker.SetSize(XMFLOAT2(256, 256)); @@ -180,7 +180,7 @@ void ProjectCreatorWindow::Create(EditorComponent* _editor) colorPreviewButton.SetText("Preview: these colors will be used by the application when showing the initialization screen and backlog text. [Click here to reset colors]"); colorPreviewButton.SetSize(XMFLOAT2(256, 64)); colorPreviewButton.OnClick([this](wi::gui::EventArgs args) { - backlogColorPicker.SetPickColor(exe_customization.backlog_color); + fontColorPicker.SetPickColor(exe_customization.font_color); backgroundColorPicker.SetPickColor(exe_customization.background_color); }); AddWidget(&colorPreviewButton); @@ -329,7 +329,7 @@ end) wi::vector replacement(sizeof(ApplicationExeCustomization)); ApplicationExeCustomization& customization = *(ApplicationExeCustomization*)replacement.data(); std::memcpy(customization.name_256padded, name.c_str(), name.length()); - customization.backlog_color = backlogColorPicker.GetPickColor(); + customization.font_color = fontColorPicker.GetPickColor(); customization.background_color = backgroundColorPicker.GetPickColor(); std::copy(replacement.begin(), replacement.end(), it); wilog("\tOverwritten ApplicationExeCustomization structure"); @@ -477,7 +477,7 @@ void ProjectCreatorWindow::ResizeLayout() layout.jump(); layout.add_fullwidth(colorPreviewButton); - layout.add(backlogColorPicker, backgroundColorPicker); + layout.add(fontColorPicker, backgroundColorPicker); layout.jump(); @@ -486,7 +486,7 @@ void ProjectCreatorWindow::ResizeLayout() createButton.SetSize(XMFLOAT2(createButton.GetSize().x, std::max(30.0f, layout.height - createButton.GetPos().y - layout.padding * 2))); colorPreviewButton.SetColor(backgroundColorPicker.GetPickColor()); - colorPreviewButton.font.params.color = backlogColorPicker.GetPickColor(); + colorPreviewButton.font.params.color = fontColorPicker.GetPickColor(); colorPreviewButton.font.params.v_align = wi::font::WIFALIGN_TOP; colorPreviewButton.font.params.h_align = wi::font::WIFALIGN_LEFT; colorPreviewButton.font.params.h_wrap = colorPreviewButton.GetSize().x; diff --git a/Editor/ProjectCreatorWindow.h b/Editor/ProjectCreatorWindow.h index d515bc5df..6ae8e1880 100644 --- a/Editor/ProjectCreatorWindow.h +++ b/Editor/ProjectCreatorWindow.h @@ -17,7 +17,7 @@ public: wi::gui::Label cursorLabel; wi::gui::Button cursorButton; - wi::gui::ColorPicker backlogColorPicker; + wi::gui::ColorPicker fontColorPicker; wi::gui::ColorPicker backgroundColorPicker; wi::gui::Button colorPreviewButton; diff --git a/Editor/main_Windows.cpp b/Editor/main_Windows.cpp index be27316da..e7df61d9c 100644 --- a/Editor/main_Windows.cpp +++ b/Editor/main_Windows.cpp @@ -2,6 +2,9 @@ #include #include // drag n drop +#include // DwmSetWindowAttribute + +#pragma comment(lib, "dwmapi.lib") Editor editor; @@ -103,6 +106,21 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, break; } break; + case WM_SETTINGCHANGE: + { + // Change window theme dark mode based on system setting: + HKEY hKey; + DWORD value = 1; // Default to light mode (1 = light, 0 = dark) + DWORD dataSize = sizeof(value); + if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + RegQueryValueEx(hKey, L"AppsUseLightTheme", NULL, NULL, (LPBYTE)&value, &dataSize); + RegCloseKey(hKey); + } + BOOL darkmode = value == 0; + DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkmode, sizeof(darkmode)); + } + break; default: return DefWindowProc(hWnd, message, wParam, lParam); } @@ -195,6 +213,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, height = info.rcMonitor.bottom - info.rcMonitor.top; MoveWindow(hWnd, 0, 0, width, height, FALSE); } + SendMessage(hWnd, WM_SETTINGCHANGE, 0, 0); // trigger dark mode theme detection ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); DragAcceptFiles(hWnd, TRUE); diff --git a/WickedEngine/wiBacklog.cpp b/WickedEngine/wiBacklog.cpp index b398f502f..ebc5e771c 100644 --- a/WickedEngine/wiBacklog.cpp +++ b/WickedEngine/wiBacklog.cpp @@ -29,6 +29,7 @@ namespace wi::backlog float scroll = 0; int historyPos = 0; wi::font::Params font_params; + wi::Color backgroundColor = wi::Color(17, 30, 43, 255); Texture backgroundTex; bool refitscroll = false; wi::gui::TextInputField inputField; @@ -222,21 +223,15 @@ namespace wi::backlog GraphicsDevice* device = GetDevice(); device->EventBegin("Backlog", cmd); - if (!backgroundTex.IsValid()) - { - const uint8_t colorData[] = { 0, 0, 43, 200, 43, 31, 141, 223 }; - wi::texturehelper::CreateTexture(backgroundTex, colorData, 1, 2); - device->SetName(&backgroundTex, "wi::backlog::backgroundTex"); - } - wi::image::Params fx = wi::image::Params((float)canvas.GetLogicalWidth(), (float)canvas.GetLogicalHeight()); fx.pos = XMFLOAT3(0, pos, 0); - fx.opacity = wi::math::Lerp(1, 0, -pos / canvas.GetLogicalHeight()); + fx.opacity = wi::math::Lerp(0.9f, 0, saturate(-pos / canvas.GetLogicalHeight())); if (colorspace != ColorSpace::SRGB) { fx.enableLinearOutputMapping(9); } - wi::image::Draw(&backgroundTex, fx, cmd); + fx.color = backgroundColor; + wi::image::Draw(backgroundTex.IsValid() ? &backgroundTex : nullptr, fx, cmd); wi::image::Params inputbg; inputbg.color = wi::Color(80, 140, 180, 200); @@ -452,6 +447,10 @@ namespace wi::backlog { backgroundTex = *texture; } + void setBackgroundColor(wi::Color color) + { + backgroundColor = color; + } void setFontSize(int value) { font_params.size = value; diff --git a/WickedEngine/wiBacklog.h b/WickedEngine/wiBacklog.h index 2a6fd673f..1e558c833 100644 --- a/WickedEngine/wiBacklog.h +++ b/WickedEngine/wiBacklog.h @@ -50,6 +50,7 @@ namespace wi::backlog bool isActive(); void setBackground(wi::graphics::Texture* texture); + void setBackgroundColor(wi::Color color); void setFontSize(int value); void setFontRowspacing(float value); void setFontColor(wi::Color color);