| 2820 | ImGui::SetNextWindowDockID(0, ImGuiCond_Always); |
| 2821 | } |
| 2822 | |
| 2823 | EditorTool->bInitialDockApplied = true; |
| 2824 | |
| 2825 | ImGuiWindowFlags WindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar; |
| 2826 | if (EditorTool->IsUnsavedDocument()) |
| 2827 | { |
| 2828 | WindowFlags |= ImGuiWindowFlags_UnsavedDocument; |
| 2829 | } |
| 2830 | |
| 2831 | ImGuiWindow* CurrentWindow = ImGui::FindWindowByName(*EditorTool->GetToolName()); |
| 2832 | const bool bVisible = CurrentWindow != nullptr && !CurrentWindow->Hidden; |
| 2833 | |
| 2834 | ImVec4 VisibleColor = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); |
| 2835 | ImVec4 NotVisibleColor = ImVec4(0.4f, 0.4f, 0.4f, 1.0f); |
| 2836 | |
| 2837 | ImGui::PushStyleColor(ImGuiCol_Text, bVisible ? VisibleColor : NotVisibleColor); |
| 2838 | // Read when the window begins, so the toolbar sits flat on the window with only a hairline beneath it. |
| 2839 | ImGui::PushStyleColor(ImGuiCol_MenuBarBg, EditorColors::WindowBg()); |
| 2840 | ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); |
| 2841 | ImGui::SetNextWindowSizeConstraints(ImVec2(128, 128), ImVec2(FLT_MAX, FLT_MAX)); |
| 2842 | ImGui::SetNextWindowSize(ImVec2(1024, 768), ImGuiCond_FirstUseEver); |
| 2843 | |
| 2844 | // CurrDockID is last frame's value while CurrentWindow->DockId is the upcoming assignment. |
| 2845 | const ImGuiID PrevFrameDockID = EditorTool->CurrDockID; |
| 2846 | const ImGuiID NextFrameDockID = CurrentWindow ? CurrentWindow->DockId : 0; |
| 2847 | if (PrevFrameDockID != 0 && NextFrameDockID == 0 && CurrentWindow != nullptr) |
| 2848 | { |
| 2849 | constexpr ImVec2 UndockedSize(1177.6f, 883.2f); |
| 2850 | const ImGuiViewport* MainViewport = ImGui::GetMainViewport(); |
| 2851 | const ImVec2 UndockedPos |
| 2852 | { |
| 2853 | MainViewport->Pos.x + (MainViewport->Size.x - UndockedSize.x) * 0.5f, |
| 2854 | MainViewport->Pos.y + (MainViewport->Size.y - UndockedSize.y) * 0.5f, |
| 2855 | }; |
| 2856 | ImGui::SetNextWindowSize(UndockedSize, ImGuiCond_Always); |
| 2857 | ImGui::SetNextWindowPos(UndockedPos, ImGuiCond_Always); |
| 2858 | } |
| 2859 | |
| 2860 | ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.5f); |
| 2861 | ImGui::Begin(*EditorTool->GetToolName(), bIsToolOpen, WindowFlags); |
| 2862 | ImGui::PopStyleVar(2); |
| 2863 | ImGui::PopStyleColor(2); |
| 2864 | |
| 2865 | if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_DockHierarchy)) |
| 2866 | { |
| 2867 | LastActiveTool = EditorTool; |
| 2868 | if (EditorTool->HasWorld()) |
| 2869 | { |
| 2870 | LastActiveWorldTool = EditorTool; |
| 2871 | } |
| 2872 | } |
| 2873 | |
| 2874 | // Per-document ID, so tabs from one document are not dockable in another. |
| 2875 | EditorTool->ToolWindowsClass.ClassId = (ImGuiID)EditorTool->GetID(); |
| 2876 | EditorTool->ToolWindowsClass.ViewportFlagsOverrideSet = ImGuiViewportFlags_NoTaskBarIcon | ImGuiViewportFlags_NoDecoration | ImGuiViewportFlags_TopMost; |
| 2877 | EditorTool->ToolWindowsClass.ParentViewportId = ImGui::GetWindowViewport()->ID; |
| 2878 | EditorTool->ToolWindowsClass.DockingAllowUnclassed = true; |
| 2879 |
nothing calls this directly
no test coverage detected