From 7538bbabb62da3105b62ca596827407f638c2e27 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 23 Jun 2020 19:01:40 +0200 Subject: [PATCH] Demo: Commented out ideas on another way to center a window. --- imgui_demo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index c6dec7a25..b43f5981c 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2923,8 +2923,11 @@ static void ShowDemoWindowPopups() ImGui::OpenPopup("Delete?"); // Always center this window when appearing - ImGuiViewport* viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); + ImVec2 center = ImGui::GetMainViewport()->GetCenter(); + //ImVec2 parent_pos = ImGui::GetWindowPos(); + //ImVec2 parent_size = ImGui::GetWindowSize(); + //ImVec2 center(parent_pos.x + parent_size.x * 0.5f, parent_pos.y + parent_size.y * 0.5f); + ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {