MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / BeginDragDropTarget

Method BeginDragDropTarget

lib/imgui/imgui.cpp:9136–9160  ·  view source on GitHub ↗

We don't use BeginDragDropTargetCustom() and duplicate its code because: 1) we use LastItemRectHoveredRect which handles items that pushes 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 HoveredWindow test is po

Source from the content-addressed store, hash-verified

9134// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
9135// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
9136bool ImGui::BeginDragDropTarget()
9137{
9138 ImGuiContext& g = *GImGui;
9139 if (!g.DragDropActive)
9140 return false;
9141
9142 ImGuiWindow* window = g.CurrentWindow;
9143 if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
9144 return false;
9145 if (g.HoveredWindow == NULL || window->RootWindow != g.HoveredWindow->RootWindow)
9146 return false;
9147
9148 const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect;
9149 ImGuiID id = window->DC.LastItemId;
9150 if (id == 0)
9151 id = window->GetIDFromRectangle(display_rect);
9152 if (g.DragDropPayload.SourceId == id)
9153 return false;
9154
9155 IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
9156 g.DragDropTargetRect = display_rect;
9157 g.DragDropTargetId = id;
9158 g.DragDropWithinSourceOrTarget = true;
9159 return true;
9160}
9161
9162bool ImGui::IsDragDropPayloadBeingAccepted()
9163{

Callers

nothing calls this directly

Calls 1

GetIDFromRectangleMethod · 0.80

Tested by

no test coverage detected