Made PushID() behave the same in 32-bit and 64-bit, by not padding the integer into a void*. (Also technically faster.)
This commit is contained in:
parent
431aa4e456
commit
2b997141cf
17
imgui.cpp
17
imgui.cpp
@ -2624,6 +2624,14 @@ ImGuiID ImGuiWindow::GetID(const void* ptr)
|
||||
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 @@ ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr)
|
||||
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(const void* ptr_id)
|
||||
|
||||
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.
|
||||
|
@ -1330,8 +1330,10 @@ public:
|
||||
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user