ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.75k stars 10.17k forks source link

Docking - Windows become invisible when docked together #4715

Open maxomous opened 2 years ago

maxomous commented 2 years ago

Version: Dear ImGui 1.86 WIP (18510) Branch: Docking

BackendPlatformName: imgui_impl_glfw BackendRendererName: imgui_impl_opengl3

OS: Raspberry Pi
Vendor: Broadcom Renderer: V3D 4.2 Version: 2.1 Mesa 19.3.2

My Issue/Question:

When I attempt to dock certain windows together, both windows vanish instead of becoming tabs See GIF

If however, I dock these items onto the DockSpaceOverViewport() node, they seem to remain there fine See GIF

Below is the config.ini file if it helps:

[Window][Debug]
Pos=1239,326
Size=128,182
Collapsed=0
DockId=0x00000001

[Window][Jog Controller]
Pos=1188,324
Size=216,305
Collapsed=0
DockId=0x00000001

[Docking][Data]
DockNode  ID=0x00000001 Pos=1188,324 Size=216,305

A workaround would be to only allow docking to the viewport dock node instead of windows to windows, I'm not sure if that's possible?

ocornut commented 2 years ago

Cannot be answered without a repro.

maxomous commented 2 years ago

What would you need from me?

ocornut commented 2 years ago

A minimum, complete, reproducible, verifiable piece code that reproduce the issue, as requested in guidelines. Otherwise we are missing information.

maxomous commented 2 years ago

Okay will get back to you :)

maxomous commented 2 years ago

Okay so I stripped down my code to this:

    ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiCond_Always);
    if (!ImGui::Begin("Jog Controller", NULL, ImGuiWindowFlags_None)) {
        ImGui::End();
        return;
    }
    ImGui::End();

    ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiCond_Always);
    if (!ImGui::Begin("Overrides", NULL, ImGuiWindowFlags_None)) {
        ImGui::End();
        return;  
    }
    ImGui::End();

And the error was reproducible. It seems that when both windows use the flag ImGuiCond_Always, the windows vanish. If one or both of these are changed to ImGuiCond_Appearing, it fixes the issue.

...

As a side question, since building the program from scratch and using the latest opengl3/glfw implementation files, I receive the following error when running the program: "Glfw Error 65543: GLX: Failed to create context: GLXBadFBConfig"

I am able to resolve this by prefixing the run command with "MESA_GL_VERSION_OVERRIDE=4.3 ./imgui_docking"

Is there a way to prevent the need for this prefix?

ocornut commented 2 years ago

Changing position or size of an individual window undocks it, and there’s probably a side effect to doing it every frame where they keep undocking or something.

The later question is more of an OpenGL driver/setup or GLFW question.

maxomous commented 2 years ago

Glad that's sorted then :)

Would you suggest posting another issue on here regarding the GLFW error? It seems odd that the previous implementation files didn't require the fix..

rokups commented 2 years ago

I would suggest not calling ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiCond_Always); on every frame. It directly contradicts with your aim to dock two windows. You may try using ImGui::SetNextWindowSize(ImVec2(0, 0), ImGuiCond_Appearing); to only auto-size window when it appears. You also can use ImGuiWindowFlags_AlwaysAutoResize window flag for this purpose.