Skip to content

Commit

Permalink
Popups: calling OpenPopup() on already open popup doesn't close it's …
Browse files Browse the repository at this point in the history
…child (#126)

It think it makes more sense? Maybe?
Note that calling OpenPopup() every frame probably doesn't make sense.
  • Loading branch information
ocornut committed May 28, 2015
1 parent 7847100 commit 78dc54a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3054,9 +3054,12 @@ void ImGui::OpenPopup(const char* str_id)
ImGuiState& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
const ImGuiID id = window->GetID(str_id);
g.OpenedPopupStack.resize(g.CurrentPopupStack.size() + 1);
if (g.OpenedPopupStack.back().PopupID != id)
g.OpenedPopupStack.back() = ImGuiPopupRef(id, window, window->GetID("##menus"));
size_t current_stack_size = g.CurrentPopupStack.size();
ImGuiPopupRef popup_ref = ImGuiPopupRef(id, window, window->GetID("##menus")); // Tagged as new ref because constructor sets Window to NULL (we are passing the ParentWindow info here)
if (g.OpenedPopupStack.size() < current_stack_size + 1)
g.OpenedPopupStack.push_back(popup_ref);
else if (g.OpenedPopupStack[current_stack_size].PopupID != id)
g.OpenedPopupStack[current_stack_size] = popup_ref;
}

static void CloseInactivePopups()
Expand Down

0 comments on commit 78dc54a

Please sign in to comment.