ocornut / imgui

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

How can I hide central node in docking layout ? #6821

Open ChivenZhang opened 11 months ago

ChivenZhang commented 11 months ago

Version/Branch of Dear ImGui:

Version: 1.89 Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_OpenGL3.cpp + imgui_impl_SDL2.cpp Compiler: vs2019 msvc Operating System: windows 11

My Issue/Question:

I want to hide central node in docking layout. I remember there was a IMGUI_DOCK_FLAGS_NO_CENTRAL_NODE enum before, but it's missed now. How can I hide it using latest api? Thanks.

image

image

ocornut commented 11 months ago

If the node is created with DockBuilderAddNode() you should not pass the ImGuiDockNodeFlags_DockSpace flag the first time you create it. Sorry it is confusingly named, this has been a common issue to correct.

GamingMinds-DanielC commented 11 months ago

If you don't specify ImGuiDockNodeFlags_NoDockingInCentralNode and ImGuiDockNodeFlags_PassthruCentralNode, you should be able to use the central node like any normal node. So if you just dock windows into the central node, it should be central only as a formality, same effect as if you didn't have one.

ocornut commented 11 months ago

Note that Central Node has different sizing behavior as normal node, as it always use "remaining size" rather than preserving its size.

ChivenZhang commented 11 months ago

The reason why I hide central node is that no-central node would share the same ratio when maximum the window.

ChivenZhang commented 11 months ago

If I place any widget in the central node, it would not keep its size ratio when resizing the window. So the question is how to keep the resize ratio among all dock widgets ? I couldn't use dock builder as I need the imgui to save layout to imgui.ini.

ChivenZhang commented 11 months ago

Note that Central Node has different sizing behavior as normal node, as it always use "remaining size" rather than preserving its size.

I think It's more natual for no-central node to use remaining size when there's no central node. It just my personal advice that from the experience of using Qt's QMainWindow and QDockWidget.

ocornut commented 11 months ago

I answered your question. When you create the node don't use the ImGuiDockNodeFlags_DockSpace flag you will have no central node. You may need to delete/clean your .ini data from past data.

ChivenZhang commented 11 months ago

I don't create node by dock builder, I just drag dock widget to dock layout and save its layout. Can it be possible to cancel the central area when dragging docking window ? image

ocornut commented 11 months ago

Where are you dragging into? an already created window or a dockspace?

ChivenZhang commented 11 months ago

Where are you dragging into? an already created window or a dockspace? It's into dockspace.