mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-15 03:27:45 +01:00
Docking: Fixes for C++03 compilers.
This commit is contained in:
parent
ae657a349a
commit
4e717b524c
26
imgui.cpp
26
imgui.cpp
@ -9868,6 +9868,14 @@ static int IMGUI_CDECL DockNodeComparerDepthMostFirst(const void* lhs, const voi
|
||||
return ImGui::DockNodeGetDepth(b) - ImGui::DockNodeGetDepth(a);
|
||||
}
|
||||
|
||||
// Pre C++0x doesn't allow us to use a local type (without linkage) as template parameter, so we moved this here.
|
||||
struct ImGuiDockContextPruneNodeData
|
||||
{
|
||||
int CountWindows, CountChildWindows, CountChildNodes;
|
||||
ImGuiID RootID;
|
||||
ImGuiDockContextPruneNodeData() { CountWindows = CountChildWindows = CountChildNodes = 0; RootID = 0; }
|
||||
};
|
||||
|
||||
// Garbage collect unused nodes (run once at init time)
|
||||
static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
|
||||
{
|
||||
@ -9875,20 +9883,14 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
|
||||
ImGuiDockContext* dc = ctx->DockContext;
|
||||
IM_ASSERT(g.Windows.Size == 0);
|
||||
|
||||
struct NodeData
|
||||
{
|
||||
int CountWindows, CountChildWindows, CountChildNodes;
|
||||
ImGuiID RootID;
|
||||
NodeData() { CountWindows = CountChildWindows = CountChildNodes = 0; RootID = 0; }
|
||||
};
|
||||
ImPool<NodeData> pool;
|
||||
ImPool<ImGuiDockContextPruneNodeData> pool;
|
||||
pool.Reserve(dc->SettingsNodes.Size);
|
||||
|
||||
// Count child nodes and compute RootID
|
||||
for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
|
||||
{
|
||||
ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
|
||||
NodeData* parent_data = settings->ParentID ? pool.GetByKey(settings->ParentID) : 0;
|
||||
ImGuiDockContextPruneNodeData* parent_data = settings->ParentID ? pool.GetByKey(settings->ParentID) : 0;
|
||||
pool.GetOrAddByKey(settings->ID)->RootID = parent_data ? parent_data->RootID : settings->ID;
|
||||
if (settings->ParentID)
|
||||
pool.GetOrAddByKey(settings->ParentID)->CountChildNodes++;
|
||||
@ -9897,9 +9899,9 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
|
||||
// Count reference to dock ids from window settings
|
||||
for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++)
|
||||
if (ImGuiID dock_id = g.SettingsWindows[settings_n].DockId)
|
||||
if (NodeData* data = pool.GetByKey(dock_id))
|
||||
if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(dock_id))
|
||||
{
|
||||
NodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID);
|
||||
ImGuiDockContextPruneNodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID);
|
||||
data->CountWindows++;
|
||||
data_root->CountChildWindows++;
|
||||
}
|
||||
@ -9908,10 +9910,10 @@ static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
|
||||
for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
|
||||
{
|
||||
ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
|
||||
NodeData* data = pool.GetByKey(settings->ID);
|
||||
ImGuiDockContextPruneNodeData* data = pool.GetByKey(settings->ID);
|
||||
if (data->CountWindows > 1)
|
||||
continue;
|
||||
NodeData* data_root = (data->RootID == settings->ID) ? data : pool.GetByKey(data->RootID);
|
||||
ImGuiDockContextPruneNodeData* data_root = (data->RootID == settings->ID) ? data : pool.GetByKey(data->RootID);
|
||||
|
||||
bool remove = false;
|
||||
remove |= (data->CountWindows == 1 && settings->ParentID == 0 && data->CountChildNodes == 0 && !settings->IsDocumentRoot); // Floating root node with only 1 window
|
||||
|
2
imgui.h
2
imgui.h
@ -969,7 +969,7 @@ enum ImGuiBackendFlags_
|
||||
// [BETA] Viewports
|
||||
ImGuiBackendFlags_PlatformHasViewports = 1 << 10, // Back-end Platform supports multiple viewports.
|
||||
ImGuiBackendFlags_HasMouseHoveredViewport=1 << 11, // Back-end Platform supports setting io.MouseHoveredViewport to the viewport directly under the mouse _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag and _REGARDLESS_ of whether another viewport is focused and may be capturing the mouse. This information is _NOT EASY_ to provide correctly with most high-level engines! Don't set this without studying how the examples/ back-end handle it!
|
||||
ImGuiBackendFlags_RendererHasViewports = 1 << 12, // Back-end Renderer supports multiple viewports.
|
||||
ImGuiBackendFlags_RendererHasViewports = 1 << 12 // Back-end Renderer supports multiple viewports.
|
||||
};
|
||||
|
||||
// Enumeration for PushStyleColor() / PopStyleColor()
|
||||
|
Loading…
Reference in New Issue
Block a user