From 09f1b56964a8553689e6d4660f27a454ed4ba869 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 9 Apr 2023 15:28:48 +0200 Subject: [PATCH] fix: Popups not being centered correctly --- main/source/window/window.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index 738a14051..243484e54 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -538,18 +538,23 @@ namespace hex { bool open = true; ImGui::SetNextWindowSizeConstraints(currPopup->getMinSize(), currPopup->getMaxSize()); - auto closeButton = currPopup->hasCloseButton() ? &open : nullptr; - auto flags = currPopup->getFlags(); + const auto closeButton = currPopup->hasCloseButton() ? &open : nullptr; + const auto flags = currPopup->getFlags(); + + const auto windowSize = ImHexApi::System::getMainWindowSize(); - ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5F, 0.5F)); if (currPopup->isModal()) { if (ImGui::BeginPopupModal(name, closeButton, flags)) { + ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing); + currPopup->drawContent(); ImGui::EndPopup(); } } else { if (ImGui::BeginPopup(name, flags)) { + ImGui::SetWindowPos((windowSize - ImGui::GetWindowSize()) / 2, ImGuiCond_Appearing); + currPopup->drawContent(); ImGui::EndPopup();