MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / BeginDragDropTarget

Method BeginDragDropTarget

core/src/imgui/imgui.cpp:9975–10000  ·  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

9973// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
9974// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
9975bool ImGui::BeginDragDropTarget()
9976{
9977 ImGuiContext& g = *GImGui;
9978 if (!g.DragDropActive)
9979 return false;
9980
9981 ImGuiWindow* window = g.CurrentWindow;
9982 if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
9983 return false;
9984 ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow;
9985 if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow)
9986 return false;
9987
9988 const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect;
9989 ImGuiID id = window->DC.LastItemId;
9990 if (id == 0)
9991 id = window->GetIDFromRectangle(display_rect);
9992 if (g.DragDropPayload.SourceId == id)
9993 return false;
9994
9995 IM_ASSERT(g.DragDropWithinTarget == false);
9996 g.DragDropTargetRect = display_rect;
9997 g.DragDropTargetId = id;
9998 g.DragDropWithinTarget = true;
9999 return true;
10000}
10001
10002bool ImGui::IsDragDropPayloadBeingAccepted()
10003{

Callers

nothing calls this directly

Calls 1

GetIDFromRectangleMethod · 0.80

Tested by

no test coverage detected