From b086f7ae78991ed72cf02ad589ef51a79413945d Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 18 Feb 2022 18:39:29 +0100 Subject: [PATCH] Clipper: Assert on extraneous calls to Step(). (#4822) + Demo tweak. --- imgui.cpp | 1 + imgui.h | 8 +++----- imgui_demo.cpp | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 8cbe97b20661..11440579aff4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2599,6 +2599,7 @@ bool ImGuiListClipper::Step() ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; ImGuiListClipperData* data = (ImGuiListClipperData*)TempData; + IM_ASSERT(data != NULL && "Called ImGuiListClipper::Step() too many times, or before ImGuiListClipper::Begin() ?"); ImGuiTable* table = g.CurrentTable; if (table && table->IsInsideRow) diff --git a/imgui.h b/imgui.h index 1e8f5b7cd4c3..a7bc141b5657 100644 --- a/imgui.h +++ b/imgui.h @@ -1422,7 +1422,7 @@ enum ImGuiKey_ ImGuiKey_GamepadRStickLeft, // [Analog] ImGuiKey_GamepadRStickRight, // [Analog] - // Keyboard Modifiers + // Keyboard Modifiers (explicitly submitted by backend via AddKeyEvent() calls) // - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper, in a format allowing // them to be accessed via standard key API, allowing calls such as IsKeyPressed(), IsKeyReleased(), querying duration etc. // - Code polling every keys (e.g. an interface to detect a key press for input mapping) might want to ignore those @@ -1430,11 +1430,9 @@ enum ImGuiKey_ // - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys. // In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and // backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user... - ImGuiKey_ModCtrl, - ImGuiKey_ModShift, - ImGuiKey_ModAlt, - ImGuiKey_ModSuper, + ImGuiKey_ModCtrl, ImGuiKey_ModShift, ImGuiKey_ModAlt, ImGuiKey_ModSuper, + // End of list ImGuiKey_COUNT, // No valid ImGuiKey is ever greater than this value // [Internal] Prior to 1.87 we required user to fill io.KeysDown[512] using their own native index + a io.KeyMap[] array. diff --git a/imgui_demo.cpp b/imgui_demo.cpp index c8c92f1d026f..cfa956693268 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -5666,12 +5666,18 @@ static void ShowDemoWindowMisc() ImGuiIO& io = ImGui::GetIO(); // Display ImGuiIO output flags - ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse); - ImGui::Text("WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose); - ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard); - ImGui::Text("WantTextInput: %d", io.WantTextInput); - ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos); - ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible); + IMGUI_DEMO_MARKER("Inputs, Navigation & Focus/Output"); + ImGui::SetNextItemOpen(true, ImGuiCond_Once); + if (ImGui::TreeNode("Output")) + { + ImGui::Text("io.WantCaptureMouse: %d", io.WantCaptureMouse); + ImGui::Text("io.WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose); + ImGui::Text("io.WantCaptureKeyboard: %d", io.WantCaptureKeyboard); + ImGui::Text("io.WantTextInput: %d", io.WantTextInput); + ImGui::Text("io.WantSetMousePos: %d", io.WantSetMousePos); + ImGui::Text("io.NavActive: %d, io.NavVisible: %d", io.NavActive, io.NavVisible); + ImGui::TreePop(); + } // Display Mouse state IMGUI_DEMO_MARKER("Inputs, Navigation & Focus/Mouse State");