Docking: Added ImGuiConfigFlags_DockingNoSplit flag. (#2109)

This commit is contained in:
omar 2018-11-23 18:42:16 +01:00
parent 760c1d95b9
commit 131de7ab62
3 changed files with 19 additions and 2 deletions

View File

@ -9857,6 +9857,16 @@ void ImGui::DockContextNewFrameUpdateUndocking(ImGuiContext* ctx)
DockContextClearNodes(ctx, 0, true);
return;
}
if (g.IO.ConfigFlags & ImGuiConfigFlags_DockingNoSplit)
{
for (int n = 0; n < dc->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
if (node->IsRootNode() && node->IsSplitNode())
{
DockBuilderRemoveNodeChildNodes(node->ID);
//dc->WantFullRebuild = true;
}
}
#if 0
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)))
@ -11195,7 +11205,7 @@ static bool ImGui::DockNodePreviewDockCalc(ImGuiWindow* host_window, ImGuiDockNo
data->IsCenterAvailable = false;
data->IsSidesAvailable = true;
if (host_node && (host_node->Flags & ImGuiDockNodeFlags_NoSplit))
if ((host_node && (host_node->Flags & ImGuiDockNodeFlags_NoSplit)) || (g.IO.ConfigFlags & ImGuiConfigFlags_DockingNoSplit))
data->IsSidesAvailable = false;
if (!is_outer_docking && host_node && host_node->ParentNode == NULL && host_node->IsCentralNode)
data->IsSidesAvailable = false;
@ -11335,7 +11345,7 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock
}
// Stop after ImGuiDir_None
if (host_node && (host_node->Flags & ImGuiDockNodeFlags_NoSplit))
if ((host_node && (host_node->Flags & ImGuiDockNodeFlags_NoSplit)) || (g.IO.ConfigFlags & ImGuiConfigFlags_DockingNoSplit))
return;
}
}
@ -11833,6 +11843,10 @@ void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id)
}
}
// DockNodeMoveWindows->DockNodeAddWindow will normally set those when reaching two windows (which is only adequate during interactive merge)
// Make sure we don't lose our current pos/size. (FIXME-DOCK: Consider tidying up that code in DockNodeAddWindow instead)
root_node->InitFromFirstWindowPosSize = false;
// Apply to settings
for (int settings_n = 0; settings_n < ctx->SettingsWindows.Size; settings_n++)
if (ImGuiID window_settings_dock_id = ctx->SettingsWindows[settings_n].DockId)

View File

@ -959,6 +959,7 @@ enum ImGuiConfigFlags_
// [BETA] Docking
ImGuiConfigFlags_DockingEnable = 1 << 6, // Docking enable flags. Use SHIFT to dock window into another (or without SHIFT if io.ConfigDockingWithShift = false).
ImGuiConfigFlags_DockingNoSplit = 1 << 7, // Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.
// [BETA] Viewports
ImGuiConfigFlags_ViewportsEnable = 1 << 10, // Viewport enable flags (require both ImGuiConfigFlags_PlatformHasViewports + ImGuiConfigFlags_RendererHasViewports set by the respective back-ends)

View File

@ -347,6 +347,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::CheckboxFlags("io.ConfigFlags: DockingEnable", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_DockingEnable);
ImGui::SameLine(); ShowHelpMarker("Use SHIFT to dock window into another (or without SHIFT if io.ConfigDockingWithShift == false)");
ImGui::CheckboxFlags("io.ConfigFlags: DockingNoSplit", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_DockingNoSplit);
ImGui::SameLine(); ShowHelpMarker("Simplified docking mode: disable window splitting, so docking is limited to merging multiple windows together into tab-bars.");
ImGui::CheckboxFlags("io.ConfigFlags: ViewportsEnable", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_ViewportsEnable);
ImGui::SameLine(); ShowHelpMarker("Toggling this at runtime is normally unsupported (it will offset your windows).");