From e4ba6e525b93814fbf7603bdd83a92b19868dae8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 28 Nov 2015 15:35:10 +0000 Subject: [PATCH] Columns:: columns set with no implicit id include the columns count into the id to avoid collisions (#125) --- imgui.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index a95a50a2..a473433e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8881,10 +8881,13 @@ void ImGui::Columns(int columns_count, const char* id, bool border) } } - // Set state for first column - ImGui::PushID(0x11223344); // Differentiate column ID with an arbitrary/random prefix for cases where users name their columns set the same as another non-scope widget - window->DC.ColumnsSetID = window->GetID(id ? id : ""); + // Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. + // In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer. + ImGui::PushID(0x11223347 + (id ? 0 : columns_count)); + window->DC.ColumnsSetID = window->GetID(id ? id : "columns"); ImGui::PopID(); + + // Set state for first column window->DC.ColumnsCurrent = 0; window->DC.ColumnsCount = columns_count; window->DC.ColumnsShowBorders = border;