mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Docking: Wrapping tab bar creation/destroy to make it easier to debug them.
This commit is contained in:
parent
f208fd7ebb
commit
26646f2450
38
imgui.cpp
38
imgui.cpp
@ -10791,6 +10791,8 @@ namespace ImGui
|
|||||||
static void DockNodeUpdate(ImGuiDockNode* node);
|
static void DockNodeUpdate(ImGuiDockNode* node);
|
||||||
static void DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node);
|
static void DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node);
|
||||||
static void DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window);
|
static void DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window);
|
||||||
|
static void DockNodeAddTabBar(ImGuiDockNode* node);
|
||||||
|
static void DockNodeRemoveTabBar(ImGuiDockNode* node);
|
||||||
static ImGuiID DockNodeUpdateTabListMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar);
|
static ImGuiID DockNodeUpdateTabListMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar);
|
||||||
static void DockNodeUpdateVisibleFlag(ImGuiDockNode* node);
|
static void DockNodeUpdateVisibleFlag(ImGuiDockNode* node);
|
||||||
static void DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window);
|
static void DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window);
|
||||||
@ -11231,7 +11233,7 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
|
|||||||
// Create tab bar before we call DockNodeMoveWindows (which would attempt to move the old tab-bar, which would lead us to payload tabs wrongly appearing before target tabs!)
|
// Create tab bar before we call DockNodeMoveWindows (which would attempt to move the old tab-bar, which would lead us to payload tabs wrongly appearing before target tabs!)
|
||||||
if (target_node->Windows.Size > 0 && target_node->TabBar == NULL)
|
if (target_node->Windows.Size > 0 && target_node->TabBar == NULL)
|
||||||
{
|
{
|
||||||
target_node->TabBar = IM_NEW(ImGuiTabBar)();
|
DockNodeAddTabBar(target_node);
|
||||||
for (int n = 0; n < target_node->Windows.Size; n++)
|
for (int n = 0; n < target_node->Windows.Size; n++)
|
||||||
TabBarAddTab(target_node->TabBar, ImGuiTabItemFlags_None, target_node->Windows[n]);
|
TabBarAddTab(target_node->TabBar, ImGuiTabItemFlags_None, target_node->Windows[n]);
|
||||||
}
|
}
|
||||||
@ -11418,7 +11420,7 @@ static void ImGui::DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, b
|
|||||||
{
|
{
|
||||||
if (node->TabBar == NULL)
|
if (node->TabBar == NULL)
|
||||||
{
|
{
|
||||||
node->TabBar = IM_NEW(ImGuiTabBar)();
|
DockNodeAddTabBar(node);
|
||||||
node->TabBar->SelectedTabId = node->TabBar->NextSelectedTabId = node->SelectedTabID;
|
node->TabBar->SelectedTabId = node->TabBar->NextSelectedTabId = node->SelectedTabID;
|
||||||
|
|
||||||
// Add existing windows
|
// Add existing windows
|
||||||
@ -11468,10 +11470,7 @@ static void ImGui::DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window
|
|||||||
TabBarRemoveTab(node->TabBar, window->ID);
|
TabBarRemoveTab(node->TabBar, window->ID);
|
||||||
const int tab_count_threshold_for_tab_bar = node->IsCentralNode ? 1 : 2;
|
const int tab_count_threshold_for_tab_bar = node->IsCentralNode ? 1 : 2;
|
||||||
if (node->Windows.Size < tab_count_threshold_for_tab_bar)
|
if (node->Windows.Size < tab_count_threshold_for_tab_bar)
|
||||||
{
|
DockNodeRemoveTabBar(node);
|
||||||
IM_DELETE(node->TabBar);
|
|
||||||
node->TabBar = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->Windows.Size == 0 && !node->IsCentralNode && !node->IsDockSpace() && window->DockId != node->ID)
|
if (node->Windows.Size == 0 && !node->IsCentralNode && !node->IsDockSpace() && window->DockId != node->ID)
|
||||||
@ -11541,8 +11540,7 @@ static void ImGui::DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* s
|
|||||||
{
|
{
|
||||||
if (dst_node->TabBar)
|
if (dst_node->TabBar)
|
||||||
dst_node->TabBar->SelectedTabId = src_node->TabBar->SelectedTabId;
|
dst_node->TabBar->SelectedTabId = src_node->TabBar->SelectedTabId;
|
||||||
IM_DELETE(src_node->TabBar);
|
DockNodeRemoveTabBar(src_node);
|
||||||
src_node->TabBar = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11571,10 +11569,7 @@ static void ImGui::DockNodeHideHostWindow(ImGuiDockNode* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node->TabBar)
|
if (node->TabBar)
|
||||||
{
|
DockNodeRemoveTabBar(node);
|
||||||
IM_DELETE(node->TabBar);
|
|
||||||
node->TabBar = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImGuiDockNodeUpdateScanResults
|
struct ImGuiDockNodeUpdateScanResults
|
||||||
@ -12042,7 +12037,10 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
|||||||
ImGuiTabBar* tab_bar = node->TabBar;
|
ImGuiTabBar* tab_bar = node->TabBar;
|
||||||
bool tab_bar_is_recreated = (tab_bar == NULL); // Tab bar are automatically destroyed when a node gets hidden
|
bool tab_bar_is_recreated = (tab_bar == NULL); // Tab bar are automatically destroyed when a node gets hidden
|
||||||
if (tab_bar == NULL)
|
if (tab_bar == NULL)
|
||||||
tab_bar = node->TabBar = IM_NEW(ImGuiTabBar)();
|
{
|
||||||
|
DockNodeAddTabBar(node);
|
||||||
|
tab_bar = node->TabBar;
|
||||||
|
}
|
||||||
|
|
||||||
ImGuiID focus_tab_id = 0;
|
ImGuiID focus_tab_id = 0;
|
||||||
node->IsFocused = is_focused;
|
node->IsFocused = is_focused;
|
||||||
@ -12209,6 +12207,20 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ImGui::DockNodeAddTabBar(ImGuiDockNode* node)
|
||||||
|
{
|
||||||
|
IM_ASSERT(node->TabBar == NULL);
|
||||||
|
node->TabBar = IM_NEW(ImGuiTabBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ImGui::DockNodeRemoveTabBar(ImGuiDockNode* node)
|
||||||
|
{
|
||||||
|
if (node->TabBar == NULL)
|
||||||
|
return;
|
||||||
|
IM_DELETE(node->TabBar);
|
||||||
|
node->TabBar = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static bool DockNodeIsDropAllowedOne(ImGuiWindow* payload, ImGuiWindow* host_window)
|
static bool DockNodeIsDropAllowedOne(ImGuiWindow* payload, ImGuiWindow* host_window)
|
||||||
{
|
{
|
||||||
if (host_window->DockNodeAsHost && host_window->DockNodeAsHost->IsDockSpace() && payload->BeginOrderWithinContext < host_window->BeginOrderWithinContext)
|
if (host_window->DockNodeAsHost && host_window->DockNodeAsHost->IsDockSpace() && payload->BeginOrderWithinContext < host_window->BeginOrderWithinContext)
|
||||||
|
Loading…
Reference in New Issue
Block a user