MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / BeginDragDropTarget

Method BeginDragDropTarget

include/imgui/imgui.cpp:15100–15129  ·  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

15098// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
15099// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
15100bool ImGui::BeginDragDropTarget()
15101{
15102 ImGuiContext& g = *GImGui;
15103 if (!g.DragDropActive)
15104 return false;
15105
15106 ImGuiWindow* window = g.CurrentWindow;
15107 if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect))
15108 return false;
15109 ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow;
15110 if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow || window->SkipItems)
15111 return false;
15112
15113 const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect;
15114 ImGuiID id = g.LastItemData.ID;
15115 if (id == 0)
15116 {
15117 id = window->GetIDFromRectangle(display_rect);
15118 KeepAliveID(id);
15119 }
15120 if (g.DragDropPayload.SourceId == id)
15121 return false;
15122
15123 IM_ASSERT(g.DragDropWithinTarget == false && g.DragDropWithinSource == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
15124 g.DragDropTargetRect = display_rect;
15125 g.DragDropTargetClipRect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasClipRect) ? g.LastItemData.ClipRect : window->ClipRect;
15126 g.DragDropTargetId = id;
15127 g.DragDropWithinTarget = true;
15128 return true;
15129}
15130
15131bool ImGui::IsDragDropPayloadBeingAccepted()
15132{

Callers

nothing calls this directly

Calls 1

GetIDFromRectangleMethod · 0.80

Tested by

no test coverage detected