Imgui: Window fills the entire dock node instead of splitted area

Created on 17 Sep 2020  路  5Comments  路  Source: ocornut/imgui

Version: 1.79 WIP
Branch: docking

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: MSVC in VS2019
Operating System: Windows10

My Issue/Question:

I was trying to create my own way of loading docking layouts so I created a class with just one method called Apply.
before diving in writing complex stuff, I started to do some test:

void DockingLayout::Apply()
{
    static bool init = false;
    if (init)
        return;
    init = true;

    ImGui::DockBuilderRemoveNode(m_RootNode); // Clear out existing layout
    ImGui::DockBuilderAddNode(m_RootNode); // Add empty node
    ImGui::DockBuilderSetNodeSize(m_RootNode, ImGui::GetMainViewport()->Size);

    ImGuiID dock_main_id = m_RootNode;
    ImGuiID dock_id_prop = ImGui::DockBuilderSplitNode(dock_main_id, ImGuiDir_Left, 0.50f, NULL, &dock_main_id);
    ImGuiID dock_id_bottom = ImGui::DockBuilderSplitNode(dock_main_id, ImGuiDir_Down, 0.20f, NULL, &dock_main_id);

    ImGui::DockBuilderDockWindow("Toolbar", dock_id_bottom);
    ImGui::DockBuilderDockWindow("Project Manager", dock_id_prop);
    ImGui::DockBuilderFinish(m_RootNode);
}
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
DockingLayout layout(/*m_RootNode*/dockspace_id);
layout.Apply();

I didn't dock anything in empty space (dock_main_id after doing splitting) but the Toolbar window fills the entire space in the right half like this:
dockissue

but I want it to just fill 20% of the space from the bottom like this: (docked by hand)
gooddock

Is there any way to achieve the second screenshot with DockBuilderXXX?

docking

All 5 comments

"To create a DockSpace() node, make sure to set the ImGuiDockNodeFlags_DockSpace flag when calling DockBuilderAddNode()."

The ambiguity is that this implicitly create a "Central node" and this term itself is ambiguous and represent 2-3 subfeatures including the feature of "staying visible and claiming space even when nothing is docked into me". Most docking nodes do NOT stay visible and do not claim space when nothing is docked into them...
We should make all the flags more explicit.

You are right.
when I wrote my own code, I cause a runtime exception because of a completely different thing(but related to Dear ImGui). so I replaced it with a code in one of the issues and he forgot to use ImGuiDockNodeFlags_DockSpace. and I forgot too.
but your description was very helpful. Thank you for your reply and for the awesome library.

Good to hear! Will rework those flags eventually...

I think its a really good idea to populate https://github.com/ocornut/imgui/tree/master/docs with detailed content and put important questions asked in issues and their answers so everyone can find them easily.

I think its a really good idea to

I don't disagree but I currently don't have the bandwidth to create the sort of documentation I would ideally like to create, so I'm hoping some people can join and help populate the wiki.

How do you define "important questions" ? Every question is an important question for the person asking it.
The FAQ has the most frequently asked ones already, otherwise Issues are searchable and this is why I always recommend people to use Github like you did (vs using one of those chat program which are not helpful to future users).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ILoveImgui picture ILoveImgui  路  3Comments

BlackWatersInc picture BlackWatersInc  路  3Comments

noche-x picture noche-x  路  3Comments

namuda picture namuda  路  3Comments

Folling picture Folling  路  3Comments