From fa10618df65072c08423364858288746ce5eaccf Mon Sep 17 00:00:00 2001 From: Rokas Kupstys <19151258+rokups@users.noreply.github.com> Date: Tue, 8 Dec 2020 15:31:18 +0200 Subject: [PATCH] Fix ID collisions in the demo (#157) Several `CollapsingHeader()` use same label as `BeginPlot()`. This creates an ID collision, which confuses Dear ImGui testing engine. Added `##` in `CollapsingHeader()` label are included in ID calculation, but discarded when rendering. This gives affected `CollapsingHeader()` a different ID and solves ID collision. --- implot_demo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/implot_demo.cpp b/implot_demo.cpp index 042dabc..3908c42 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -286,7 +286,7 @@ void ShowDemoWindow(bool* p_open) { } } //------------------------------------------------------------------------- - if (ImGui::CollapsingHeader("Shaded Plots")) { + if (ImGui::CollapsingHeader("Shaded Plots##")) { static float xs[1001], ys[1001], ys1[1001], ys2[1001], ys3[1001], ys4[1001]; srand(0); for (int i = 0; i < 1001; ++i) { @@ -419,7 +419,7 @@ void ShowDemoWindow(bool* p_open) { ImPlot::EndPlot(); } } - if (ImGui::CollapsingHeader("Stem Plots")) { + if (ImGui::CollapsingHeader("Stem Plots##")) { static double xs[51], ys1[51], ys2[51]; for (int i = 0; i < 51; ++i) { xs[i] = i * 0.02; @@ -1239,7 +1239,7 @@ void ShowDemoWindow(bool* p_open) { } } //------------------------------------------------------------------------- - if (ImGui::CollapsingHeader("Custom Ticks")) { + if (ImGui::CollapsingHeader("Custom Ticks##")) { static bool custom_ticks = true; static bool custom_labels = true; ImGui::Checkbox("Show Custom Ticks", &custom_ticks); @@ -1705,4 +1705,4 @@ void ShowBenchmarkTool() { } } -} \ No newline at end of file +}