From 839ecce57154a33ede985eeab746828f8102c8d9 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Thu, 25 Feb 2021 14:04:07 +0200 Subject: [PATCH] Internals: Add a way to request window to not process any interactions for specified number of frames. --- imgui.cpp | 7 +++++++ imgui_internal.h | 1 + 2 files changed, 8 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 63d23f1ae..9ac6d20ad 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6827,6 +6827,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Update the Hidden flag window->Hidden = (window->HiddenFramesCanSkipItems > 0) || (window->HiddenFramesCannotSkipItems > 0) || (window->HiddenFramesForRenderOnly > 0); + // Disable inputs for requested number of frames + if (window->DisableInputsFrames > 0) + { + window->DisableInputsFrames--; + window->Flags |= ImGuiWindowFlags_NoInputs; + } + // Update the SkipItems flag, used to early out of all items functions (no layout required) bool skip_items = false; if (window->Collapsed || !window->Active || window->Hidden) diff --git a/imgui_internal.h b/imgui_internal.h index 96236360a..92173ef08 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1970,6 +1970,7 @@ struct IMGUI_API ImGuiWindow ImS8 HiddenFramesCanSkipItems; // Hide the window for N frames ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only + ImS8 DisableInputsFrames; // Disable window interactions for N frames ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use. ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use. ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.