Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal dialog remembering position #915

Closed
pdoane opened this issue Nov 16, 2016 · 1 comment
Closed

Modal dialog remembering position #915

pdoane opened this issue Nov 16, 2016 · 1 comment

Comments

@pdoane
Copy link

pdoane commented Nov 16, 2016

I would like for a modal dialog to open in the center of the screen once, but then remember its location on subsequent uses. I tried adding this to the modal dialog demo:

            ImGui::SetNextWindowPosCenter(ImGuiSetCond_Once);

            if (ImGui::Button("Delete.."))
                ImGui::OpenPopup("Delete?");
            if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize))
            {
            }

But it still always opens in the center. Any thoughts or ideas?

@ocornut ocornut added the bug label Nov 17, 2016
@ocornut ocornut added the popups label Aug 16, 2017
ocornut added a commit that referenced this issue Jun 23, 2020
…ag anymore, and will not always be auto-centered. (#915, #3091)
ocornut added a commit that referenced this issue Jun 23, 2020
…ag anymore, and will not always be auto-centered. (#915, #3091)

# Conflicts:
#	imgui.cpp
@ocornut
Copy link
Owner

ocornut commented Jun 23, 2020

Implemented that change now.

Some very tangential thoughts (copying same message in #3091)

(
Generally speaking, modals tends to be closer to regular windows than they are to popups, and I imagine a revamp where we could fully use Begin() with ImGuiWindowFlags_Modal (as suggested by #402) and keep control of visibility. The BeginPopupModal() api could still work.

Centering a modal window is surprisingly unobvious in a multi-viewport context, there are just many desirable scenarios. Considering an hypothetical GetFocusedViewport() returning ~~g.NavWindow->Viewport

SetNextWindowPos(GetFocusedViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));

Won't work as expected due to how ImGuiCond_Appearing is set and because the focused/nav window tends to evolve across appearing frames. We probably need variety of access to monitors and viewports tagged with semantic (e.g. access to "focused (last interacted with?) monitor", access to "viewport from where popup was activated", access to "monitor mouse is in") and let the user choose. And I guess we may need to create more continuity between viewports and monitors down the line. Finishing work on the "there are no main viewport" task will probably help enforce this.

Currently the code and demo code uses io.DisplaySize * 0.5f in master branch and selectively CurrentWindow->Viewport's center or GetMainViewport()'s center in docking branch, which are ALL arbitrary, we ought to design standards and have them integrated in master asap.
)

@ocornut ocornut closed this as completed Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants