Internals: removed GetIDNoKeepAlive() now that it is the same as GetID(). (#5181)

Amend 9038678
This commit is contained in:
ocornut 2022-04-12 14:49:21 +02:00
parent 90386780e3
commit 6d15a506fa
3 changed files with 5 additions and 38 deletions

View File

@ -3294,36 +3294,6 @@ ImGuiID ImGuiWindow::GetID(int n)
return id; return id;
} }
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end)
{
ImGuiID seed = IDStack.back();
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
ImGuiContext& g = *GImGui;
if (g.DebugHookIdInfo == id)
ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end);
return id;
}
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr)
{
ImGuiID seed = IDStack.back();
ImGuiID id = ImHashData(&ptr, sizeof(void*), seed);
ImGuiContext& g = *GImGui;
if (g.DebugHookIdInfo == id)
ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL);
return id;
}
ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n)
{
ImGuiID seed = IDStack.back();
ImGuiID id = ImHashData(&n, sizeof(n), seed);
ImGuiContext& g = *GImGui;
if (g.DebugHookIdInfo == id)
ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL);
return id;
}
// This is only used in rare/specific situations to manufacture an ID out of nowhere. // This is only used in rare/specific situations to manufacture an ID out of nowhere.
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
{ {
@ -7420,7 +7390,7 @@ void ImGui::PushID(const char* str_id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetIDNoKeepAlive(str_id); ImGuiID id = window->GetID(str_id);
window->IDStack.push_back(id); window->IDStack.push_back(id);
} }
@ -7428,7 +7398,7 @@ void ImGui::PushID(const char* str_id_begin, const char* str_id_end)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetIDNoKeepAlive(str_id_begin, str_id_end); ImGuiID id = window->GetID(str_id_begin, str_id_end);
window->IDStack.push_back(id); window->IDStack.push_back(id);
} }
@ -7436,7 +7406,7 @@ void ImGui::PushID(const void* ptr_id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetIDNoKeepAlive(ptr_id); ImGuiID id = window->GetID(ptr_id);
window->IDStack.push_back(id); window->IDStack.push_back(id);
} }
@ -7444,7 +7414,7 @@ void ImGui::PushID(int int_id)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetIDNoKeepAlive(int_id); ImGuiID id = window->GetID(int_id);
window->IDStack.push_back(id); window->IDStack.push_back(id);
} }

View File

@ -2117,9 +2117,6 @@ public:
ImGuiID GetID(const char* str, const char* str_end = NULL); ImGuiID GetID(const char* str, const char* str_end = NULL);
ImGuiID GetID(const void* ptr); ImGuiID GetID(const void* ptr);
ImGuiID GetID(int n); 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); ImGuiID GetIDFromRectangle(const ImRect& r_abs);
// We don't use g.FontSize because the window may be != g.CurrentWidow. // We don't use g.FontSize because the window may be != g.CurrentWidow.

View File

@ -856,7 +856,7 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis) ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis)
{ {
return window->GetIDNoKeepAlive(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY"); return window->GetID(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY");
} }
// Return scrollbar rectangle, must only be called for corresponding axis if window->ScrollbarX/Y is set. // Return scrollbar rectangle, must only be called for corresponding axis if window->ScrollbarX/Y is set.