mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-20 23:06:36 +00:00
Docking: Made DockBuilderSplitNode/DockNodeTreeSplit work even if the node doesn't have a size yet. (#2357, #2109)
Followup to fa0ce4b7d
, at that time I came to the conclusion that programmatic split couldn't work without knowing the size ahead of it. I forgot the reason for that. May bite us back!
This commit is contained in:
parent
3de440fda2
commit
5412cdf2c8
@ -11959,6 +11959,7 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock
|
|||||||
|
|
||||||
void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_inheritor_child_idx, float split_ratio, ImGuiDockNode* new_node)
|
void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_inheritor_child_idx, float split_ratio, ImGuiDockNode* new_node)
|
||||||
{
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(split_axis != ImGuiAxis_None);
|
IM_ASSERT(split_axis != ImGuiAxis_None);
|
||||||
|
|
||||||
ImGuiDockNode* child_0 = (new_node && split_inheritor_child_idx != 0) ? new_node : DockContextAddNode(ctx, 0);
|
ImGuiDockNode* child_0 = (new_node && split_inheritor_child_idx != 0) ? new_node : DockContextAddNode(ctx, 0);
|
||||||
@ -11976,6 +11977,7 @@ void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG
|
|||||||
parent_node->VisibleWindow = NULL;
|
parent_node->VisibleWindow = NULL;
|
||||||
|
|
||||||
float size_avail = (parent_node->Size[split_axis] - IMGUI_DOCK_SPLITTER_SIZE);
|
float size_avail = (parent_node->Size[split_axis] - IMGUI_DOCK_SPLITTER_SIZE);
|
||||||
|
size_avail = ImMax(size_avail, g.Style.WindowMinSize[split_axis] * 2.0f);
|
||||||
IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
|
IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
|
||||||
child_0->SizeRef = child_1->SizeRef = parent_node->Size;
|
child_0->SizeRef = child_1->SizeRef = parent_node->Size;
|
||||||
child_0->SizeRef[split_axis] = ImFloor(size_avail * split_ratio);
|
child_0->SizeRef[split_axis] = ImFloor(size_avail * split_ratio);
|
||||||
|
Loading…
Reference in New Issue
Block a user