ClosePopupsOverWindow(): amend to remove _ChildWindow test.

Said test seems unnecessary and incorrect as we test hierarchy now. See test "nav_ctrl_tab_popups" in ImGuiTestSuite.
This commit is contained in:
ocornut 2024-02-08 17:08:01 +01:00
parent 3a078466a7
commit 76e09c4b0f
2 changed files with 9 additions and 6 deletions

View File

@ -59,11 +59,13 @@ Other changes:
- Nav, Menus: Fixed click on a BeginMenu() followed by right-arrow from making the child menu - Nav, Menus: Fixed click on a BeginMenu() followed by right-arrow from making the child menu
reopen and flicker (using ImGuiPopupFlags_NoReopen). reopen and flicker (using ImGuiPopupFlags_NoReopen).
- Nav: ImGuiWindowFlags_NoNavInputs is tested during scoring so NavFlattened windows can use it. - Nav: ImGuiWindowFlags_NoNavInputs is tested during scoring so NavFlattened windows can use it.
- OpenPopup(): Added ImGuiPopupFlags_NoReopen flag to specifically not close and reopen a popup - Popups: OpenPopup(): added ImGuiPopupFlags_NoReopen flag to specifically not close and reopen
when it is already open. (#1497, #1533) a popup when it is already open. (#1497, #1533)
(Note that this differs from specific handling we already have in place for the case of calling (Note that this differs from specific handling we already have in place for the case of calling
OpenPopup() repeatedly every frame: we already didn't reopen in that specific situation, otherwise OpenPopup() repeatedly every frame: we already didn't reopen in that specific situation, otherwise
the effect would be very disastrous in term of confusion, as reopening would steal focus). the effect would be very disastrous in term of confusion, as reopening would steal focus).
- Popups: Slight change to popup closing logic (e.g. after focusing another window) which skipped
over popups that are also child windows.
- Debug Tools: Metrics: Fixed debug break in SetShortcutRouting() not handling ImGuiMod_Shortcut redirect. - Debug Tools: Metrics: Fixed debug break in SetShortcutRouting() not handling ImGuiMod_Shortcut redirect.
- Debug Tools: Debug Log: Added "Input Routing" logging. - Debug Tools: Debug Log: Added "Input Routing" logging.
- Debug Tools: Added "nop" to IM_DEBUG_BREAK macro on GCC to work around GDB bug (#7266) [@Peter0x44] - Debug Tools: Added "nop" to IM_DEBUG_BREAK macro on GCC to work around GDB bug (#7266) [@Peter0x44]

View File

@ -10819,14 +10819,15 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to
if (!popup.Window) if (!popup.Window)
continue; continue;
IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0); IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
continue;
// Trim the stack unless the popup is a direct parent of the reference window (the reference window is often the NavWindow) // Trim the stack unless the popup is a direct parent of the reference window (the reference window is often the NavWindow)
// - With this stack of window, clicking/focusing Popup1 will close Popup2 and Popup3: // - Clicking/Focusing Window2 won't close Popup1:
// Window -> Popup1 -> Popup2 -> Popup3 // Window -> Popup1 -> Window2(Ref)
// - Clicking/focusing Popup1 will close Popup2 and Popup3:
// Window -> Popup1(Ref) -> Popup2 -> Popup3
// - Each popups may contain child windows, which is why we compare ->RootWindow! // - Each popups may contain child windows, which is why we compare ->RootWindow!
// Window -> Popup1 -> Popup1_Child -> Popup2 -> Popup2_Child // Window -> Popup1 -> Popup1_Child -> Popup2 -> Popup2_Child
// We step through every popup from bottom to top to validate their position relative to reference window.
bool ref_window_is_descendent_of_popup = false; bool ref_window_is_descendent_of_popup = false;
for (int n = popup_count_to_keep; n < g.OpenPopupStack.Size; n++) for (int n = popup_count_to_keep; n < g.OpenPopupStack.Size; n++)
if (ImGuiWindow* popup_window = g.OpenPopupStack[n].Window) if (ImGuiWindow* popup_window = g.OpenPopupStack[n].Window)