| 12874 | #ifndef IMGUI_DISABLE_DEBUG_TOOLS |
| 12875 | |
| 12876 | void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb) |
| 12877 | { |
| 12878 | ImGuiContext& g = *GImGui; |
| 12879 | ImGuiWindow* window = g.CurrentWindow; |
| 12880 | |
| 12881 | ImVec2 scale = bb.GetSize() / viewport->Size; |
| 12882 | ImVec2 off = bb.Min - viewport->Pos * scale; |
| 12883 | float alpha_mul = 1.0f; |
| 12884 | window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f)); |
| 12885 | for (int i = 0; i != g.Windows.Size; i++) |
| 12886 | { |
| 12887 | ImGuiWindow* thumb_window = g.Windows[i]; |
| 12888 | if (!thumb_window->WasActive || (thumb_window->Flags & ImGuiWindowFlags_ChildWindow)) |
| 12889 | continue; |
| 12890 | |
| 12891 | ImRect thumb_r = thumb_window->Rect(); |
| 12892 | ImRect title_r = thumb_window->TitleBarRect(); |
| 12893 | thumb_r = ImRect(ImFloor(off + thumb_r.Min * scale), ImFloor(off + thumb_r.Max * scale)); |
| 12894 | title_r = ImRect(ImFloor(off + title_r.Min * scale), ImFloor(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0,5)); // Exaggerate title bar height |
| 12895 | thumb_r.ClipWithFull(bb); |
| 12896 | title_r.ClipWithFull(bb); |
| 12897 | const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight); |
| 12898 | window->DrawList->AddRectFilled(thumb_r.Min, thumb_r.Max, GetColorU32(ImGuiCol_WindowBg, alpha_mul)); |
| 12899 | window->DrawList->AddRectFilled(title_r.Min, title_r.Max, GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg, alpha_mul)); |
| 12900 | window->DrawList->AddRect(thumb_r.Min, thumb_r.Max, GetColorU32(ImGuiCol_Border, alpha_mul)); |
| 12901 | window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r.Min, GetColorU32(ImGuiCol_Text, alpha_mul), thumb_window->Name, FindRenderedTextEnd(thumb_window->Name)); |
| 12902 | } |
| 12903 | draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul)); |
| 12904 | } |
| 12905 | |
| 12906 | static void RenderViewportsThumbnails() |
| 12907 | { |