diff --git a/imgui.cpp b/imgui.cpp index 937619ca..ac12e3ff 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6174,7 +6174,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) @@ -7650,8 +7651,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; @@ -7672,6 +7674,7 @@ void ImGui::LogToFile(int max_depth, const char* filename) return; } + IM_ASSERT(g.LogFile == NULL); g.LogFile = ImFileOpen(filename, "ab"); if (!g.LogFile) { @@ -7692,8 +7695,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; @@ -7706,7 +7710,6 @@ void ImGui::LogFinish() return; LogText(IM_NEWLINE); - g.LogEnabled = false; if (g.LogFile != NULL) { if (g.LogFile == stdout) @@ -7720,6 +7723,7 @@ void ImGui::LogFinish() SetClipboardText(g.LogClipboard->begin()); g.LogClipboard->clear(); } + g.LogEnabled = false; } // Helper to display logging buttons diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 852123fd..2de0f632 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1054,7 +1054,9 @@ 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); static int line = 50; bool goto_line = ImGui::Button("Goto"); @@ -1082,8 +1084,8 @@ 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) | ImGuiWindowFlags_MenuBar); - if (ImGui::BeginMenuBar()) + 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")) {