| 19970 | } |
| 19971 | |
| 19972 | static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, const ImGuiDockPreviewData* data) |
| 19973 | { |
| 19974 | ImGuiContext& g = *GImGui; |
| 19975 | IM_ASSERT(g.CurrentWindow == host_window); // Because we rely on font size to calculate tab sizes |
| 19976 | |
| 19977 | // With this option, we only display the preview on the target viewport, and the payload viewport is made transparent. |
| 19978 | // To compensate for the single layer obstructed by the payload, we'll increase the alpha of the preview nodes. |
| 19979 | const bool is_transparent_payload = g.IO.ConfigDockingTransparentPayload; |
| 19980 | |
| 19981 | // In case the two windows involved are on different viewports, we will draw the overlay on each of them. |
| 19982 | int overlay_draw_lists_count = 0; |
| 19983 | ImDrawList* overlay_draw_lists[2]; |
| 19984 | overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(host_window->Viewport); |
| 19985 | if (host_window->Viewport != root_payload->Viewport && !is_transparent_payload) |
| 19986 | overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(root_payload->Viewport); |
| 19987 | |
| 19988 | // Draw main preview rectangle |
| 19989 | const ImU32 overlay_col_main = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.60f : 0.40f); |
| 19990 | const ImU32 overlay_col_drop = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.90f : 0.70f); |
| 19991 | const ImU32 overlay_col_drop_hovered = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 1.20f : 1.00f); |
| 19992 | const ImU32 overlay_col_lines = GetColorU32(ImGuiCol_NavWindowingHighlight, is_transparent_payload ? 0.80f : 0.60f); |
| 19993 | |
| 19994 | // Display area preview |
| 19995 | const bool can_preview_tabs = (root_payload->DockNodeAsHost == NULL || root_payload->DockNodeAsHost->Windows.Size > 0); |
| 19996 | if (data->IsDropAllowed) |
| 19997 | { |
| 19998 | ImRect overlay_rect = data->FutureNode.Rect(); |
| 19999 | if (data->SplitDir == ImGuiDir_None && can_preview_tabs) |
| 20000 | overlay_rect.Min.y += GetFrameHeight(); |
| 20001 | if (data->SplitDir != ImGuiDir_None || data->IsCenterAvailable) |
| 20002 | for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++) |
| 20003 | overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding, CalcRoundingFlagsForRectInRect(overlay_rect, host_window->Rect(), g.Style.DockingSeparatorSize)); |
| 20004 | } |
| 20005 | |
| 20006 | // Display tab shape/label preview unless we are splitting node (it generally makes the situation harder to read) |
| 20007 | if (data->IsDropAllowed && can_preview_tabs && data->SplitDir == ImGuiDir_None && data->IsCenterAvailable) |
| 20008 | { |
| 20009 | // Compute target tab bar geometry so we can locate our preview tabs |
| 20010 | ImRect tab_bar_rect; |
| 20011 | DockNodeCalcTabBarLayout(&data->FutureNode, NULL, &tab_bar_rect, NULL, NULL); |
| 20012 | ImVec2 tab_pos = tab_bar_rect.Min; |
| 20013 | if (host_node && host_node->TabBar) |
| 20014 | { |
| 20015 | if (!host_node->IsHiddenTabBar() && !host_node->IsNoTabBar()) |
| 20016 | tab_pos.x += host_node->TabBar->WidthAllTabs + g.Style.ItemInnerSpacing.x; // We don't use OffsetNewTab because when using non-persistent-order tab bar it is incremented with each Tab submission. |
| 20017 | else |
| 20018 | tab_pos.x += g.Style.ItemInnerSpacing.x + TabItemCalcSize(host_node->Windows[0]).x; |
| 20019 | } |
| 20020 | else if (!(host_window->Flags & ImGuiWindowFlags_DockNodeHost)) |
| 20021 | { |
| 20022 | tab_pos.x += g.Style.ItemInnerSpacing.x + TabItemCalcSize(host_window).x; // Account for slight offset which will be added when changing from title bar to tab bar |
| 20023 | } |
| 20024 | |
| 20025 | // Draw tab shape/label preview (payload may be a loose window or a host window carrying multiple tabbed windows) |
| 20026 | if (root_payload->DockNodeAsHost) |
| 20027 | IM_ASSERT(root_payload->DockNodeAsHost->Windows.Size <= root_payload->DockNodeAsHost->TabBar->Tabs.Size); |
| 20028 | ImGuiTabBar* tab_bar_with_payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar : NULL; |
| 20029 | const int payload_count = tab_bar_with_payload ? tab_bar_with_payload->Tabs.Size : 1; |
nothing calls this directly
no test coverage detected