Viewport, Platform: Refactored platform interface. Removed need to use imgui_internal.h in backends. Split viewport into public facing ImGuiViewport and internal structure. Exposing enough data to provide custom tweaked renderers. Renamed handlers, fixed lots of inconsistencies. (#1542, #1042)
// (minor and older changes stripped away, please see git history for details)
// (minor and older changes stripped away, please see git history for details)
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiRendererInterface.
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2018-XX-XX: DirectX10: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
// 2018-XX-XX: DirectX10: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX10_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX10_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// (minor and older changes stripped away, please see git history for details)
// (minor and older changes stripped away, please see git history for details)
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiRendererInterface.
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2018-XX-XX: DirectX11: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
// 2018-XX-XX: DirectX11: Offset projection matrix and clipping rectangle by draw_data->DisplayPos (which will be non-zero for multi-viewport applications).
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX11_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX11_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// (minor and older changes stripped away, please see git history for details)
// (minor and older changes stripped away, please see git history for details)
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformInterface
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2018-XX-XX: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
// 2018-XX-XX: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
// (minor and older changes stripped away, please see git history for details)
// (minor and older changes stripped away, please see git history for details)
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformInterface
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
// 2018-XX-XX: Misc: ImGui_ImplSDL2_Init() now takes a SDL_GLContext parameter.
// 2018-XX-XX: Misc: ImGui_ImplSDL2_Init() now takes a SDL_GLContext parameter.
// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// (We pass an error message in the assert expression as a trick to get it visible to programmers who are not using a debugger, as most assert handlers display their argument)
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
IM_ASSERT(g.Initialized);
IM_ASSERT(g.Initialized);
IM_ASSERT(g.IO.DeltaTime>=0.0f&&"Need a positive DeltaTime (zero is tolerated but will cause some timing issues)");
IM_ASSERT(g.IO.DeltaTime>=0.0f&&"Need a positive DeltaTime (zero is tolerated but will cause some timing issues)");
IM_ASSERT(g.IO.KeyMap[n]>=-1&&g.IO.KeyMap[n]<IM_ARRAYSIZE(g.IO.KeysDown)&&"io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
IM_ASSERT(g.IO.KeyMap[n]>=-1&&g.IO.KeyMap[n]<IM_ARRAYSIZE(g.IO.KeysDown)&&"io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
// Do a simple check for required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was super recently added in 1.60 WIP)
// Perform simple check for required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
IMGUI_APIvoidNewFrame();// start a new ImGui frame, you can submit any command from this point until Render()/EndFrame().
IMGUI_APIvoidNewFrame();// start a new ImGui frame, you can submit any command from this point until Render()/EndFrame().
IMGUI_APIvoidRender();// ends the ImGui frame, finalize the draw data. (Obsolete: optionally call io.RenderDrawListsFn if set. Nowadays, prefer calling your render function yourself.)
IMGUI_APIvoidRender();// ends the ImGui frame, finalize the draw data. (Obsolete: optionally call io.RenderDrawListsFn if set. Nowadays, prefer calling your render function yourself.)
IMGUI_APIvoidRenderAdditionalViewports();
IMGUI_APIImDrawData*GetDrawData();// valid after Render() and until the next call to NewFrame(). this is what you have to render. (Obsolete: this used to be passed to your io.RenderDrawListsFn() function.)
IMGUI_APIImDrawData*GetDrawData();// valid after Render() and until the next call to NewFrame(). this is what you have to render. (Obsolete: this used to be passed to your io.RenderDrawListsFn() function.)
IMGUI_APIImDrawData*GetDrawDataForViewport(ImGuiIDviewport_id);// ImDrawData filtered to hold only the ImDrawList covering a given viewport. valid after Render() and until the next call to NewFrame()
IMGUI_APIvoidEndFrame();// ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead!
IMGUI_APIvoidEndFrame();// ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead!
// Demo, Debug, Information
// Demo, Debug, Information
@ -543,6 +544,15 @@ namespace ImGui
IMGUI_APIconstchar*GetClipboardText();
IMGUI_APIconstchar*GetClipboardText();
IMGUI_APIvoidSetClipboardText(constchar*text);
IMGUI_APIvoidSetClipboardText(constchar*text);
// (Optional) Platform interface for multi-viewport support
IMGUI_APIvoidUpdatePlatformWindows();// Call in main loop. Create/Destroy/Resize platform windows so there's one for each viewport
IMGUI_APIvoidRenderPlatformWindows();// Call in main loop. Call RenderWindow/SwapBuffers from the ImGuiPlatformIO structure. May be reimplemented by user.
IMGUI_APIvoidDestroyPlatformWindows();// Call in back-end shutdown.
void(*ChangedViewport)(ImGuiViewport*viewport);// (Optional) Called during Begin() every time the viewport we are outputting into changes (viewport = next viewport)
};
// (Optional) Setup required only if (io.ConfigFlags & ImGuiConfigFlags_EnableMultiViewport) is enabled
// You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame().
// You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame().
// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors.
// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors.
// Optional: platform interface to use multiple viewports
ImGuiPlatformInterfacePlatformInterface;
ImGuiRendererInterfaceRendererInterface;
// Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows)
// Optional: notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME in Windows)
// (Optional) Setup required only if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports) is enabled
// This is designed so we can mix and match two imgui_impl_xxxx files, one for the Platform (~ Windowing), one for Renderer.
// Custom engine back-ends will often provide both Platform and Renderer interfaces and thus may not need to use all functions.
// Platform functions are typically called before their Renderer counterpart, apart from Destroy which are called the other way.
structImGuiPlatformIO
{
// Platform (e.g. Win32, GLFW, SDL2)
void(*Platform_CreateWindow)(ImGuiViewport*vp);// Create a new platform window for the given viewport
void(*Platform_DestroyWindow)(ImGuiViewport*vp);
void(*Platform_ShowWindow)(ImGuiViewport*vp);// Newly created windows are initially hidden so we have a chance to call SetWindowPos/Size/Title on them.
float(*Platform_GetWindowDpiScale)(ImGuiViewport*vp);// (Optional) DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI. (FIXME-DPI)
void(*Platform_OnChangedViewport)(ImGuiViewport*vp);// (Optional) DPI handling: Called during Begin() every time the viewport we are outputting into changes, so back-end has a chance to swap fonts to adjust style.
int(*Platform_CreateVkSurface)(ImGuiViewport*vp,ImU64vk_inst,constvoid*vk_allocators,ImU64*out_vk_surface);// (Optional) For Renderer to call into Platform code
// Renderer (e.g. DirectX, OpenGL3, Vulkan)
void(*Renderer_CreateWindow)(ImGuiViewport*vp);// Create swap chains, frame buffers etc.
void(*Renderer_DestroyWindow)(ImGuiViewport*vp);
void(*Renderer_SetWindowSize)(ImGuiViewport*vp,ImVec2size);// Resize swap chain, frame buffers etc.
floatFontSize;// (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
floatFontSize;// (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
@ -617,6 +597,7 @@ struct ImGuiContext
floatTime;
floatTime;
intFrameCount;
intFrameCount;
intFrameCountEnded;
intFrameCountEnded;
intFrameCountPlatformEnded;
intFrameCountRendered;
intFrameCountRendered;
ImVector<ImGuiWindow*>Windows;
ImVector<ImGuiWindow*>Windows;
ImVector<ImGuiWindow*>WindowsSortBuffer;
ImVector<ImGuiWindow*>WindowsSortBuffer;
@ -651,11 +632,12 @@ struct ImGuiContext
ImGuiCondNextTreeNodeOpenCond;
ImGuiCondNextTreeNodeOpenCond;
// Viewports
// Viewports
ImVector<ImGuiViewport*>Viewports;
ImVector<ImGuiViewportP*>Viewports;
ImGuiViewport*CurrentViewport;
ImGuiPlatformDataPlatformData;// This is essentially the public facing version of the Viewports vector (it is updated in UpdatePlatformWindows and exclude the viewports about to be destroyed)
ImGuiViewport*MouseViewport;
ImGuiViewportP*CurrentViewport;
ImGuiViewport*MouseLastViewport;
ImGuiViewportP*MouseViewport;
ImGuiViewport*MouseLastHoveredViewport;
ImGuiViewportP*MouseLastViewport;
ImGuiViewportP*MouseLastHoveredViewport;
// Navigation data (for gamepad/keyboard)
// Navigation data (for gamepad/keyboard)
ImGuiWindow*NavWindow;// Focused window for navigation. Could be called 'FocusWindow'
ImGuiWindow*NavWindow;// Focused window for navigation. Could be called 'FocusWindow'
ImGuiWindowFlagsFlags,FlagsPreviousFrame;// See enum ImGuiWindowFlags_
ImGuiWindowFlagsFlags,FlagsPreviousFrame;// See enum ImGuiWindowFlags_
ImGuiViewport*Viewport;// Always set in Begin(), only inactive windows may have a NULL value here
ImGuiViewportP*Viewport;// Always set in Begin(), only inactive windows may have a NULL value here
ImGuiIDViewportId;// Inactive windows preserve their last viewport id (since the viewport may disappear with the window inactivity)
ImGuiIDViewportId;// Inactive windows preserve their last viewport id (since the viewport may disappear with the window inactivity)
ImVec2ViewportPlatformPos;
ImVec2ViewportPlatformPos;
ImVec2PosFloat;
ImVec2PosFloat;
@ -1082,17 +1065,12 @@ namespace ImGui
IMGUI_APIvoidShutdown(ImGuiContext*context);// Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
IMGUI_APIvoidShutdown(ImGuiContext*context);// Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().