Package imgui

Class ImGuiPlatformIO


public final class ImGuiPlatformIO extends ImGuiStruct
----------------------------------------------------------------------------- [BETA] Platform interface for multi-viewport support ----------------------------------------------------------------------------- (Optional) This is completely optional, for advanced users! If you are new to Dear ImGui and trying to integrate it into your engine, you can probably ignore this for now. This feature allows you to seamlessly drag Dear ImGui windows outside of your application viewport. This is achieved by creating new Platform/OS windows on the fly, and rendering into them. Dear ImGui manages the viewport structures, and the backend create and maintain one Platform/OS window for each of those viewports. See Glossary https://github.com/ocornut/imgui/wiki/Glossary for details about some of the terminology. See Thread https://github.com/ocornut/imgui/issues/1542 for gifs, news and questions about this evolving feature. About the coordinates system: - When multi-viewports are enabled, all Dear ImGui coordinates become absolute coordinates (same as OS coordinates!) - So e.g. ImGui::SetNextWindowPos(ImVec2(0,0)) will position a window relative to your primary monitor! - If you want to position windows relative to your main application viewport, use ImGui::GetMainViewport().Pos as a base position. Steps to use multi-viewports in your application, when using a default backend from the examples/ folder: - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. - Backend: The backend initialization will setup all necessary ImGuiPlatformIO's functions and update monitors info every frame. - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render(). - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls. Steps to use multi-viewports in your application, when using a custom backend: - Important: THIS IS NOT EASY TO DO and comes with many subtleties not described here! It's also an experimental feature, so some of the requirements may evolve. Consider using default backends if you can. Either way, carefully follow and refer to examples/ backends for details. - Application: Enable feature with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. - Backend: Hook ImGuiPlatformIO's Platform_* and Renderer_* callbacks (see below). Set 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports' and 'io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports'. Update ImGuiPlatformIO's Monitors list every frame. Update MousePos every frame, in absolute coordinates. - Application: In your main loop, call ImGui::UpdatePlatformWindows(), ImGui::RenderPlatformWindowsDefault() after EndFrame() or Render(). You may skip calling RenderPlatformWindowsDefault() if its API is not convenient for your needs. Read comments below. - Application: Fix absolute coordinates used in ImGui::SetWindowPos() or ImGui::SetNextWindowPos() calls. About ImGui::RenderPlatformWindowsDefault(): - This function is a mostly a _helper_ for the common-most cases, and to facilitate using default backends. - You can check its simple source code to understand what it does. It basically iterates secondary viewports and call 4 functions that are setup in ImGuiPlatformIO, if available: Platform_RenderWindow(), Renderer_RenderWindow(), Platform_SwapBuffers(), Renderer_SwapBuffers() Those functions pointers exists only for the benefit of RenderPlatformWindowsDefault(). - If you have very specific rendering needs (e.g. flipping multiple swap-chain simultaneously, unusual sync/threading issues, etc.), you may be tempted to ignore RenderPlatformWindowsDefault() and write customized code to perform your renderingg. You may decide to setup the platform_io's *RenderWindow and *SwapBuffers pointers and call your functions through those pointers, or you may decide to never setup those pointers and call your code directly. They are a convenience, not an obligatory interface. ----------------------------------------------------------------------------- (Optional) Access via ImGui::GetPlatformIO()

