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

Method BeginDragDropTargetViewport

include/imgui/imgui.cpp:15076–15094  ·  view source on GitHub ↗

Typical usage would be: if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) if (ImGui::BeginDragDropTargetViewport(ImGui::GetMainViewport(), NULL)) But we are leaving the hover test to the caller for maximum flexibility.

Source from the content-addressed store, hash-verified

15074// if (ImGui::BeginDragDropTargetViewport(ImGui::GetMainViewport(), NULL))
15075// But we are leaving the hover test to the caller for maximum flexibility.
15076bool ImGui::BeginDragDropTargetViewport(ImGuiViewport* viewport, const ImRect* p_bb)
15077{
15078 ImGuiContext& g = *GImGui;
15079 if (!g.DragDropActive)
15080 return false;
15081
15082 ImRect bb = p_bb ? *p_bb : ((ImGuiViewportP*)viewport)->GetWorkRect();
15083 ImGuiID id = viewport->ID;
15084 if (!IsMouseHoveringRect(bb.Min, bb.Max, false) || (id == g.DragDropPayload.SourceId))
15085 return false;
15086
15087 IM_ASSERT(g.DragDropWithinTarget == false && g.DragDropWithinSource == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
15088 g.DragDropTargetRect = bb;
15089 g.DragDropTargetClipRect = bb;
15090 g.DragDropTargetId = id;
15091 g.DragDropTargetFullViewport = id;
15092 g.DragDropWithinTarget = true;
15093 return true;
15094}
15095
15096// We don't use BeginDragDropTargetCustom() and duplicate its code because:
15097// 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.

Callers

nothing calls this directly

Calls 1

GetWorkRectMethod · 0.80

Tested by

no test coverage detected