host_node may be NULL if the window doesn't have a DockNode already. FIXME-DOCK: This is misnamed since it's also doing the filtering.
| 15485 | // host_node may be NULL if the window doesn't have a DockNode already. |
| 15486 | // FIXME-DOCK: This is misnamed since it's also doing the filtering. |
| 15487 | static void ImGui::DockNodePreviewDockSetup(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, ImGuiDockPreviewData* data, bool is_explicit_target, bool is_outer_docking) |
| 15488 | { |
| 15489 | ImGuiContext& g = *GImGui; |
| 15490 | |
| 15491 | // There is an edge case when docking into a dockspace which only has inactive nodes. |
| 15492 | // In this case DockNodeTreeFindNodeByPos() will have selected a leaf node which is inactive. |
| 15493 | // Because the inactive leaf node doesn't have proper pos/size yet, we'll use the root node as reference. |
| 15494 | ImGuiDockNode* root_payload_as_host = root_payload->DockNodeAsHost; |
| 15495 | ImGuiDockNode* ref_node_for_rect = (host_node && !host_node->IsVisible) ? DockNodeGetRootNode(host_node) : host_node; |
| 15496 | if (ref_node_for_rect) |
| 15497 | IM_ASSERT(ref_node_for_rect->IsVisible); |
| 15498 | |
| 15499 | // Filter, figure out where we are allowed to dock |
| 15500 | ImGuiDockNodeFlags src_node_flags = root_payload_as_host ? root_payload_as_host->MergedFlags : root_payload->WindowClass.DockNodeFlagsOverrideSet; |
| 15501 | ImGuiDockNodeFlags dst_node_flags = host_node ? host_node->MergedFlags : host_window->WindowClass.DockNodeFlagsOverrideSet; |
| 15502 | data->IsCenterAvailable = true; |
| 15503 | if (is_outer_docking) |
| 15504 | data->IsCenterAvailable = false; |
| 15505 | else if (dst_node_flags & ImGuiDockNodeFlags_NoDocking) |
| 15506 | data->IsCenterAvailable = false; |
| 15507 | else if (host_node && (dst_node_flags & ImGuiDockNodeFlags_NoDockingInCentralNode) && host_node->IsCentralNode()) |
| 15508 | data->IsCenterAvailable = false; |
| 15509 | else if ((!host_node || !host_node->IsEmpty()) && root_payload_as_host && root_payload_as_host->IsSplitNode() && (root_payload_as_host->OnlyNodeWithWindows == NULL)) // Is _visibly_ split? |
| 15510 | data->IsCenterAvailable = false; |
| 15511 | else if (dst_node_flags & ImGuiDockNodeFlags_NoDockingOverMe) |
| 15512 | data->IsCenterAvailable = false; |
| 15513 | else if ((src_node_flags & ImGuiDockNodeFlags_NoDockingOverOther) && (!host_node || !host_node->IsEmpty())) |
| 15514 | data->IsCenterAvailable = false; |
| 15515 | else if ((src_node_flags & ImGuiDockNodeFlags_NoDockingOverEmpty) && host_node && host_node->IsEmpty()) |
| 15516 | data->IsCenterAvailable = false; |
| 15517 | |
| 15518 | data->IsSidesAvailable = true; |
| 15519 | if ((dst_node_flags & ImGuiDockNodeFlags_NoSplit) || g.IO.ConfigDockingNoSplit) |
| 15520 | data->IsSidesAvailable = false; |
| 15521 | else if (!is_outer_docking && host_node && host_node->ParentNode == NULL && host_node->IsCentralNode()) |
| 15522 | data->IsSidesAvailable = false; |
| 15523 | else if ((dst_node_flags & ImGuiDockNodeFlags_NoDockingSplitMe) || (src_node_flags & ImGuiDockNodeFlags_NoDockingSplitOther)) |
| 15524 | data->IsSidesAvailable = false; |
| 15525 | |
| 15526 | // Build a tentative future node (reuse same structure because it is practical. Shape will be readjusted when previewing a split) |
| 15527 | data->FutureNode.HasCloseButton = (host_node ? host_node->HasCloseButton : host_window->HasCloseButton) || (root_payload->HasCloseButton); |
| 15528 | data->FutureNode.HasWindowMenuButton = host_node ? true : ((host_window->Flags & ImGuiWindowFlags_NoCollapse) == 0); |
| 15529 | data->FutureNode.Pos = ref_node_for_rect ? ref_node_for_rect->Pos : host_window->Pos; |
| 15530 | data->FutureNode.Size = ref_node_for_rect ? ref_node_for_rect->Size : host_window->Size; |
| 15531 | |
| 15532 | // Calculate drop shapes geometry for allowed splitting directions |
| 15533 | IM_ASSERT(ImGuiDir_None == -1); |
| 15534 | data->SplitNode = host_node; |
| 15535 | data->SplitDir = ImGuiDir_None; |
| 15536 | data->IsSplitDirExplicit = false; |
| 15537 | if (!host_window->Collapsed) |
| 15538 | for (int dir = ImGuiDir_None; dir < ImGuiDir_COUNT; dir++) |
| 15539 | { |
| 15540 | if (dir == ImGuiDir_None && !data->IsCenterAvailable) |
| 15541 | continue; |
| 15542 | if (dir != ImGuiDir_None && !data->IsSidesAvailable) |
| 15543 | continue; |
| 15544 | if (DockNodeCalcDropRectsAndTestMousePos(data->FutureNode.Rect(), (ImGuiDir)dir, data->DropRectsDraw[dir+1], is_outer_docking, &g.IO.MousePos)) |
nothing calls this directly
no test coverage detected