------------------------------------------------------------------ Input - Backend interface/functions + Monitor List ------------------------------------------------------------------ (Optional) Platform functions (e.g. Win32, GLFW, SDL2) For reference, the second column shows which function are generally calling the Platform Functions: N = ImGui::NewFrame() ~ beginning of the dear imgui frame: read info from platform/OS windows (latest size/position) F = ImGui::Begin(), ImGui::EndFrame() ~ during the dear imgui frame U = ImGui::UpdatePlatformWindows() ~ after the dear imgui frame: create and update all platform/OS windows R = ImGui::RenderPlatformWindowsDefault() ~ render D = ImGui::DestroyPlatformWindows() ~ shutdown The general idea is that NewFrame() we will read the current Platform/OS state, and UpdatePlatformWindows() will write to it. The functions are designed so we can mix and match 2 imgui_impl_xxxx files, one for the Platform (~window/input handling), one for Renderer. Custom engine backends will often provide both Platform and Renderer interfaces and so 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.

  • Constructor Details

    • ImGuiPlatformIO

      public ImGuiPlatformIO(long ptr)
  • Method Details

    • setPlatformCreateWindow

      public void setPlatformCreateWindow(ImPlatformFuncViewport func)
      // . . U . . // Create a new platform window for the given viewport.
    • setPlatformDestroyWindow

      public void setPlatformDestroyWindow(ImPlatformFuncViewport func)
      // N . U . D //
    • setPlatformShowWindow

      public void setPlatformShowWindow(ImPlatformFuncViewport func)
      // . . U . . // Newly created windows are initially hidden so SetWindowPos/Size/Title can be called on them before showing the window.
    • setPlatformSetWindowPos

      public void setPlatformSetWindowPos(ImPlatformFuncViewportImVec2 func)
      // . . U . . // Set platform window position (given the upper-left corner of client area).
    • setPlatformGetWindowPos

      public void setPlatformGetWindowPos(ImPlatformFuncViewportSuppImVec2 func)
      // N . . . . //
    • setPlatformSetWindowSize

      public void setPlatformSetWindowSize(ImPlatformFuncViewportImVec2 func)
      // . . U . . // Set platform window client area size (ignoring OS decorations such as OS title bar etc.)
    • setPlatformGetWindowSize

      public void setPlatformGetWindowSize(ImPlatformFuncViewportSuppImVec2 func)
      // N . . . . // Get platform window client area size
    • setPlatformSetWindowFocus

      public void setPlatformSetWindowFocus(ImPlatformFuncViewport func)
      // N . . . . // Move window to front and set input focus.
    • setPlatformGetWindowFocus

      public void setPlatformGetWindowFocus(ImPlatformFuncViewportSuppBoolean func)
      // . . U . . //
    • setPlatformGetWindowMinimized

      public void setPlatformGetWindowMinimized(ImPlatformFuncViewportSuppBoolean func)
      // N . . . . // Get platform window minimized state. When minimized, we generally won't attempt to get/set size and contents will be culled more easily.
    • setPlatformSetWindowTitle

      public void setPlatformSetWindowTitle(ImPlatformFuncViewportString func)
      // . . U . . // Set platform window title (given an UTF-8 string)
    • setPlatformSetWindowAlpha

      public void setPlatformSetWindowAlpha(ImPlatformFuncViewportFloat func)
      // . . U . . // (Optional) Setup window transparency
    • setPlatformUpdateWindow

      public void setPlatformUpdateWindow(ImPlatformFuncViewport func)
      // . . U . . // (Optional) Called by UpdatePlatformWindows(). Optional hook to allow the platform backend from doing general book-keeping every frame.
    • setPlatformRenderWindow

      public void setPlatformRenderWindow(ImPlatformFuncViewport func)
      // . . . R . // (Optional) Main rendering (platform side! This is often unused, or just setting a "current" context for OpenGL bindings).
    • setPlatformSwapBuffers

      public void setPlatformSwapBuffers(ImPlatformFuncViewport func)
      // . . . R . // (Optional) Call Present/SwapBuffers (platform side! This is often unused!).
    • setPlatformGetWindowDpiScale

      public void setPlatformGetWindowDpiScale(ImPlatformFuncViewportSuppFloat func)
      // N . . . . // (Optional) [BETA] FIXME-DPI: DPI handling: Return DPI scale for this viewport. 1.0f = 96 DPI.
    • setPlatformOnChangedViewport

      public void setPlatformOnChangedViewport(ImPlatformFuncViewport func)
      // (Optional) [BETA] FIXME-DPI: DPI handling: Called during Begin() every time the viewport we are outputting into changes, so backend has a chance to swap fonts to adjust style.
    • setRendererCreateWindow

      public void setRendererCreateWindow(ImPlatformFuncViewport func)
      // . . U . . // Create swap chain, frame buffers etc. (called after Platform_CreateWindow)
    • setRendererDestroyWindow

      public void setRendererDestroyWindow(ImPlatformFuncViewport func)
      // N . U . D // Destroy swap chain, frame buffers etc. (called before Platform_DestroyWindow)
    • setRendererSetWindowPos

      public void setRendererSetWindowPos(ImPlatformFuncViewportImVec2 func)
      // . . U . . // Resize swap chain, frame buffers etc. (called after Platform_SetWindowSize)
    • setRendererRenderWindow

      public void setRendererRenderWindow(ImPlatformFuncViewport func)
      // . . . R . // (Optional) Clear framebuffer, setup render target, then render the viewport.DrawData. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
    • setRendererSwapBuffers

      public void setRendererSwapBuffers(ImPlatformFuncViewport func)
      // . . . R . // (Optional) Call Present/SwapBuffers. 'render_arg' is the value passed to RenderPlatformWindowsDefault().
    • resizeMonitors

      public void resizeMonitors(int size)
    • getMonitorsSize

      public int getMonitorsSize()
    • pushMonitors

      public void pushMonitors(long platformHandle, float mainPosX, float mainPosY, float mainSizeX, float mainSizeY, float workPosX, float workPosY, float workSizeX, float workSizeY, float dpiScale)
    • getMonitors

      public ImGuiPlatformMonitor getMonitors(int idx)
    • getViewportsSize

      public int getViewportsSize()
    • getViewports

      public ImGuiViewport getViewports(int idx)