1
0
mirror of synced 2025-01-18 17:14:13 +01:00

fix: Popups not being centered correctly

This commit is contained in:
WerWolv 2023-04-09 15:28:48 +02:00
parent f9a08f5c11
commit 09f1b56964

View File

@ -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();