Docking (original) (raw)

Docked windows
Docked windows

Preamble

Where to find it?

Docking is currently available in the docking branch.

How can I enable docking?

Enable config flag:

Create a fullscreen dockspace (optional)

That's pretty much it. There are additional docked related configuration flags in the ImGuiIO structure which you may toy with.

Why is not merged to master???

(This is the most asked question ever)
TL;DR; I am not happy with the current state of the code. I am a cautious person.

However, you can benefit from a lot of docking features without being impacted by any of this. The largest amount of interactions you'll have with the docking system are at end-user level and do not require API calls. By just enabling the config flag above and calling a few functions you can benefit from 90% of Docking features. Even the hypothetical full rewrite of Docking system is not expected to impact most users. API that are most at risk of changing are hidden in imgui_internal.h for this reason, and even so, if they do change, we'll make reasonable effort to document the reasoning the update path.

In addition, Docking will only move forward with feedback from users, so the more people using it, the closer we are to a reach mergeable version. TL;DR; is totally fine to use for most users.

Usage Guide

Also see our Glossary about Docking terminology.

Docking

Dock by dragging windows from their title tab or tab (hold SHIFT to disable docking)

Undocking

Other features

Dockspace

If you want to dock window on the edge of your screen (rather than only into other windows), most application can do:

ImGui::NewFrame();

// Create a dockspace in main viewport. ImGui::DockSpaceOverViewport();

or

ImGui::NewFrame();

// Create a dockspace in main viewport, where central node is transparent. ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);

DockSpaceOverViewport() is a helper which:

That's pretty much what it does.

A DockSpace() is an arbitrary location inside a window, where other windows may be docked into.

Programmatically setting up docking layout (DockBuider api)

Unfortunately, there is no great API for this yet. I am sorry! I know everyone is asking for this!

DockBuilder API idiomatic example:

#include "imgui_internal.h"

ImGuiID dockspace_id = ImGui::GetID("My Dockspace"); ImGuiViewport* viewport = ImGui::GetMainViewport();

// Create settings if (ImGui::DockBuilderGetNode(dockspace_id) == nullptr) { ImGui::DockBuilderAddNode(dockspace_id, ImGuiDockNodeFlags_DockSpace); ImGui::DockBuilderSetNodeSize(dockspace_id, viewport->Size); ImGuiID dock_id_left = 0; ImGuiID dock_id_main = dockspace_id; ImGui::DockBuilderSplitNode(dock_id_main, ImGuiDir_Left, 0.20f, &dock_id_left, &dock_id_main); ImGuiID dock_id_left_top = 0; ImGuiID dock_id_left_bottom = 0; ImGui::DockBuilderSplitNode(dock_id_left, ImGuiDir_Up, 0.50f, &dock_id_left_top, &dock_id_left_bottom); ImGui::DockBuilderDockWindow("Game", dock_id_main); ImGui::DockBuilderDockWindow("Properties", dock_id_left_top); ImGui::DockBuilderDockWindow("Scene", dock_id_left_bottom); ImGui::DockBuilderFinish(dockspace_id); }

// Submit dockspace ImGui::DockSpaceOverViewport(dockspace_id, viewport, ImGuiDockNodeFlags_PassthruCentralNode);

// Submit windows ImGui::Begin("Properties"); ...

DockBuilder example

Debugging

More