Skip to content

Same-frame docking layout evaluation #9058

@ssh4net

Description

@ssh4net

Version/Branch of Dear ImGui:

Version 1.92.4, Branch: docking

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp

Compiler, OS:

windows 11

Full config/build information:

No response

Details:

Question is more about find a proper way to evaluate app GUI layout in a same-frame.

App has main window defined as MainDockSpace where I also define “Process”, “Info”, “Props” and “Image” windows dock layout for default look.
All windows except Image window has fixed width size.

When app run only Process window docked on the left.
When app open Image app also make visible windows with Info (mouse cords, image size, UI debug information etc.) and Props window for image (shader) manipulations or zoom, scroll, grid etc.

I have use Demo for Vulkan/GLFW as a reference and
Docking space, Menus, AppWindows run inside ImGUI::NewFrame / Render().

In code I try to utilize public ImGUI API but for image scale (zoom or fit to window) still need have window size from ImGUI.

Issues I had found at this moment:

  • Even if Info and Props windows defined and initializing before Image Window and Process window already in place. Image windows after Begin get size equal of empty space in DockingSpace without Info/Props.
    Both are docked by default and have fixed size, so ImGui in theory can correctly evaluate available area wrt Process, Info and Props windows.
    So in first frame I don’t have correct sizes from ImGui.
  • second NewFrame pass, ImageWindow still don’t get correct sizes from imgui and Info and Props still did not rendering, as well as ImageWindow
  • only on third frame, I get all sizes app need to evaluate correct image size to fit it into a window and on Render() finally visible all windows.

At this moment I have a counter for image open that re-evaluate image size untill third frame. And I have feels that this is suboptimal. Because also have some issues with zooming and scroll positions.

I have an idea to use “dummy frames” and run ImGui::NewFrame() several times without call Render()
Maybe with some suppression for time/frame count. Only to force system re-evaluate gui in same frame for interactive events.

Or maybe there are more straight forward way to finish gui layout in same frame?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions