Viewports: added ImGuiBackendFlags_HasParentViewportId backend flag. (#8948)

This commit is contained in:
ocornut
2025-09-30 17:38:06 +02:00
parent b4514ce64a
commit 50a8bb2711
12 changed files with 27 additions and 13 deletions

View File

@@ -534,7 +534,8 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
io.BackendPlatformName = bd->BackendPlatformName;
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
// (ImGuiBackendFlags_PlatformHasViewports may be set just below)
// (ImGuiBackendFlags_PlatformHasViewports and ImGuiBackendFlags_HasParentViewportId may be set just below)
// (ImGuiBackendFlags_HasMouseHoveredViewport is set dynamically in our _NewFrame function)
bd->Window = window;
bd->WindowID = SDL_GetWindowID(window);
@@ -560,7 +561,10 @@ static bool ImGui_ImplSDL3_Init(SDL_Window* window, SDL_Renderer* renderer, void
bd->MouseCanUseGlobalState = bd->MouseCanUseCapture = true;
#endif
if (bd->MouseCanUseGlobalState)
{
io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional)
io.BackendFlags |= ImGuiBackendFlags_HasParentViewportId; // We can honor viewport->ParentViewportId by applying the corresponding parent/child relationship at platform levle (optional)
}
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
@@ -675,7 +679,7 @@ void ImGui_ImplSDL3_Shutdown()
io.BackendPlatformName = nullptr;
io.BackendPlatformUserData = nullptr;
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport);
io.BackendFlags &= ~(ImGuiBackendFlags_HasMouseCursors | ImGuiBackendFlags_HasSetMousePos | ImGuiBackendFlags_HasGamepad | ImGuiBackendFlags_PlatformHasViewports | ImGuiBackendFlags_HasMouseHoveredViewport | ImGuiBackendFlags_HasParentViewportId);
platform_io.ClearPlatformHandlers();
IM_DELETE(bd);
}