MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / BeginDragDropTarget

Method BeginDragDropTarget

Dependencies/ImGui/src/imgui.cpp:14924–14953  ·  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

14922// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
14923// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
14924bool ImGui::BeginDragDropTarget()
14925{
14926 ImGuiContext& g = *GImGui;
14927 if (!g.DragDropActive)
14928 return false;
14929
14930 ImGuiWindow* window = g.CurrentWindow;
14931 if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect))
14932 return false;
14933 ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow;
14934 if (hovered_window == NULL || window->RootWindowDockTree != hovered_window->RootWindowDockTree || window->SkipItems)
14935 return false;
14936
14937 const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect;
14938 ImGuiID id = g.LastItemData.ID;
14939 if (id == 0)
14940 {
14941 id = window->GetIDFromRectangle(display_rect);
14942 KeepAliveID(id);
14943 }
14944 if (g.DragDropPayload.SourceId == id)
14945 return false;
14946
14947 IM_ASSERT(g.DragDropWithinTarget == false && g.DragDropWithinSource == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
14948 g.DragDropTargetRect = display_rect;
14949 g.DragDropTargetClipRect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasClipRect) ? g.LastItemData.ClipRect : window->ClipRect;
14950 g.DragDropTargetId = id;
14951 g.DragDropWithinTarget = true;
14952 return true;
14953}
14954
14955bool ImGui::IsDragDropPayloadBeingAccepted()
14956{

Callers

nothing calls this directly

Calls 1

GetIDFromRectangleMethod · 0.80

Tested by

no test coverage detected