|
|
|
@ -3121,7 +3121,7 @@ ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n)
|
|
|
|
|
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
|
|
|
|
|
{
|
|
|
|
|
ImGuiID seed = IDStack.back();
|
|
|
|
|
const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) };
|
|
|
|
|
ImRect r_rel = ImGui::WindowRectAbsToRel(this, r_abs);
|
|
|
|
|
ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed);
|
|
|
|
|
ImGui::KeepAliveID(id);
|
|
|
|
|
return id;
|
|
|
|
@ -10276,16 +10276,16 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
|
|
|
|
|
// A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride.
|
|
|
|
|
// A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag.
|
|
|
|
|
if (!(flags & ImGuiDragDropFlags_SourceAllowNullID))
|
|
|
|
|
{
|
|
|
|
|
IM_ASSERT(0);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
|
|
|
|
|
// Magic fallback to handle items with no assigned ID, e.g. Text(), Image()
|
|
|
|
|
// We build a throwaway ID based on current ID stack + relative AABB of items in window.
|
|
|
|
|
// THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
|
|
|
|
|
// THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING/RESIZINGG OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
|
|
|
|
|
// We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
|
|
|
|
|
// Rely on keeping other window->LastItemXXX fields intact.
|
|
|
|
|
source_id = g.LastItemData.ID = window->GetIDFromRectangle(g.LastItemData.Rect);
|
|
|
|
|