From b76353bbb166cbd03494f665f0a227556e2b4221 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 25 Aug 2015 11:54:13 +0100 Subject: [PATCH] Passing ImGuiWindowFlags_NoMove to BeginChild() allows to inhibit moving root window from this child --- imgui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 10775bc1..1bd40423 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2258,12 +2258,12 @@ void ImGui::Render() { if (!(g.FocusedWindow && !g.FocusedWindow->WasActive && g.FocusedWindow->Active)) // Unless we just made a popup appear { - if (g.HoveredRootWindow != NULL) + if (g.HoveredRootWindow != NULL && !(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove)) { g.MovedWindow = g.HoveredWindow; SetActiveID(g.HoveredRootWindow->MoveID, g.HoveredRootWindow); } - else if (g.FocusedWindow != NULL && GetFrontMostModalRootWindow() == NULL) + else if (g.HoveredRootWindow == NULL && g.FocusedWindow != NULL && GetFrontMostModalRootWindow() == NULL) { // Clicking on void disable focus FocusWindow(NULL); @@ -3176,7 +3176,7 @@ bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) { ImGuiWindow* window = GetCurrentWindow(); - ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow; + ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow; const ImVec2 content_avail = ImGui::GetContentRegionAvail(); ImVec2 size = size_arg; @@ -3251,7 +3251,7 @@ bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size) const ImGuiStyle& style = g.Style; ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, style.Colors[ImGuiCol_FrameBg]); ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, style.FrameRounding); - return ImGui::BeginChild(id, size); + return ImGui::BeginChild(id, size, false, ImGuiWindowFlags_NoMove); } void ImGui::EndChildFrame()