ocornut / imgui

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

Windows inside Tabs #6221

Open IceLuna opened 1 year ago

IceLuna commented 1 year ago

Version/Branch of Dear ImGui:

Version: 1.89.4 WIP Branch: docking

My Issue/Question:

Hi! I want to make UI like in unreal engine and my question is: is there a way to dock windows to a tab? On a screenshot below you can see a texture-viewer tab (called T_Test) and it has docked windows (Viewport, Details, etc). Also these docked windows are moved along with a texture-viewer tab How can I achieve that? Couldn't find anything like this in issues and in ImGui::ShowDemoWindow() I hope I didn't miss anything :) Thanks!

Screenshots/Video

ue_example

ocornut commented 1 year ago

If you create a DockSpace() inside your window you can dock other windows into it. See Demo->Examples->Dockspace and Demo->Examples->Documents.

IceLuna commented 1 year ago

Yes, I've tried it but I don't see a way to recreate UE's behavior. I did something like this image

I have Viewport and Details windows like in UE. But the key that is missing is a tab containing both windows (in UE-screenshot it's called T_Test). And I can't dock these two windows to something else without undocking them. I guess I need some kind of Parent/Upper window that will carry Viewport and Details windows along with it.

ocornut commented 1 year ago

That’s exactly what DockSpace() does and I don’t see a dockspace in your image above. Be mindful that a hidden dockspace needs to be still be submitted using the _KeepAlive flag else its child windows will be undocked if it stops being submitted.

You can then use SetNextWindowClass() to perform some filtering, so top level windows can only be combined with each others, and tool windows can only be docked in a top-level window.

IceLuna commented 1 year ago

Sorry, but I can't seem to understand it and get it right. I've tried playing with Demo->Examples->Dockspace and Demo->Examples->Documents and couldn't get what I want. This is what I have right now:

image

ImGui::Begin("Tab/Parent window");
ImGui::DockSpace(dockspace_id1, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_KeepAliveOnly);
ImGui::End();

ImGui::Begin("MyViewport");
ImGui::DockSpace(dockspace_id2, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_KeepAliveOnly);
ImGui::End();

ImGui::Begin("Details");
ImGui::DockSpace(dockspace_id3, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_KeepAliveOnly);
ImGui::End();

My goal result is something like this image2