mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 07:40:22 +01:00
Refactor moving ID stack functions to their own section (part 2)
This commit is contained in:
parent
0bf134a8e2
commit
f959c417fe
80
imgui.cpp
80
imgui.cpp
@ -3782,45 +3782,6 @@ ImGuiWindow::~ImGuiWindow()
|
||||
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 @@ bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
|
||||
// [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;
|
||||
|
Loading…
Reference in New Issue
Block a user