| 16613 | } |
| 16614 | |
| 16615 | static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, const ImGuiDockPreviewData* data) |
| 16616 | { |
| 16617 | ImGuiContext& g = *GImGui; |
| 16618 | IM_ASSERT(g.CurrentWindow == host_window); // Because we rely on font size to calculate tab sizes |
| 16619 | |
| 16620 | // With this option, we only display the preview on the target viewport, and the payload viewport is made transparent. |
| 16621 | // To compensate for the single layer obstructed by the payload, we'll increase the alpha of the preview nodes. |
| 16622 | const bool is_transparent_payload = g.IO.ConfigDockingTransparentPayload; |
| 16623 | |
| 16624 | // In case the two windows involved are on different viewports, we will draw the overlay on each of them. |
| 16625 | int overlay_draw_lists_count = 0; |
| 16626 | ImDrawList* overlay_draw_lists[2]; |
| 16627 | overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(host_window->Viewport); |
| 16628 | if (host_window->Viewport != root_payload->Viewport && !is_transparent_payload) |
| 16629 | overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(root_payload->Viewport); |
| 16630 | |
| 16631 | // Draw main preview rectangle |
| 16632 | const ImU32 overlay_col_main = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.60f : 0.40f); |
| 16633 | const ImU32 overlay_col_drop = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.90f : 0.70f); |
| 16634 | const ImU32 overlay_col_drop_hovered = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 1.20f : 1.00f); |
| 16635 | const ImU32 overlay_col_lines = GetColorU32(ImGuiCol_NavWindowingHighlight, is_transparent_payload ? 0.80f : 0.60f); |
| 16636 | |
| 16637 | // Display area preview |
| 16638 | const bool can_preview_tabs = (root_payload->DockNodeAsHost == NULL || root_payload->DockNodeAsHost->Windows.Size > 0); |
| 16639 | if (data->IsDropAllowed) |
| 16640 | { |
| 16641 | ImRect overlay_rect = data->FutureNode.Rect(); |
| 16642 | if (data->SplitDir == ImGuiDir_None && can_preview_tabs) |
| 16643 | overlay_rect.Min.y += GetFrameHeight(); |
| 16644 | if (data->SplitDir != ImGuiDir_None || data->IsCenterAvailable) |
| 16645 | for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++) |
| 16646 | overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding, CalcRoundingFlagsForRectInRect(overlay_rect, host_window->Rect(), DOCKING_SPLITTER_SIZE)); |
| 16647 | } |
| 16648 | |
| 16649 | // Display tab shape/label preview unless we are splitting node (it generally makes the situation harder to read) |
| 16650 | if (data->IsDropAllowed && can_preview_tabs && data->SplitDir == ImGuiDir_None && data->IsCenterAvailable) |
| 16651 | { |
| 16652 | // Compute target tab bar geometry so we can locate our preview tabs |
| 16653 | ImRect tab_bar_rect; |
| 16654 | DockNodeCalcTabBarLayout(&data->FutureNode, NULL, &tab_bar_rect, NULL, NULL); |
| 16655 | ImVec2 tab_pos = tab_bar_rect.Min; |
| 16656 | if (host_node && host_node->TabBar) |
| 16657 | { |
| 16658 | if (!host_node->IsHiddenTabBar() && !host_node->IsNoTabBar()) |
| 16659 | 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. |
| 16660 | else |
| 16661 | tab_pos.x += g.Style.ItemInnerSpacing.x + TabItemCalcSize(host_node->Windows[0]).x; |
| 16662 | } |
| 16663 | else if (!(host_window->Flags & ImGuiWindowFlags_DockNodeHost)) |
| 16664 | { |
| 16665 | 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 |
| 16666 | } |
| 16667 | |
| 16668 | // Draw tab shape/label preview (payload may be a loose window or a host window carrying multiple tabbed windows) |
| 16669 | if (root_payload->DockNodeAsHost) |
| 16670 | IM_ASSERT(root_payload->DockNodeAsHost->Windows.Size <= root_payload->DockNodeAsHost->TabBar->Tabs.Size); |
| 16671 | ImGuiTabBar* tab_bar_with_payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar : NULL; |
| 16672 | const int payload_count = tab_bar_with_payload ? tab_bar_with_payload->Tabs.Size : 1; |
nothing calls this directly
no test coverage detected