Docking, Viewports: Moving code.

Moved NewFrame() sanity checks in NewFrameSanityChecks().
Moved some of DockNodeUpdate() into DockNodeUpdateForRootNode().
This commit is contained in:
omar 2019-11-27 19:13:15 +01:00
parent 71a58261f6
commit 4dff49b2f1

View File

@ -3693,22 +3693,8 @@ static void NewFrameSanityChecks()
// Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
g.IO.ConfigWindowsResizeFromEdges = false;
}
void ImGui::NewFrame()
{
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
ImGuiContext& g = *GImGui;
#ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_PreNewFrame(&g);
#endif
// Check and assert for various common IO and Configuration mistakes
NewFrameSanityChecks();
// Perform simple check: error if Docking or Viewport are enabled _exactly_ on frame 1 (instead of frame 0 or later), which is a common error leading to loss of .ini data.
g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame;
if (g.FrameCount == 1 && (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable) && (g.ConfigFlagsLastFrame & ImGuiConfigFlags_DockingEnable) == 0)
IM_ASSERT(0 && "Please set DockingEnable before the first call to NewFrame()! Otherwise you will lose your .ini settings!");
if (g.FrameCount == 1 && (g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (g.ConfigFlagsLastFrame & ImGuiConfigFlags_ViewportsEnable) == 0)
@ -3750,6 +3736,20 @@ void ImGui::NewFrame()
IM_ASSERT(mon.DpiScale != 0.0f);
}
}
}
void ImGui::NewFrame()
{
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
ImGuiContext& g = *GImGui;
#ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_PreNewFrame(&g);
#endif
// Check and assert for various common IO and Configuration mistakes
g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame;
NewFrameSanityChecks();
g.ConfigFlagsCurrFrame = g.IO.ConfigFlags;
// Load settings on first frame (if not explicitly loaded manually before)
@ -11232,6 +11232,7 @@ namespace ImGui
static void DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window, ImGuiID save_dock_id);
static void DockNodeHideHostWindow(ImGuiDockNode* node);
static void DockNodeUpdate(ImGuiDockNode* node);
static void DockNodeUpdateForRootNode(ImGuiDockNode* node);
static void DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node);
static void DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window);
static void DockNodeAddTabBar(ImGuiDockNode* node);
@ -12168,7 +12169,6 @@ static ImGuiWindow* ImGui::DockNodeFindWindowByID(ImGuiDockNode* node, ImGuiID i
static void ImGui::DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(node->ParentNode == NULL || node->ParentNode->ChildNodes[0] == node || node->ParentNode->ChildNodes[1] == node);
// Inherit most flags
@ -12247,16 +12247,9 @@ static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWind
g.ActiveIdClickOffset = backup_active_click_offset;
}
static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
// Update CentralNode, OnlyNodeWithWindows, LastFocusedNodeID. Copy window class.
static void ImGui::DockNodeUpdateForRootNode(ImGuiDockNode* node)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(node->LastFrameActive != g.FrameCount);
node->LastFrameAlive = g.FrameCount;
node->MarkedForPosSizeWrite = false;
node->CentralNode = node->OnlyNodeWithWindows = NULL;
if (node->IsRootNode())
{
DockNodeUpdateVisibleFlagAndInactiveChilds(node);
// FIXME-DOCK: Merge this scan into the one above.
@ -12282,7 +12275,18 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
break;
}
}
}
}
static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(node->LastFrameActive != g.FrameCount);
node->LastFrameAlive = g.FrameCount;
node->MarkedForPosSizeWrite = false;
node->CentralNode = node->OnlyNodeWithWindows = NULL;
if (node->IsRootNode())
DockNodeUpdateForRootNode(node);
// Remove tab bar if not needed
if (node->TabBar && node->IsNoTabBar())