Skip to content

Commit

Permalink
Internals: removed GetIDNoKeepAlive() now that it is the same as GetI…
Browse files Browse the repository at this point in the history
…D(). (#5181)

Amend 9038678
  • Loading branch information
ocornut committed Apr 12, 2022
1 parent 9038678 commit 6d15a50
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 38 deletions.
38 changes: 4 additions & 34 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3294,36 +3294,6 @@ ImGuiID ImGuiWindow::GetID(int n)
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.
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
{
Expand Down Expand Up @@ -7420,31 +7390,31 @@ void ImGui::PushID(const char* str_id)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetIDNoKeepAlive(str_id);
ImGuiID id = window->GetID(str_id);
window->IDStack.push_back(id);
}

void ImGui::PushID(const char* str_id_begin, const char* str_id_end)
{
ImGuiContext& g = *GImGui;
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);
}

void ImGui::PushID(const void* ptr_id)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetIDNoKeepAlive(ptr_id);
ImGuiID id = window->GetID(ptr_id);
window->IDStack.push_back(id);
}

void ImGui::PushID(int int_id)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGuiID id = window->GetIDNoKeepAlive(int_id);
ImGuiID id = window->GetID(int_id);
window->IDStack.push_back(id);
}

Expand Down
3 changes: 0 additions & 3 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2117,9 +2117,6 @@ struct IMGUI_API ImGuiWindow
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.
Expand Down
2 changes: 1 addition & 1 deletion imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)

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.
Expand Down

0 comments on commit 6d15a50

Please sign in to comment.