From 9c8fb804ed7d1523711b1ea460a380fc665292c3 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 31 Jan 2018 17:41:26 +0100 Subject: [PATCH 1/3] Log: Comments and extraneous assets to clarify intent. (#1584) --- imgui.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 45e0e2a9..10250545 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6570,8 +6570,9 @@ void ImGui::LogToTTY(int max_depth) return; ImGuiWindow* window = g.CurrentWindow; - g.LogEnabled = true; + IM_ASSERT(g.LogFile == NULL); g.LogFile = stdout; + g.LogEnabled = true; g.LogStartDepth = window->DC.TreeDepth; if (max_depth >= 0) g.LogAutoExpandMaxDepth = max_depth; @@ -6592,6 +6593,7 @@ void ImGui::LogToFile(int max_depth, const char* filename) return; } + IM_ASSERT(g.LogFile == NULL); g.LogFile = ImFileOpen(filename, "ab"); if (!g.LogFile) { @@ -6612,8 +6614,9 @@ void ImGui::LogToClipboard(int max_depth) return; ImGuiWindow* window = g.CurrentWindow; - g.LogEnabled = true; + IM_ASSERT(g.LogFile == NULL); g.LogFile = NULL; + g.LogEnabled = true; g.LogStartDepth = window->DC.TreeDepth; if (max_depth >= 0) g.LogAutoExpandMaxDepth = max_depth; @@ -6626,7 +6629,6 @@ void ImGui::LogFinish() return; LogText(IM_NEWLINE); - g.LogEnabled = false; if (g.LogFile != NULL) { if (g.LogFile == stdout) @@ -6640,6 +6642,7 @@ void ImGui::LogFinish() SetClipboardText(g.LogClipboard->begin()); g.LogClipboard->clear(); } + g.LogEnabled = false; } // Helper to display logging buttons From dbdbf01b9f735ccf53f7e767e54ff12867eb617b Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 31 Jan 2018 19:13:20 +0100 Subject: [PATCH 2/3] Demo: Tweaked the Child demos, added a menu bar to the second child to test some navigation functions. --- imgui_demo.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 4c2a437e..b7c69948 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1051,9 +1051,10 @@ void ImGui::ShowDemoWindow(bool* p_open) if (ImGui::TreeNode("Child regions")) { static bool disable_mouse_wheel = false; + static bool disable_menu = false; ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel); + ImGui::Checkbox("Disable Menu", &disable_menu); - ImGui::Text("Without border"); static int line = 50; bool goto_line = ImGui::Button("Goto"); ImGui::SameLine(); @@ -1080,8 +1081,16 @@ void ImGui::ShowDemoWindow(bool* p_open) // Child 2: rounded border { ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); - ImGui::BeginChild("Child2", ImVec2(0,300), true, (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0)); - ImGui::Text("With border"); + ImGui::BeginChild("Child2", ImVec2(0,300), true, (disable_mouse_wheel ? ImGuiWindowFlags_NoScrollWithMouse : 0) | (disable_menu ? 0 : ImGuiWindowFlags_MenuBar)); + if (!disable_menu && ImGui::BeginMenuBar()) + { + if (ImGui::BeginMenu("Menu")) + { + ShowExampleMenuFile(); + ImGui::EndMenu(); + } + ImGui::EndMenuBar(); + } ImGui::Columns(2); for (int i = 0; i < 100; i++) { From 9bc5c089b6c351b821bbd672f3c002b9b53ead03 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 31 Jan 2018 22:14:33 +0100 Subject: [PATCH 3/3] Internal: Avoid needlessly bringing parent of front-most child back to front. This is mostly to reduce flicker/confusion in Metrics when traversing windows. We could aim at separating the child windows from non-child windows at some point. --- imgui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 10250545..f0414555 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5161,7 +5161,8 @@ void ImGui::Scrollbar(ImGuiLayoutType direction) void ImGui::BringWindowToFront(ImGuiWindow* window) { ImGuiContext& g = *GImGui; - if (g.Windows.back() == window) + ImGuiWindow* current_front_window = g.Windows.back(); + if (current_front_window == window || current_front_window->RootWindow == window) return; for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the front most window if (g.Windows[i] == window)