MCPcopy Create free account
hub / github.com/cinder/Cinder / BeginDragDropTarget

Method BeginDragDropTarget

src/imgui/imgui.cpp:14720–14749  ·  view source on GitHub ↗

We don't use BeginDragDropTargetCustom() and duplicate its code because: 1) we use LastItemData's ImGuiItemStatusFlags_HoveredRect which handles items that push a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them. 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can. Also note how the Ho

Source from the content-addressed store, hash-verified

14718// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
14719// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
14720bool ImGui::BeginDragDropTarget()
14721{
14722 ImGuiContext& g = *GImGui;
14723 if (!g.DragDropActive)
14724 return false;
14725
14726 ImGuiWindow* window = g.CurrentWindow;
14727 if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect))
14728 return false;
14729 ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow;
14730 if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow || window->SkipItems)
14731 return false;
14732
14733 const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect;
14734 ImGuiID id = g.LastItemData.ID;
14735 if (id == 0)
14736 {
14737 id = window->GetIDFromRectangle(display_rect);
14738 KeepAliveID(id);
14739 }
14740 if (g.DragDropPayload.SourceId == id)
14741 return false;
14742
14743 IM_ASSERT(g.DragDropWithinTarget == false && g.DragDropWithinSource == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
14744 g.DragDropTargetRect = display_rect;
14745 g.DragDropTargetClipRect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasClipRect) ? g.LastItemData.ClipRect : window->ClipRect;
14746 g.DragDropTargetId = id;
14747 g.DragDropWithinTarget = true;
14748 return true;
14749}
14750
14751bool ImGui::IsDragDropPayloadBeingAccepted()
14752{

Callers

nothing calls this directly

Calls 1

GetIDFromRectangleMethod · 0.80

Tested by

no test coverage detected