Made PushID() behave the same in 32-bit and 64-bit, by not padding the integer into a void*. (Also technically faster.)
diff --git a/imgui.cpp b/imgui.cpp
index 721fbe1..0be6954 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -2624,6 +2624,14 @@
return id;
}
+ImGuiID ImGuiWindow::GetID(int n)
+{
+ ImGuiID seed = IDStack.back();
+ ImGuiID id = ImHashData(&n, sizeof(n), seed);
+ ImGui::KeepAliveID(id);
+ return id;
+}
+
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end)
{
ImGuiID seed = IDStack.back();
@@ -2636,6 +2644,12 @@
return ImHashData(&ptr, sizeof(void*), seed);
}
+ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n)
+{
+ ImGuiID seed = IDStack.back();
+ return ImHashData(&n, sizeof(n), seed);
+}
+
// This is only used in rare/specific situations to manufacture an ID out of nowhere.
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
{
@@ -6836,9 +6850,8 @@
void ImGui::PushID(int int_id)
{
- const void* ptr_id = (void*)(intptr_t)int_id;
ImGuiWindow* window = GImGui->CurrentWindow;
- window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
+ window->IDStack.push_back(window->GetIDNoKeepAlive(int_id));
}
// Push a given id value ignoring the ID stack as a seed.
diff --git a/imgui_internal.h b/imgui_internal.h
index 1760bbb..ab14d9f 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1330,8 +1330,10 @@
ImGuiID GetID(const char* str, const char* str_end = NULL);
ImGuiID GetID(const void* ptr);
+ ImGuiID GetID(int n);
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
ImGuiID GetIDNoKeepAlive(const void* ptr);
+ ImGuiID GetIDNoKeepAlive(int n);
ImGuiID GetIDFromRectangle(const ImRect& r_abs);
// We don't use g.FontSize because the window may be != g.CurrentWidow.