Refactor moving ID stack functions to their own section (part 2)
diff --git a/imgui.cpp b/imgui.cpp
index 1d55559..64655f1 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -3782,45 +3782,6 @@
ColumnsStorage.clear_destruct();
}
-ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
-{
- ImGuiID seed = IDStack.back();
- ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
- ImGuiContext& g = *Ctx;
- if (g.DebugHookIdInfo == id)
- ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end);
- return id;
-}
-
-ImGuiID ImGuiWindow::GetID(const void* ptr)
-{
- ImGuiID seed = IDStack.back();
- ImGuiID id = ImHashData(&ptr, sizeof(void*), seed);
- ImGuiContext& g = *Ctx;
- if (g.DebugHookIdInfo == id)
- ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL);
- return id;
-}
-
-ImGuiID ImGuiWindow::GetID(int n)
-{
- ImGuiID seed = IDStack.back();
- ImGuiID id = ImHashData(&n, sizeof(n), seed);
- ImGuiContext& g = *Ctx;
- 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)
-{
- ImGuiID seed = IDStack.back();
- ImRect r_rel = ImGui::WindowRectAbsToRel(this, r_abs);
- ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed);
- return id;
-}
-
static void SetCurrentWindow(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
@@ -8000,6 +7961,47 @@
// [SECTION] ID STACK
//-----------------------------------------------------------------------------
+// This is one of the very rare legacy case where we use ImGuiWindow methods,
+// it should ideally be flattened at some point but it's been used a lots by widgets.
+ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
+{
+ ImGuiID seed = IDStack.back();
+ ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
+ ImGuiContext& g = *Ctx;
+ if (g.DebugHookIdInfo == id)
+ ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end);
+ return id;
+}
+
+ImGuiID ImGuiWindow::GetID(const void* ptr)
+{
+ ImGuiID seed = IDStack.back();
+ ImGuiID id = ImHashData(&ptr, sizeof(void*), seed);
+ ImGuiContext& g = *Ctx;
+ if (g.DebugHookIdInfo == id)
+ ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL);
+ return id;
+}
+
+ImGuiID ImGuiWindow::GetID(int n)
+{
+ ImGuiID seed = IDStack.back();
+ ImGuiID id = ImHashData(&n, sizeof(n), seed);
+ ImGuiContext& g = *Ctx;
+ 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)
+{
+ ImGuiID seed = IDStack.back();
+ ImRect r_rel = ImGui::WindowRectAbsToRel(this, r_abs);
+ ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed);
+ return id;
+}
+
void ImGui::PushID(const char* str_id)
{
ImGuiContext& g = *GImGui;