Docking and Viewports
Docking and multi-viewport features are available in the docking branch of Dear ImGui. These features allow windows to be docked together and moved outside the main application window.Docking and viewports are currently available in the
docking branch, not in the master branch. You need to use the docking branch to access these features.Docking Overview
Docking allows users to:- Drag windows to dock them together
- Create custom layouts by splitting docked spaces
- Save and restore docking layouts
- Create tab bars from docked windows
Enabling Docking
Enable docking in your application:Creating a Dockspace
A dockspace is a region where windows can be docked:Simple Dockspace
For a simpler approach:Docking Flags
Window Flags
Control docking behavior per-window:ImGuiWindowFlags_NoDocking- Cannot be docked
DockNode Flags
Customize dockspace behavior:Programmatic Docking
Set up initial docking layout programmatically:Multi-Viewport Support
Multi-viewport allows Dear ImGui windows to be moved outside the main application window into their own OS windows.Enabling Viewports
Backend Requirements
Multi-viewport requires:- Platform backend support (e.g.,
imgui_impl_glfw.cpp,imgui_impl_win32.cpp) - Renderer backend support (e.g.,
imgui_impl_opengl3.cpp,imgui_impl_dx11.cpp) - Backend must create and manage additional OS windows
Rendering Viewports
Viewport Flags
ImGuiViewport Structure
Getting Viewport Information
Complete Docking Example
Saving and Loading Layouts
Dear ImGui automatically saves docking layouts to.ini files:
Platform-Specific Considerations
Windows
Full support in GLFW, Win32, SDL2 backends.macOS
Full support with some quirks around focus and decorations.Linux
Full support with X11 and Wayland backends.Web (Emscripten)
Multi-viewport not supported (browser limitation).Reference
- Docking Branch
- Viewport API (line 3922)
- See backend implementations in
backends/folder for multi-viewport examples