Skip to content

Commit

Permalink
Docking: added comments. added experimental TabItemFlagsOverrideSet t…
Browse files Browse the repository at this point in the history
…o ImGuiWindowClass.

(Could probably do something similar with TabBarFlagsOverrideSet+Clear for #2700 later.)
  • Loading branch information
ocornut committed Jan 18, 2021
1 parent 388ca56 commit 9e4956d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
49 changes: 48 additions & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11930,6 +11930,50 @@ void ImGui::DestroyPlatformWindows()
// Docking: Settings
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Typical Docking call flow: (root level is generally public API):
//-----------------------------------------------------------------------------
// - NewFrame() new dear imgui frame
// | DockContextUpdateUndocking() - process queued undocking requests
// | - DockContextProcessUndockWindow() - process one window undocking request
// | - DockContextProcessUndockNode() - process one whole node undocking request
// | DockContextUpdateDocking() - process queue docking requests, create floating dock nodes
// | - update g.HoveredDockNode - [debug] update node hovered by mouse
// | - DockContextProcessDock() - process one docking request
// | - DockNodeUpdate()
// | - DockNodeUpdateForRootNode()
// | - DockNodeUpdateVisibleFlagAndInactiveChilds()
// | - DockNodeFindInfo()
// | - destroy unused node or tab bar
// | - create dock node host window
// | - Begin() etc.
// | - DockNodeStartMouseMovingWindow()
// | - DockNodeTreeUpdatePosSize()
// | - DockNodeTreeUpdateSplitter()
// | - draw node background
// | - DockNodeUpdateTabBar() - create/update tab bar for a docking node
// | - DockNodeAddTabBar()
// | - DockNodeUpdateWindowMenu()
// | - DockNodeCalcTabBarLayout()
// | - BeginTabBarEx()
// | - TabItemEx() calls
// | - EndTabBar()
// | - BeginDockableDragDropTarget()
// | - DockNodeUpdate() - recurse into child nodes...
//-----------------------------------------------------------------------------
// - DockSpace() user submit a dockspace into a window
// | Begin(Child) - create a child window
// | DockNodeUpdate() - call main dock node update function
// | End(Child)
// | ItemSize()
//-----------------------------------------------------------------------------
// - Begin()
// | BeginDocked()
// | BeginDockableDragDropSource()
// | BeginDockableDragDropTarget()
// | - DockNodePreviewDockRender()
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Docking: Internal Types
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -12191,7 +12235,9 @@ void ImGui::DockContextUpdateDocking(ImGuiContext* ctx)
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
return;

// Store hovered dock node. We could in theory use DockNodeTreeFindVisibleNodeByPos() on the root host dock node, but using ->DockNode is a good shortcut.
// [DEBUG] Store hovered dock node.
// We could in theory use DockNodeTreeFindVisibleNodeByPos() on the root host dock node, but using ->DockNode is a good shortcut.
// Note this is mostly a debug thing and isn't actually used for docking target, because docking involve more detailed filtering.
g.HoveredDockNode = NULL;
if (ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow)
{
Expand Down Expand Up @@ -13582,6 +13628,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
if (window->LastFrameActive + 1 >= g.FrameCount || !node_was_active)
{
ImGuiTabItemFlags tab_item_flags = 0;
tab_item_flags |= window->WindowClass.TabItemFlagsOverrideSet;
if (window->Flags & ImGuiWindowFlags_UnsavedDocument)
tab_item_flags |= ImGuiTabItemFlags_UnsavedDocument;
if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)
Expand Down
3 changes: 2 additions & 1 deletion imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1995,12 +1995,13 @@ struct ImGuiWindowClass
ImGuiID ParentViewportId; // Hint for the platform backend. If non-zero, the platform backend can create a parent<>child relationship between the platform windows. Not conforming backends are free to e.g. parent every viewport to the main viewport or not.
ImGuiViewportFlags ViewportFlagsOverrideSet; // Viewport flags to set when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
ImGuiViewportFlags ViewportFlagsOverrideClear; // Viewport flags to clear when a window of this class owns a viewport. This allows you to enforce OS decoration or task bar icon, override the defaults on a per-window basis.
ImGuiTabItemFlags TabItemFlagsOverrideSet; // [EXPERIMENTAL] TabItem flags to set when a window of this class gets submitted into a dock node tab bar. May use with ImGuiTabItemFlags_Leading or ImGuiTabItemFlags_Trailing.
ImGuiDockNodeFlags DockNodeFlagsOverrideSet; // [EXPERIMENTAL] Dock node flags to set when a window of this class is hosted by a dock node (it doesn't have to be selected!)
ImGuiDockNodeFlags DockNodeFlagsOverrideClear; // [EXPERIMENTAL]
bool DockingAlwaysTabBar; // Set to true to enforce single floating windows of this class always having their own docking node (equivalent of setting the global io.ConfigDockingAlwaysTabBar)
bool DockingAllowUnclassed; // Set to true to allow windows of this class to be docked/merged with an unclassed window. // FIXME-DOCK: Move to DockNodeFlags override?

ImGuiWindowClass() { ClassId = 0; ParentViewportId = 0; ViewportFlagsOverrideSet = ViewportFlagsOverrideClear = 0x00; DockNodeFlagsOverrideSet = DockNodeFlagsOverrideClear = 0x00; DockingAlwaysTabBar = false; DockingAllowUnclassed = true; }
ImGuiWindowClass() { memset(this, 0, sizeof(*this)); DockingAllowUnclassed = true; }
};

// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload()
Expand Down
2 changes: 1 addition & 1 deletion imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ struct ImGuiDockContext
ImVector<ImGuiDockRequest> Requests;
ImVector<ImGuiDockNodeSettings> NodesSettings;
bool WantFullRebuild;
ImGuiDockContext() { WantFullRebuild = false; }
ImGuiDockContext() { memset(this, 0, sizeof(*this)); }
};

#endif // #ifdef IMGUI_HAS_DOCK
Expand Down

0 comments on commit 9e4956d

Please sign in to comment.