From c1abbfad7dd657aa348f18d0aa0052ce84f6c95b Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 18 Dec 2023 10:14:07 +0100 Subject: [PATCH] impr: Make sure welcome screen stays at the back --- lib/libimhex/source/api/tutorial_manager.cpp | 2 +- main/gui/source/window/win_window.cpp | 2 +- main/gui/source/window/window.cpp | 4 ++-- plugins/builtin/source/content/ui_items.cpp | 4 ++-- plugins/builtin/source/content/views/view_achievements.cpp | 2 +- plugins/builtin/source/content/views/view_tools.cpp | 2 +- plugins/builtin/source/content/welcome_screen.cpp | 6 ++++-- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/libimhex/source/api/tutorial_manager.cpp b/lib/libimhex/source/api/tutorial_manager.cpp index f5d54a0d8..1024abda3 100644 --- a/lib/libimhex/source/api/tutorial_manager.cpp +++ b/lib/libimhex/source/api/tutorial_manager.cpp @@ -163,7 +163,7 @@ namespace hex { ImGui::SetNextWindowPos(position, ImGuiCond_Always, pivot); if (ImGui::Begin("##TutorialMessage", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing)) { - ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow()); + ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindowRead()); if (!message->unlocalizedTitle.empty()) ImGuiExt::Header(Lang(message->unlocalizedTitle), true); diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index b5f0ede16..3e36a479c 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -402,7 +402,7 @@ namespace hex { } void Window::beginNativeWindowFrame() { - g_titleBarHeight = ImGui::GetCurrentWindow()->MenuBarHeight(); + g_titleBarHeight = ImGui::GetCurrentWindowRead()->MenuBarHeight(); } void Window::endNativeWindowFrame() { diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 5577d7ba4..2e639647a 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -255,7 +255,7 @@ namespace hex { } void Window::drawTitleBar() const { - auto titleBarHeight = ImGui::GetCurrentWindow()->MenuBarHeight(); + auto titleBarHeight = ImGui::GetCurrentWindowRead()->MenuBarHeight(); auto buttonSize = ImVec2(titleBarHeight * 1.5F, titleBarHeight - 1); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); @@ -383,7 +383,7 @@ namespace hex { } }(); - const auto menuBarHeight = ImGui::GetCurrentWindow()->MenuBarHeight(); + const auto menuBarHeight = ImGui::GetCurrentWindowRead()->MenuBarHeight(); auto sidebarPos = ImGui::GetCursorPos(); auto sidebarWidth = shouldDrawSidebar ? 20_scaled : 0; diff --git a/plugins/builtin/source/content/ui_items.cpp b/plugins/builtin/source/content/ui_items.cpp index ecffad16b..25f8aa322 100644 --- a/plugins/builtin/source/content/ui_items.cpp +++ b/plugins/builtin/source/content/ui_items.cpp @@ -95,13 +95,13 @@ namespace hex::plugin::builtin { { ImGuiExt::TextSpinner(hex::format("({})", taskCount).c_str()); ImGui::SameLine(); - ImGuiExt::SmallProgressBar(progress, (ImGui::GetCurrentWindow()->MenuBarHeight() - 10_scaled) / 2.0); + ImGuiExt::SmallProgressBar(progress, (ImGui::GetCurrentWindowRead()->MenuBarHeight() - 10_scaled) / 2.0); ImGui::SameLine(); } const auto widgetEnd = ImGui::GetCursorPos(); ImGui::SetCursorPos(widgetStart); - ImGui::InvisibleButton("FrontTask", ImVec2(widgetEnd.x - widgetStart.x, ImGui::GetCurrentWindow()->MenuBarHeight())); + ImGui::InvisibleButton("FrontTask", ImVec2(widgetEnd.x - widgetStart.x, ImGui::GetCurrentWindowRead()->MenuBarHeight())); ImGui::SetCursorPos(widgetEnd); ImGuiExt::InfoTooltip(hex::format("[{:.1f}%] {}", progress * 100.0F, Lang(frontTask->getUnlocalizedName())).c_str()); diff --git a/plugins/builtin/source/content/views/view_achievements.cpp b/plugins/builtin/source/content/views/view_achievements.cpp index a4c5c8983..4bba67409 100644 --- a/plugins/builtin/source/content/views/view_achievements.cpp +++ b/plugins/builtin/source/content/views/view_achievements.cpp @@ -414,7 +414,7 @@ namespace hex::plugin::builtin { ImGui::SetNextWindowPos(ImHexApi::System::getMainWindowPosition() + ImVec2 { ImHexApi::System::getMainWindowSize().x - windowSize.x - 100_scaled, 0 }); ImGui::SetNextWindowSize(windowSize); if (ImGui::Begin("##achievement_unlocked", nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoInputs)) { - ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow()); + ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindowRead()); // Draw unlock text ImGuiExt::TextFormattedColored(ImGuiExt::GetCustomColorVec4(ImGuiCustomCol_AchievementUnlocked), "{}", "hex.builtin.view.achievements.unlocked"_lang); diff --git a/plugins/builtin/source/content/views/view_tools.cpp b/plugins/builtin/source/content/views/view_tools.cpp index ba74c80ed..f2b1ed523 100644 --- a/plugins/builtin/source/content/views/view_tools.cpp +++ b/plugins/builtin/source/content/views/view_tools.cpp @@ -66,7 +66,7 @@ namespace hex::plugin::builtin { this->m_dragStartIterator = tools.end(); // Attach the newly created window to the cursor, so it gets dragged around - GImGui->MovingWindow = ImGui::GetCurrentWindow(); + GImGui->MovingWindow = ImGui::GetCurrentWindowRead(); GImGui->ActiveId = GImGui->MovingWindow->MoveId; } } diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index 3482284fa..f80aa227f 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -383,7 +383,7 @@ namespace hex::plugin::builtin { if (ImGui::Begin("ImHexDockSpace")) { if (!ImHexApi::Provider::isValid()) { static std::array title; - ImFormatString(title.data(), title.size(), "%s/DockSpace_%08X", ImGui::GetCurrentWindow()->Name, ImGui::GetID("ImHexMainDock")); + ImFormatString(title.data(), title.size(), "%s/DockSpace_%08X", ImGui::GetCurrentWindowRead()->Name, ImGui::GetID("ImHexMainDock")); if (ImGui::Begin(title.data(), nullptr, ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoBringToFrontOnFocus)) { ImGui::Dummy({}); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, scaled({ 10, 10 })); @@ -392,6 +392,7 @@ namespace hex::plugin::builtin { ImGui::SetNextWindowSize(ImGui::GetContentRegionAvail() + scaled({ 0, 10 })); ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos() - ImVec2(0, ImGui::GetStyle().FramePadding.y + 2_scaled)); if (ImGui::Begin("Welcome Screen", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) { + ImGui::BringWindowToDisplayBack(ImGui::GetCurrentWindowRead()); if (s_simplifiedWelcomeScreen) drawWelcomeScreenContentSimplified(); else @@ -421,6 +422,7 @@ namespace hex::plugin::builtin { ImGui::PopStyleVar(); } ImGui::End(); + ImGui::BringWindowToDisplayBack(ImGui::GetCurrentWindowRead()); } } ImGui::End(); @@ -432,7 +434,7 @@ namespace hex::plugin::builtin { void drawNoViewsBackground() { if (ImGui::Begin("ImHexDockSpace")) { static std::array title; - ImFormatString(title.data(), title.size(), "%s/DockSpace_%08X", ImGui::GetCurrentWindow()->Name, ImGui::GetID("ImHexMainDock")); + ImFormatString(title.data(), title.size(), "%s/DockSpace_%08X", ImGui::GetCurrentWindowRead()->Name, ImGui::GetID("ImHexMainDock")); if (ImGui::Begin(title.data())) { ImGui::Dummy({}); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, scaled({ 10, 10 }));