From 792a8631aafd3df8d45563e3af60e39feb20b31d Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 31 Oct 2019 14:01:35 +0100 Subject: [PATCH] Metrics: Expose basic details of each window key/value state storage. --- docs/CHANGELOG.txt | 1 + imgui.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 719e598fd..a5f6b1ee0 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -72,6 +72,7 @@ Other Changes: - Docs: Improved and moved FAQ to docs/FAQ.md so it can be readable on the web. [@ButternCream, @ocornut] - Docs: Added permanent redirect from https://www.dearimgui.org/faq to FAQ page. - Demo: Added simple item reordering demo in Widgets -> Drag and Drop section. (#2823, #143) [@rokups] +- Metrics: Expose basic details of each window key/value state storage. - Examples: DX12: Using IDXGIDebug1::ReportLiveObjects() when DX12_ENABLE_DEBUG_LAYER is enabled. - Examples: Emscripten: Removed NO_FILESYSTEM from Makefile, seems to fail on some setup. (#2734) [@Funto] - Backends: OpenGL3: Fix building with pre-3.2 GL loaders which do not expose glDrawElementsBaseVertex(), diff --git a/imgui.cpp b/imgui.cpp index 53b19fad7..22f5395e5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9762,7 +9762,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) NodeColumns(&window->ColumnsStorage[n]); ImGui::TreePop(); } - ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.size_in_bytes()); + NodeStorage(&window->StateStorage, "Storage"); ImGui::TreePop(); } @@ -9787,6 +9787,18 @@ void ImGui::ShowMetricsWindow(bool* p_open) ImGui::TreePop(); } } + + static void NodeStorage(ImGuiStorage* storage, const char* label) + { + if (!ImGui::TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes())) + return; + for (int n = 0; n < storage->Data.Size; n++) + { + const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n]; + ImGui::BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer. + } + ImGui::TreePop(); + } }; Funcs::NodeWindows(g.Windows, "Windows");