ocornut / imgui

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

How to set `ImGuiDockNodeFlags` on nodes created with `DockBuilderSplitNode` #8099

Open sodamouse opened 4 weeks ago

sodamouse commented 4 weeks ago

Version/Branch of Dear ImGui:

Version 1.91.4, Branch: docking

Back-ends:

imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp

Compiler, OS:

Windows 11 + MSVS 2022

Full config/build information:

No response

Details:

My Issue/Question:

Hello, I am wondering how I can set flags on nodes created via DockBuilderSplitNode. I added node flags to the parent node, but the child doesn't seem to inherit the flags. Also I tried using AddNode on ImGuiIDs belonging to (future) child nodes created by the split function, but this doesn't help me either, so I guess the Split function sets the ID values to something else.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:


static ImGuiID mainDockId;
static ImGuiID dockIdResourcesAndControls;

constexpr ImGuiDockNodeFlags DOCK_NODE_FLAGS =
    ImGuiDockNodeFlags_NoTabBar           |
    ImGuiDockNodeFlags_NoResizeX          |
    ImGuiDockNodeFlags_NoResizeY;

void init_dockspaces(GameMode mode)
{
    switch (mode) {
        case GameMode_Management:
        case GameMode_Report:
        {
            ImGui::DockBuilderRemoveNode(mainDockId);

            // This works fine.
            ImGui::DockBuilderAddNode(mainDockId, DOCK_NODE_FLAGS);

            ImGui::DockBuilderSetNodeSize(mainDockId, ImGui::GetMainViewport()->Size);

            // How to add flags here?
            ImGui::DockBuilderSplitNode(mainDockId, ImGuiDir_Right, 0.2f, &dockIdResourcesAndControls, &dockIdMainPort);

            ImGui::DockBuilderDockWindow("MainPort", dockIdMainPort);
            ImGui::DockBuilderDockWindow("ResourcesAndControls", dockIdResourcesAndControls);

            ImGui::DockBuilderFinish(mainDockId);
        }; break;
    }
sodamouse commented 4 weeks ago

Since I am using DockSpaceOverViewport, I found that setting the flags there would have them be inherited by the child nodes. While this solves my immediate problem, I think more granular control over child node flags would be useful in many situations.