From c337cdcfd3b153541e685d4ad53b908f2d901f2e Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 15:02:09 +0100 Subject: [PATCH 1/8] Internal: ButtonBehavior: Tweak to update g.ActiveIdClickOffset more consistently --- imgui.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 75b6aa40c..d952e287f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6253,20 +6253,14 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool { SetActiveID(id, window); // Hold on ID FocusWindow(window); - g.ActiveIdClickOffset = g.IO.MousePos - bb.Min; } if (((flags & ImGuiButtonFlags_PressedOnClick) && g.IO.MouseClicked[0]) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[0])) { pressed = true; if (flags & ImGuiButtonFlags_NoHoldingActiveID) - { ClearActiveID(); - } else - { SetActiveID(id, window); // Hold on ID - g.ActiveIdClickOffset = g.IO.MousePos - bb.Min; - } FocusWindow(window); } if ((flags & ImGuiButtonFlags_PressedOnRelease) && g.IO.MouseReleased[0]) @@ -6286,6 +6280,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool bool held = false; if (g.ActiveId == id) { + if (g.ActiveIdIsJustActivated) + g.ActiveIdClickOffset = g.IO.MousePos - bb.Min; if (g.IO.MouseDown[0]) { held = true; From 63e4677b8148d67336e9807334a4401a93bf9d82 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 15:22:54 +0100 Subject: [PATCH 2/8] Popup: BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid(), OpenPopupOnItemClick() all react on mouse release instead of mouse click. Note that they don't use the full ButtonBehavior() or tracking aabb on both click and release. Applications I've tried seems to behave inconsistently there but on-release-without-tracking is both fairly common and doesn't require extra code for the id tracking. (~#439) --- imgui.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index d952e287f..e63341b41 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3904,7 +3904,7 @@ void ImGui::EndPopup() bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button) { ImGuiWindow* window = GImGui->CurrentWindow; - if (IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) { ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) @@ -3922,9 +3922,8 @@ bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button) ImGuiWindow* window = GImGui->CurrentWindow; ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) - if (IsMouseClicked(mouse_button)) - if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) - OpenPopupEx(id, true); + if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + OpenPopupEx(id, true); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } @@ -3933,10 +3932,9 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool a if (!str_id) str_id = "window_context"; ImGuiID id = GImGui->CurrentWindow->GetID(str_id); - if (IsMouseClicked(mouse_button)) - if (IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) - if (also_over_items || !IsAnyItemHovered()) - OpenPopupEx(id, true); + if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) + if (also_over_items || !IsAnyItemHovered()) + OpenPopupEx(id, true); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } @@ -3945,7 +3943,7 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) if (!str_id) str_id = "void_context"; ImGuiID id = GImGui->CurrentWindow->GetID(str_id); - if (!IsAnyWindowHovered() && IsMouseClicked(mouse_button)) + if (IsMouseReleased(mouse_button) && !IsAnyWindowHovered()) OpenPopupEx(id, true); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } From e09852fc49c8aa12f44702f3c9aa85c7c5472003 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 15:34:15 +0100 Subject: [PATCH 3/8] Popups: Revert aca23fd3f0eb1b6fb109840f5fc942c49312d096 (Oct 20, 2017). Because 1) I can't seem to find a default. 2) The if is definitively faulty and would have been all true. 3) It looks like possibly the following commit 6ab737a4bb288d553f4de3e3841e393ef96d32a0 could have made this unnecessary. Not absolutly certain. (~#439) --- imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index e63341b41..7d6c3f9be 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3737,8 +3737,8 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by CloseInactivePopups(). // This is equivalent to what ClosePopupToLevel() does. - if (g.OpenPopupStack[current_stack_size].PopupId == id) - FocusWindow(parent_window); + //if (g.OpenPopupStack[current_stack_size].PopupId == id) + // FocusWindow(parent_window); } } From 369189b675c456116a932848d781beeb4b439bd0 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 15:40:46 +0100 Subject: [PATCH 4/8] Internals: Popup: Explicitely setting up ImGuiPopupRef reduces confusion. --- imgui.cpp | 10 +++++++--- imgui_internal.h | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 7d6c3f9be..41d75c6bd 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3725,9 +3725,13 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) ImGuiContext& g = *GImGui; ImGuiWindow* parent_window = g.CurrentWindow; int current_stack_size = g.CurrentPopupStack.Size; - ImVec2 mouse_pos = g.IO.MousePos; - ImVec2 popup_pos = mouse_pos; // NB: In the Navigation branch popup_pos may not use mouse_pos. - ImGuiPopupRef popup_ref = ImGuiPopupRef(id, parent_window, parent_window->GetID("##Menus"), popup_pos, mouse_pos); // Tagged as new ref because constructor sets Window to NULL. + ImGuiPopupRef popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack. + popup_ref.PopupId = id; + popup_ref.Window = NULL; + popup_ref.ParentWindow = parent_window; + popup_ref.ParentMenuSet = parent_window->GetID("##Menus"); + popup_ref.MousePosOnOpen = g.IO.MousePos; + popup_ref.PopupPosOnOpen = g.IO.MousePos; // NB: In the Navigation branch popup_pos may not use mouse_pos. if (g.OpenPopupStack.Size < current_stack_size + 1) g.OpenPopupStack.push_back(popup_ref); else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id) diff --git a/imgui_internal.h b/imgui_internal.h index bdadc464e..771d4e073 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -403,8 +403,6 @@ struct ImGuiPopupRef ImGuiID ParentMenuSet; // Set on OpenPopup() ImVec2 PopupPosOnOpen; // Preferred popup position (typically == MousePosOnOpen when using mouse) ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup - - ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& popup_pos, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; PopupPosOnOpen = popup_pos; MousePosOnOpen = mouse_pos; } }; struct ImGuiColumnData From 3678307cd953e51913d1d1076f8124a96c34e0a3 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 15:56:14 +0100 Subject: [PATCH 5/8] Popup, Menus: Tweaks and comments. --- imgui.cpp | 4 ++-- imgui_internal.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 41d75c6bd..b3c7a8038 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3729,7 +3729,7 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) popup_ref.PopupId = id; popup_ref.Window = NULL; popup_ref.ParentWindow = parent_window; - popup_ref.ParentMenuSet = parent_window->GetID("##Menus"); + popup_ref.ParentIdOnOpen = parent_window->IDStack.back(); popup_ref.MousePosOnOpen = g.IO.MousePos; popup_ref.PopupPosOnOpen = g.IO.MousePos; // NB: In the Navigation branch popup_pos may not use mouse_pos. if (g.OpenPopupStack.Size < current_stack_size + 1) @@ -9664,7 +9664,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) bool pressed; bool menu_is_open = IsPopupOpen(id); - bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentMenuSet == window->GetID("##Menus")); + bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentIdOnOpen == window->IDStack.back()); ImGuiWindow* backed_nav_window = g.NavWindow; if (menuset_is_open) g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) diff --git a/imgui_internal.h b/imgui_internal.h index 771d4e073..f355a4922 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -400,7 +400,7 @@ struct ImGuiPopupRef ImGuiID PopupId; // Set on OpenPopup() ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup() ImGuiWindow* ParentWindow; // Set on OpenPopup() - ImGuiID ParentMenuSet; // Set on OpenPopup() + ImGuiID ParentIdOnOpen; // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) ImVec2 PopupPosOnOpen; // Preferred popup position (typically == MousePosOnOpen when using mouse) ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup }; From 69ff65f054eddba4936473be814d58305913479f Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 16:11:25 +0100 Subject: [PATCH 6/8] Internals: Popup: Renaming fields. --- imgui.cpp | 12 ++++++------ imgui_internal.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index b3c7a8038..9eef1ba4d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3550,7 +3550,7 @@ ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup() { ImGuiContext& g = *GImGui; if (g.CurrentPopupStack.Size > 0) - return g.OpenPopupStack[g.CurrentPopupStack.Size-1].MousePosOnOpen; + return g.OpenPopupStack[g.CurrentPopupStack.Size-1].OpenMousePos; return g.IO.MousePos; } @@ -3729,9 +3729,9 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) popup_ref.PopupId = id; popup_ref.Window = NULL; popup_ref.ParentWindow = parent_window; - popup_ref.ParentIdOnOpen = parent_window->IDStack.back(); - popup_ref.MousePosOnOpen = g.IO.MousePos; - popup_ref.PopupPosOnOpen = g.IO.MousePos; // NB: In the Navigation branch popup_pos may not use mouse_pos. + popup_ref.OpenParentId = parent_window->IDStack.back(); + popup_ref.OpenMousePos = g.IO.MousePos; + popup_ref.OpenPopupPos = g.IO.MousePos; // NB: In the Navigation branch popup_pos may not use mouse_pos. if (g.OpenPopupStack.Size < current_stack_size + 1) g.OpenPopupStack.push_back(popup_ref); else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id) @@ -4483,7 +4483,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Popup first latch mouse position, will position itself when it appears next frame window->AutoPosLastDirection = ImGuiDir_None; if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api) - window->PosFloat = g.CurrentPopupStack.back().PopupPosOnOpen; + window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos; } // Collapse window by double-clicking on title bar @@ -9664,7 +9664,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) bool pressed; bool menu_is_open = IsPopupOpen(id); - bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentIdOnOpen == window->IDStack.back()); + bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].OpenParentId == window->IDStack.back()); ImGuiWindow* backed_nav_window = g.NavWindow; if (menuset_is_open) g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) diff --git a/imgui_internal.h b/imgui_internal.h index f355a4922..4ff50d8f5 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -400,9 +400,9 @@ struct ImGuiPopupRef ImGuiID PopupId; // Set on OpenPopup() ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup() ImGuiWindow* ParentWindow; // Set on OpenPopup() - ImGuiID ParentIdOnOpen; // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) - ImVec2 PopupPosOnOpen; // Preferred popup position (typically == MousePosOnOpen when using mouse) - ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup + ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) + ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse) + ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup }; struct ImGuiColumnData From deab2ab015c4d66a9cdd51971e616a6ac444bad1 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 16:15:54 +0100 Subject: [PATCH 7/8] Popups: Gently handle the user mistakenly calling OpenPopup() every frame. (when reopen_existing is true). (#1497) --- imgui.cpp | 18 +++++++++++++++--- imgui_internal.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 9eef1ba4d..d735e0266 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3729,15 +3729,27 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) popup_ref.PopupId = id; popup_ref.Window = NULL; popup_ref.ParentWindow = parent_window; + popup_ref.OpenFrameCount = g.FrameCount; popup_ref.OpenParentId = parent_window->IDStack.back(); popup_ref.OpenMousePos = g.IO.MousePos; - popup_ref.OpenPopupPos = g.IO.MousePos; // NB: In the Navigation branch popup_pos may not use mouse_pos. + popup_ref.OpenPopupPos = g.IO.MousePos; // NB: In the Navigation branch OpenPopupPos doesn't use the mouse position, hence the separation here. + if (g.OpenPopupStack.Size < current_stack_size + 1) + { g.OpenPopupStack.push_back(popup_ref); + } else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id) { - g.OpenPopupStack.resize(current_stack_size+1); - g.OpenPopupStack[current_stack_size] = popup_ref; + // Close child popups if any + g.OpenPopupStack.resize(current_stack_size + 1); + + // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui + // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing + // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand. + if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1) + g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount; + else + g.OpenPopupStack[current_stack_size] = popup_ref; // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by CloseInactivePopups(). // This is equivalent to what ClosePopupToLevel() does. diff --git a/imgui_internal.h b/imgui_internal.h index 4ff50d8f5..be4284d24 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -400,6 +400,7 @@ struct ImGuiPopupRef ImGuiID PopupId; // Set on OpenPopup() ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup() ImGuiWindow* ParentWindow; // Set on OpenPopup() + int OpenFrameCount; // Set on OpenPopup() ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differenciate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse) ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup From 3fc7cf190def6ac51cb5791f3ad8cee7a79c4026 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 7 Jan 2018 16:20:02 +0100 Subject: [PATCH 8/8] OpenPopup(): Always reopen existing popup. Removed OpenPopupEx() bool reopen_existing which is always true. This also makes the public API on par with OpenPopupEx(). (#1497, #1533) --- imgui.cpp | 16 ++++++++-------- imgui_internal.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index d735e0266..4a21fe4de 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3720,7 +3720,7 @@ void ImGui::EndTooltip() // Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. // Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). // One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL) -void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) +void ImGui::OpenPopupEx(ImGuiID id) { ImGuiContext& g = *GImGui; ImGuiWindow* parent_window = g.CurrentWindow; @@ -3738,7 +3738,7 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) { g.OpenPopupStack.push_back(popup_ref); } - else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id) + else { // Close child popups if any g.OpenPopupStack.resize(current_stack_size + 1); @@ -3761,7 +3761,7 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) void ImGui::OpenPopup(const char* str_id) { ImGuiContext& g = *GImGui; - OpenPopupEx(g.CurrentWindow->GetID(str_id), false); + OpenPopupEx(g.CurrentWindow->GetID(str_id)); } static void CloseInactivePopups(ImGuiWindow* ref_window) @@ -3924,7 +3924,7 @@ bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button) { ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) - OpenPopupEx(id, true); + OpenPopupEx(id); return true; } return false; @@ -3939,7 +3939,7 @@ bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button) ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) - OpenPopupEx(id, true); + OpenPopupEx(id); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } @@ -3950,7 +3950,7 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool a ImGuiID id = GImGui->CurrentWindow->GetID(str_id); if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) if (also_over_items || !IsAnyItemHovered()) - OpenPopupEx(id, true); + OpenPopupEx(id); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } @@ -3960,7 +3960,7 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) str_id = "void_context"; ImGuiID id = GImGui->CurrentWindow->GetID(str_id); if (IsMouseReleased(mouse_button) && !IsAnyWindowHovered()) - OpenPopupEx(id, true); + OpenPopupEx(id); return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings); } @@ -9204,7 +9204,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF if (pressed && !popup_open) { - OpenPopupEx(id, false); + OpenPopupEx(id); popup_open = true; } diff --git a/imgui_internal.h b/imgui_internal.h index be4284d24..9216793b6 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -894,7 +894,7 @@ namespace ImGui IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); IMGUI_API void PopItemFlag(); - IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing); + IMGUI_API void OpenPopupEx(ImGuiID id); IMGUI_API void ClosePopup(ImGuiID id); IMGUI_API bool IsPopupOpen(ImGuiID id); IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);