mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 22:26:34 +00:00
Viewports: Add various comments
This commit is contained in:
parent
7e068da2bd
commit
f1b5c742ff
@ -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..
|
// 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
|
struct ImGuiViewportDataDx10
|
||||||
{
|
{
|
||||||
IDXGISwapChain* SwapChain;
|
IDXGISwapChain* SwapChain;
|
||||||
|
@ -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..
|
// 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
|
struct ImGuiViewportDataDx11
|
||||||
{
|
{
|
||||||
IDXGISwapChain* SwapChain;
|
IDXGISwapChain* SwapChain;
|
||||||
|
@ -66,6 +66,7 @@ struct FrameContext
|
|||||||
D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetCpuDescriptors;
|
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
|
struct ImGuiViewportDataDx12
|
||||||
{
|
{
|
||||||
ID3D12CommandQueue* CommandQueue;
|
ID3D12CommandQueue* CommandQueue;
|
||||||
|
@ -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..
|
// 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
|
struct ImGuiViewportDataDx9
|
||||||
{
|
{
|
||||||
IDirect3DSwapChain9* SwapChain;
|
IDirect3DSwapChain9* SwapChain;
|
||||||
|
@ -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..
|
// 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
|
struct ImGuiViewportDataGlfw
|
||||||
{
|
{
|
||||||
GLFWwindow* Window;
|
GLFWwindow* Window;
|
||||||
@ -496,7 +497,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
|||||||
#endif
|
#endif
|
||||||
glfwSetWindowPos(data->Window, (int)viewport->Pos.x, (int)viewport->Pos.y);
|
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);
|
glfwSetMouseButtonCallback(data->Window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||||
glfwSetScrollCallback(data->Window, ImGui_ImplGlfw_ScrollCallback);
|
glfwSetScrollCallback(data->Window, ImGui_ImplGlfw_ScrollCallback);
|
||||||
glfwSetKeyCallback(data->Window, ImGui_ImplGlfw_KeyCallback);
|
glfwSetKeyCallback(data->Window, ImGui_ImplGlfw_KeyCallback);
|
||||||
@ -529,7 +530,8 @@ static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
|
|||||||
viewport->PlatformUserData = viewport->PlatformHandle = NULL;
|
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
|
#if defined(_WIN32) && GLFW_HAS_GLFW_HOVERED
|
||||||
static WNDPROC g_GlfwWndProc = NULL;
|
static WNDPROC g_GlfwWndProc = NULL;
|
||||||
static LRESULT CALLBACK WndProcNoInputs(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
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
|
#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()
|
static void ImGui_ImplGlfw_UpdateMonitors()
|
||||||
{
|
{
|
||||||
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
|
||||||
@ -805,6 +806,7 @@ static void ImGui_ImplGlfw_InitPlatformInterface()
|
|||||||
glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
|
glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback);
|
||||||
|
|
||||||
// Register main window handle (which is owned by the main application, not by us)
|
// 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();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
ImGuiViewportDataGlfw* data = IM_NEW(ImGuiViewportDataGlfw)();
|
ImGuiViewportDataGlfw* data = IM_NEW(ImGuiViewportDataGlfw)();
|
||||||
data->Window = g_Window;
|
data->Window = g_Window;
|
||||||
|
@ -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..
|
// 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
|
struct ImGuiViewportDataSDL2
|
||||||
{
|
{
|
||||||
SDL_Window* Window;
|
SDL_Window* Window;
|
||||||
@ -685,6 +686,7 @@ static void ImGui_ImplSDL2_InitPlatformInterface(SDL_Window* window, void* sdl_g
|
|||||||
ImGui_ImplSDL2_UpdateMonitors();
|
ImGui_ImplSDL2_UpdateMonitors();
|
||||||
|
|
||||||
// Register main window handle (which is owned by the main application, not by us)
|
// 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();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
ImGuiViewportDataSDL2* data = IM_NEW(ImGuiViewportDataSDL2)();
|
ImGuiViewportDataSDL2* data = IM_NEW(ImGuiViewportDataSDL2)();
|
||||||
data->Window = window;
|
data->Window = window;
|
||||||
|
@ -70,7 +70,8 @@ struct ImGui_ImplVulkanH_WindowRenderBuffers
|
|||||||
ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers;
|
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
|
struct ImGuiViewportDataVulkan
|
||||||
{
|
{
|
||||||
bool WindowOwned;
|
bool WindowOwned;
|
||||||
|
@ -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..
|
// 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
|
struct ImGuiViewportDataWin32
|
||||||
{
|
{
|
||||||
HWND Hwnd;
|
HWND Hwnd;
|
||||||
@ -831,6 +832,7 @@ static void ImGui_ImplWin32_InitPlatformInterface()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Register main window handle (which is owned by the main application, not by us)
|
// 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();
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||||
ImGuiViewportDataWin32* data = IM_NEW(ImGuiViewportDataWin32)();
|
ImGuiViewportDataWin32* data = IM_NEW(ImGuiViewportDataWin32)();
|
||||||
data->Hwnd = g_hWnd;
|
data->Hwnd = g_hWnd;
|
||||||
|
@ -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
|
// Create the draw list on demand, because they are not frequently used for all viewports
|
||||||
ImGuiContext& g = *GImGui;
|
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];
|
ImDrawList* draw_list = viewport->DrawLists[drawlist_no];
|
||||||
if (draw_list == NULL)
|
if (draw_list == NULL)
|
||||||
{
|
{
|
||||||
|
6
imgui.h
6
imgui.h
@ -1159,7 +1159,7 @@ enum ImGuiCol_
|
|||||||
ImGuiCol_TabActive,
|
ImGuiCol_TabActive,
|
||||||
ImGuiCol_TabUnfocused,
|
ImGuiCol_TabUnfocused,
|
||||||
ImGuiCol_TabUnfocusedActive,
|
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_DockingEmptyBg, // Background color for empty node (e.g. CentralNode with no window docked into it)
|
||||||
ImGuiCol_PlotLines,
|
ImGuiCol_PlotLines,
|
||||||
ImGuiCol_PlotLinesHovered,
|
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().
|
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.
|
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* 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)
|
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* 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*)
|
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)
|
bool PlatformRequestClose; // Platform window requested closure (e.g. window was moved by the OS / host window manager, e.g. pressing ALT-F4)
|
||||||
|
Loading…
Reference in New Issue
Block a user