MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / BeginDragDropTarget

Method BeginDragDropTarget

extern/imgui/imgui.cpp:12686–12714  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

12684// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
12685// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
12686bool ImGui::BeginDragDropTarget()
12687{
12688 ImGuiContext& g = *GImGui;
12689 if (!g.DragDropActive)
12690 return false;
12691
12692 ImGuiWindow* window = g.CurrentWindow;
12693 if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect))
12694 return false;
12695 ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow;
12696 if (hovered_window == NULL || window->RootWindowDockTree != hovered_window->RootWindowDockTree || window->SkipItems)
12697 return false;
12698
12699 const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect;
12700 ImGuiID id = g.LastItemData.ID;
12701 if (id == 0)
12702 {
12703 id = window->GetIDFromRectangle(display_rect);
12704 KeepAliveID(id);
12705 }
12706 if (g.DragDropPayload.SourceId == id)
12707 return false;
12708
12709 IM_ASSERT(g.DragDropWithinTarget == false);
12710 g.DragDropTargetRect = display_rect;
12711 g.DragDropTargetId = id;
12712 g.DragDropWithinTarget = true;
12713 return true;
12714}
12715
12716bool ImGui::IsDragDropPayloadBeingAccepted()
12717{

Callers

nothing calls this directly

Calls 1

GetIDFromRectangleMethod · 0.80

Tested by

no test coverage detected