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

Could you provide IsPopupOpen publicly? #799

Closed
ecraven opened this issue Aug 26, 2016 · 10 comments
Closed

Could you provide IsPopupOpen publicly? #799

ecraven opened this issue Aug 26, 2016 · 10 comments
Labels

Comments

@ecraven
Copy link
Contributor

ecraven commented Aug 26, 2016

I've been working on a variant of the radial menu you posted here, and it would help to know whether the Popup is actually open. There is a function IsPopupOpen in imgui.cpp, but it isn't exported publicly. Would you consider changing this?

@ocornut
Copy link
Owner

ocornut commented Sep 15, 2016

Hello and sorry for my late answer.
For now I would suggest just including imgui_internal.h and copying the function code locally.

static bool IsPopupOpen(ImGuiID id)
{
    ImGuiContext& g = *GImGui;
    return g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].PopupId == id;
}

I can't expose it in imgui.h just yet because popup ID are slightly misleading and problematic right now (in some instances using the ID stack - as currently - makes more sense, in some instances we'd want to ignore the id stack). Hence the unclosed discussion at #331, and I don't want to expose users relying on that subtly until it is sorted out.

So it's just better now if you copy the function, at least you know you are in internals territory. You may want to call ImGui::GetId(const char*) to get an ID relative to the current point.

@ocornut
Copy link
Owner

ocornut commented Aug 16, 2017

This is done now.
Note that there are two functions:

In imgui.h
bool IsPopupOpen(const char* str_id);

In imgui_internal.h only
bool IsPopupOpen(ImGuiID id);

The second one will probably be exposed later/soon along with other popup related functions, to help solving recurrent issues such as #331 #747

@ocornut ocornut closed this as completed Aug 16, 2017
@jiapei100
Copy link

jiapei100 commented May 15, 2022

@ocornut
Even 5 years later, the second function is still NOT exposed ...

How to call ImGui::IsPopupOpen(w->PopupId)), where PopupId is an ImGuiID, instead of an const char*??
It looks, the external code failed to tell which function is going to call. I still obtained the following ERROR message:

error: invalid conversion from ‘ImGuiID’ {aka ‘unsigned int’} to ‘const char*’ [-fpermissive]
 1112 |                 ImGui::IsPopupOpen(w->PopupId)) {
      |                                    ~~~^~~~~~~
      |                                       |
      |                                       ImGuiID {aka unsigned int}

@brad-colbert
Copy link

This appears to cause an issue when compiling Open3D currently. Both imgui.h and imgui_internal.h are included and the compiler can't figure out which ImGui::IsPopupOpen() is being called. Is there a solution for this?

@PathogenDavid
Copy link
Contributor

@brad-colbert What compiler error are you getting? They should be distinct overloads.

@ocornut
Copy link
Owner

ocornut commented Oct 25, 2022

@jiapei100

Even 5 years later, the second function is still NOT exposed ...

Just include imgui_internal.h to access it.

@brad-colbert
Copy link

@PathogenDavid gcc 11.3.0 (Ubuntu 22.04.01).

"They should be distinct overloads." That's what I would expect but the compiler is complaining. Doesn't make sense to me.

@ocornut
Copy link
Owner

ocornut commented Oct 25, 2022

Please provide actual code and actual warnings so we don’t have to guess.

@brad-colbert
Copy link

Exactly the same as the original post:

error: invalid conversion from ‘ImGuiID’ {aka ‘unsigned int’} to ‘const char*’ [-fpermissive]
1112 | ImGui::IsPopupOpen(w->PopupId)) {
| ~~~^~~~~~~
| |
| ImGuiID {aka unsigned int}

@ocornut
Copy link
Owner

ocornut commented Oct 25, 2022

That error suggests imgui_internal.h is not included in the compilation unit giving out the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants