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.
| 15074 | // if (ImGui::BeginDragDropTargetViewport(ImGui::GetMainViewport(), NULL)) |
| 15075 | // But we are leaving the hover test to the caller for maximum flexibility. |
| 15076 | bool 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. |
nothing calls this directly
no test coverage detected