diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index 021be31d..95dc6fd2 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -544,6 +544,7 @@ void ImGui_ImplDX10_NewFrame() // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataDx10 { IDXGISwapChain* SwapChain; diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index f03177f2..ffd05625 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -560,6 +560,7 @@ void ImGui_ImplDX11_NewFrame() // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataDx11 { IDXGISwapChain* SwapChain; diff --git a/examples/imgui_impl_dx12.cpp b/examples/imgui_impl_dx12.cpp index 5beadf0d..3ead29c5 100644 --- a/examples/imgui_impl_dx12.cpp +++ b/examples/imgui_impl_dx12.cpp @@ -66,6 +66,7 @@ struct FrameContext D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetCpuDescriptors; }; +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataDx12 { ID3D12CommandQueue* CommandQueue; diff --git a/examples/imgui_impl_dx9.cpp b/examples/imgui_impl_dx9.cpp index 2dd0ee8c..ab1b6578 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/examples/imgui_impl_dx9.cpp @@ -310,6 +310,7 @@ void ImGui_ImplDX9_NewFrame() // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataDx9 { IDirect3DSwapChain9* SwapChain; diff --git a/examples/imgui_impl_glfw.cpp b/examples/imgui_impl_glfw.cpp index ed03aece..388942c6 100644 --- a/examples/imgui_impl_glfw.cpp +++ b/examples/imgui_impl_glfw.cpp @@ -428,6 +428,7 @@ void ImGui_ImplGlfw_NewFrame() // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataGlfw { GLFWwindow* Window; @@ -496,7 +497,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport) #endif glfwSetWindowPos(data->Window, (int)viewport->Pos.x, (int)viewport->Pos.y); - // Install callbacks for secondary viewports + // Install GLFW callbacks for secondary viewports glfwSetMouseButtonCallback(data->Window, ImGui_ImplGlfw_MouseButtonCallback); glfwSetScrollCallback(data->Window, ImGui_ImplGlfw_ScrollCallback); glfwSetKeyCallback(data->Window, ImGui_ImplGlfw_KeyCallback); @@ -529,7 +530,8 @@ static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport) viewport->PlatformUserData = viewport->PlatformHandle = NULL; } -// FIXME-VIEWPORT: Implement same work-around for Linux/OSX in the meanwhile. +// We have submitted https://github.com/glfw/glfw/pull/1568 to allow GLFW to support "transparent inputs". +// In the meanwhile we implement custom per-platform workarounds here (FIXME-VIEWPORT: Implement same work-around for Linux/OSX!) #if defined(_WIN32) && GLFW_HAS_GLFW_HOVERED static WNDPROC g_GlfwWndProc = NULL; static LRESULT CALLBACK WndProcNoInputs(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -733,7 +735,6 @@ static int ImGui_ImplGlfw_CreateVkSurface(ImGuiViewport* viewport, ImU64 vk_inst } #endif // GLFW_HAS_VULKAN -// FIXME-PLATFORM: GLFW doesn't export monitor work area (see https://github.com/glfw/glfw/pull/989) static void ImGui_ImplGlfw_UpdateMonitors() { ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); @@ -805,6 +806,7 @@ static void ImGui_ImplGlfw_InitPlatformInterface() glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback); // Register main window handle (which is owned by the main application, not by us) + // This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports. ImGuiViewport* main_viewport = ImGui::GetMainViewport(); ImGuiViewportDataGlfw* data = IM_NEW(ImGuiViewportDataGlfw)(); data->Window = g_Window; diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 63021d39..ebb1ff15 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -432,6 +432,7 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window) // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataSDL2 { SDL_Window* Window; @@ -685,6 +686,7 @@ static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_g ImGui_ImplSDL2_UpdateMonitors(); // Register main window handle (which is owned by the main application, not by us) + // This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports. ImGuiViewport* main_viewport = ImGui::GetMainViewport(); ImGuiViewportDataSDL2* data = IM_NEW(ImGuiViewportDataSDL2)(); data->Window = window; diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp index a503703e..3d0ad9a1 100644 --- a/examples/imgui_impl_vulkan.cpp +++ b/examples/imgui_impl_vulkan.cpp @@ -70,7 +70,8 @@ struct ImGui_ImplVulkanH_WindowRenderBuffers ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers; }; -// For multi-viewport support +// For multi-viewport support: +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataVulkan { bool WindowOwned; diff --git a/examples/imgui_impl_win32.cpp b/examples/imgui_impl_win32.cpp index 61750145..cc190093 100644 --- a/examples/imgui_impl_win32.cpp +++ b/examples/imgui_impl_win32.cpp @@ -511,6 +511,7 @@ static void ImGui_ImplWin32_SetImeInputPos(ImGuiViewport* viewport, ImVec2 pos) // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. //-------------------------------------------------------------------------------------------------------- +// Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. struct ImGuiViewportDataWin32 { HWND Hwnd; @@ -831,6 +832,7 @@ static void ImGui_ImplWin32_InitPlatformInterface() #endif // Register main window handle (which is owned by the main application, not by us) + // This is mostly for simplicity and consistency, so that our code (e.g. mouse handling etc.) can use same logic for main and secondary viewports. ImGuiViewport* main_viewport = ImGui::GetMainViewport(); ImGuiViewportDataWin32* data = IM_NEW(ImGuiViewportDataWin32)(); data->Hwnd = g_hWnd; diff --git a/imgui.cpp b/imgui.cpp index a58b6faf..82d8eee0 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3326,7 +3326,7 @@ static ImDrawList* GetViewportDrawList(ImGuiViewportP* viewport, size_t drawlist { // Create the draw list on demand, because they are not frequently used for all viewports ImGuiContext& g = *GImGui; - IM_ASSERT(drawlist_no >= 0 && drawlist_no < IM_ARRAYSIZE(viewport->DrawLists)); + IM_ASSERT(drawlist_no < IM_ARRAYSIZE(viewport->DrawLists)); ImDrawList* draw_list = viewport->DrawLists[drawlist_no]; if (draw_list == NULL) { diff --git a/imgui.h b/imgui.h index c74fc7ca..cee80e35 100644 --- a/imgui.h +++ b/imgui.h @@ -1159,7 +1159,7 @@ enum ImGuiCol_ ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive, - ImGuiCol_DockingPreview, + ImGuiCol_DockingPreview, // Preview overlay color when about to docking something ImGuiCol_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it) ImGuiCol_PlotLines, ImGuiCol_PlotLinesHovered, @@ -2463,8 +2463,8 @@ struct ImGuiViewport ImDrawData* DrawData; // The ImDrawData corresponding to this viewport. Valid after Render() and until the next call to NewFrame(). ImGuiID ParentViewportId; // (Advanced) 0: no parent. Instruct the platform back-end to setup a parent/child relationship between platform windows. - void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.) - void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context) + void* RendererUserData; // void* to hold custom data structure for the renderer (e.g. swap chain, frame-buffers etc.). If somehow everything you need can fit in the void* PlatformHandle field you may ignore this. + void* PlatformUserData; // void* to hold custom data structure for the OS / platform (e.g. windowing info, render context). If somehow everything you need can fit in the void* PlatformHandle field you may ignore this. void* PlatformHandle; // void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*) void* PlatformHandleRaw; // void* to hold low-level, platform-native window handle (e.g. the HWND) when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*) bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)