MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / DockNodeTreeUpdateSplitter

Method DockNodeTreeUpdateSplitter

imgui_tiny_app/imgui/imgui.cpp:20304–20419  ·  view source on GitHub ↗

(Depth-First, Pre-Order)

Source from the content-addressed store, hash-verified

20302
20303// (Depth-First, Pre-Order)
20304void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node)
20305{
20306 if (node->IsLeafNode())
20307 return;
20308
20309 ImGuiContext& g = *GImGui;
20310
20311 ImGuiDockNode* child_0 = node->ChildNodes[0];
20312 ImGuiDockNode* child_1 = node->ChildNodes[1];
20313 if (child_0->IsVisible && child_1->IsVisible)
20314 {
20315 // Bounding box of the splitter cover the space between both nodes (w = Spacing, h = Size[xy^1] for when splitting horizontally)
20316 const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
20317 IM_ASSERT(axis != ImGuiAxis_None);
20318 ImRect bb;
20319 bb.Min = child_0->Pos;
20320 bb.Max = child_1->Pos;
20321 bb.Min[axis] += child_0->Size[axis];
20322 bb.Max[axis ^ 1] += child_1->Size[axis ^ 1];
20323 //if (g.IO.KeyCtrl) GetForegroundDrawList(g.CurrentWindow->Viewport)->AddRect(bb.Min, bb.Max, IM_COL32(255,0,255,255));
20324
20325 const ImGuiDockNodeFlags merged_flags = child_0->MergedFlags | child_1->MergedFlags; // Merged flags for BOTH childs
20326 const ImGuiDockNodeFlags no_resize_axis_flag = (axis == ImGuiAxis_X) ? ImGuiDockNodeFlags_NoResizeX : ImGuiDockNodeFlags_NoResizeY;
20327 if ((merged_flags & ImGuiDockNodeFlags_NoResize) || (merged_flags & no_resize_axis_flag))
20328 {
20329 ImGuiWindow* window = g.CurrentWindow;
20330 window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator), g.Style.FrameRounding);
20331 }
20332 else
20333 {
20334 //bb.Min[axis] += 1; // Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node.
20335 //bb.Max[axis] -= 1;
20336 PushID(node->ID);
20337
20338 // Find resizing limits by gathering list of nodes that are touching the splitter line.
20339 ImVector<ImGuiDockNode*> touching_nodes[2];
20340 float min_size = g.Style.WindowMinSize[axis];
20341 float resize_limits[2];
20342 resize_limits[0] = node->ChildNodes[0]->Pos[axis] + min_size;
20343 resize_limits[1] = node->ChildNodes[1]->Pos[axis] + node->ChildNodes[1]->Size[axis] - min_size;
20344
20345 ImGuiID splitter_id = GetID("##Splitter");
20346 if (g.ActiveId == splitter_id) // Only process when splitter is active
20347 {
20348 DockNodeTreeUpdateSplitterFindTouchingNode(child_0, axis, 1, &touching_nodes[0]);
20349 DockNodeTreeUpdateSplitterFindTouchingNode(child_1, axis, 0, &touching_nodes[1]);
20350 for (int touching_node_n = 0; touching_node_n < touching_nodes[0].Size; touching_node_n++)
20351 resize_limits[0] = ImMax(resize_limits[0], touching_nodes[0][touching_node_n]->Rect().Min[axis] + min_size);
20352 for (int touching_node_n = 0; touching_node_n < touching_nodes[1].Size; touching_node_n++)
20353 resize_limits[1] = ImMin(resize_limits[1], touching_nodes[1][touching_node_n]->Rect().Max[axis] - min_size);
20354
20355 // [DEBUG] Render touching nodes & limits
20356 /*
20357 ImDrawList* draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList(GetMainViewport());
20358 for (int n = 0; n < 2; n++)
20359 {
20360 for (int touching_node_n = 0; touching_node_n < touching_nodes[n].Size; touching_node_n++)
20361 draw_list->AddRect(touching_nodes[n][touching_node_n]->Pos, touching_nodes[n][touching_node_n]->Pos + touching_nodes[n][touching_node_n]->Size, IM_COL32(0, 255, 0, 255));

Callers

nothing calls this directly

Calls 4

ImMaxFunction · 0.85
ImMinFunction · 0.85
AddRectFilledMethod · 0.80

Tested by

no test coverage detected