| 2532 | const ImVec2 ViewportAvail = ImGui::GetContentRegionAvail(); |
| 2533 | SceneRenderer->SetPrimaryViewSize(FUIntVector2( |
| 2534 | (uint32)eastl::max(ViewportAvail.x, 64.0f), |
| 2535 | (uint32)eastl::max(ViewportAvail.y, 64.0f))); |
| 2536 | |
| 2537 | ImTextureRef ViewportTexture = ImGuiX::ToImTextureRef(SceneRenderer->GetDisplayResourceID()); |
| 2538 | |
| 2539 | Tool->bViewportFocused = ImGui::IsWindowFocused(); |
| 2540 | Tool->bViewportHovered = ImGui::IsWindowHovered(); |
| 2541 | Tool->UpdateViewportInput(UpdateContext); |
| 2542 | Tool->DrawViewport(UpdateContext, ViewportTexture); |
| 2543 | } |
| 2544 | |
| 2545 | ImGui::End(); |
| 2546 | } |
| 2547 | else |
| 2548 | { |
| 2549 | ImGui::SetNextWindowClass(&Tool->ToolWindowsClass); |
| 2550 | ImGui::SetNextWindowSizeConstraints(ImVec2(128, 128), ImVec2(FLT_MAX, FLT_MAX)); |
| 2551 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); |
| 2552 | bool const DrawViewportWindow = ImGui::Begin(ToolWindowName.c_str(), nullptr, ViewportWindowFlags); |
| 2553 | ImGui::PopStyleVar(); |
| 2554 | |
| 2555 | if (DrawViewportWindow) |
| 2556 | { |
| 2557 | IRenderScene* SceneRenderer = Tool->GetWorld()->GetRenderer(); |
| 2558 | |
| 2559 | // Size the scene to the panel that displays it, not the window. ImGui works in |
| 2560 | // physical pixels here (Io.DisplaySize is the swapchain extent), so the content |
| 2561 | // region is already the right unit. Floor matches DrawViewport's. |
| 2562 | const ImVec2 ViewportAvail = ImGui::GetContentRegionAvail(); |
| 2563 | SceneRenderer->SetPrimaryViewSize(FUIntVector2( |
| 2564 | (uint32)eastl::max(ViewportAvail.x, 64.0f), |
| 2565 | (uint32)eastl::max(ViewportAvail.y, 64.0f))); |
| 2566 | |
| 2567 | ImTextureRef ViewportTexture = ImGuiX::ToImTextureRef(SceneRenderer->GetDisplayResourceID()); |
| 2568 | |
| 2569 | Tool->bViewportFocused = ImGui::IsWindowFocused(); |
| 2570 | Tool->bViewportHovered = ImGui::IsWindowHovered(); |
| 2571 | Tool->UpdateViewportInput(UpdateContext); |
| 2572 | Tool->DrawViewport(UpdateContext, ViewportTexture); |
| 2573 | } |
| 2574 | |
| 2575 | ImGui::End(); |
| 2576 | } |
| 2577 | } |
| 2578 | else |
| 2579 | { |
| 2580 | LUMINA_PROFILE_SECTION("Draw Tool Window"); |
| 2581 | |
| 2582 | ImGuiWindowFlags ToolWindowFlags = ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoCollapse; |
| 2583 | |
| 2584 | if (Window->bDisableScrolling) |
| 2585 | { |
| 2586 | ToolWindowFlags |= ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; |
| 2587 | } |
| 2588 | |
| 2589 | ImGui::SetNextWindowClass(&Tool->ToolWindowsClass); |
| 2590 | // Floor the size so a panel can't be dragged to a degenerate extent (child widgets assert at zero width). |
| 2591 | ImGui::SetNextWindowSizeConstraints(ImVec2(100.0f, 80.0f), ImVec2(FLT_MAX, FLT_MAX)); |
nothing calls this directly
no test coverage detected