-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do exactly ImGui::DockBuilderXXX functions work? #6535
Comments
Hello, I haven't looked at your case in much details yet, but notice that comment:
Try to call I wonder if what's the thing causing your problem? |
Alright, so I think I've just used to small vector in |
Alright, so I've achieved what I wanted without the I've got ImGuiID dockspaceID = 0;
ImGuiID propertiesID = 0;
ImGuiID previewID = 0;
ImGuiID sceneID = 0;
ImGuiID detailsID = 0; as a member variables I split nodes like this: static ImGuiDockNodeFlags dockFlags = ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_NoWindowMenuButton;
dockspaceID = ImGui::GetID(titleAndId.c_str());
static ImGuiID leftID = 0;
static ImGuiID rightID = 0;
if (!ImGui::DockBuilderGetNode(dockspaceID)) {
ImGui::DockBuilderRemoveNode(dockspaceID);
ImGui::DockBuilderAddNode(dockspaceID, ImGuiDockNodeFlags_None);
ImGuiID mainID = dockspaceID;
// Split the main dockspace node into left and right nodes
leftID = ImGui::DockBuilderSplitNode(mainID, ImGuiDir_Left, 0.3f, nullptr, &rightID);
//split left node into top and bottom nodes
propertiesID = ImGui::DockBuilderSplitNode(leftID, ImGuiDir_Up, 0.5f, nullptr, &previewID);
//split right into left and right nodes
sceneID = ImGui::DockBuilderSplitNode(rightID, ImGuiDir_Left, 0.8, nullptr, &detailsID);
// Dock windows to the resulting nodes
ImGui::DockBuilderDockWindow("Properties", propertiesID);
ImGui::DockBuilderDockWindow("Scene Preview", previewID);
ImGui::DockBuilderDockWindow("Canvas", sceneID);
ImGui::DockBuilderDockWindow("Details", detailsID);
ImGui::DockBuilderFinish(mainID);
}
ImGui::DockSpace(dockspaceID, ImVec2(0, 0), dockFlags); and I use ImGui::SetNextWindowClass
and
ImGui::SetNextWindowDockID before every window, like this: ImGui::SetNextWindowClass(&windowClass);
ImGui::SetNextWindowDockID(sceneID);
ImGui::Begin("Scene Preview");
//...
ImGui::End();
//... etc works great! |
Basically there's an issue where shrinking down to small size is slightly "lossy" as there are occasional back and forth between ratio and absolute sizes following some interactions, and this breaks this situation. Will let you know if it gets improved. |
There's also a problem with this approach, when I restart the app, the docked windows are undocked and I'm unable to dock them again. Quick fix: get rid of: if (!ImGui::DockBuilderGetNode(dockspaceID)) {
ImGui::DockBuilderRemoveNode(dockspaceID);
ImGui::DockBuilderAddNode(dockspaceID, ImGuiDockNodeFlags_None);
//body remains the same
} call ImGui::DockSpace(dockspaceID, ImVec2(0, 0), dockFlags); before
I've also slightly changed Instead of throwing asset I just return if (node->IsSplitNode()) {
ImGuiID id_at_dir = node->ChildNodes[(split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 0 : 1]->ID;
ImGuiID id_at_opposite_dir = node->ChildNodes[(split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0]->ID;
if (out_id_at_dir)
*out_id_at_dir = id_at_dir;
if (out_id_at_opposite_dir)
*out_id_at_opposite_dir = id_at_opposite_dir;
return id_at_dir;
} Now it seems to be working fine. If I find anything more, I'll post it here. Maybe someone find it helpful for a quick solution |
Version/Branch of Dear ImGui:
Version: v1.89 WIP
Branch: docking
My Issue/Question:
I have 2 windows,
Properties
andCanvas
.I want the
Properties
window to be on the left side and take 50% of the docking space and theCanvas
to take the rest of the docking space. I'm having a hard time understanding how this all works.I've already seen #2583, but it's not exactly what I want
I've tried:
I thought I'd split the docking space in half, but the
Properties
window takes like 90% of a space:So, I've played around with the
size_ratio_for_node_at_dir
, but it only went worse.I've tried setting
DockBuilderSetNodePos
and/orDockBuilderSetNodeSize
.I've tried to use
DockBuilderSplitNode
onImGuiID dockLeft
like this:and then play around with the
size_ratio_for_node_at_dir
.Nothing works as I wish.
For the main docking space it works:
in this example, I actually split vertically, but I guess it should not matter.
I've tried doing the same for the second docking space:
I use it like this:
where
windowClass
is the one that was set inRenderInADockspace2
function.It ends up not splitting the window anyhow, there're just 2 tabs:
expected result:
I believe it may be related to
ImGui::SetNextWindowClass(&windowClass);
functionThe text was updated successfully, but these errors were encountered: