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
| 11948 | // 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can. |
| 11949 | // Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case) |
| 11950 | bool ImGui::BeginDragDropTarget() |
| 11951 | { |
| 11952 | ImGuiContext& g = *GImGui; |
| 11953 | if (!g.DragDropActive) |
| 11954 | return false; |
| 11955 | |
| 11956 | ImGuiWindow* window = g.CurrentWindow; |
| 11957 | if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect)) |
| 11958 | return false; |
| 11959 | ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow; |
| 11960 | if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow || window->SkipItems) |
| 11961 | return false; |
| 11962 | |
| 11963 | const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect; |
| 11964 | ImGuiID id = g.LastItemData.ID; |
| 11965 | if (id == 0) |
| 11966 | { |
| 11967 | id = window->GetIDFromRectangle(display_rect); |
| 11968 | KeepAliveID(id); |
| 11969 | } |
| 11970 | if (g.DragDropPayload.SourceId == id) |
| 11971 | return false; |
| 11972 | |
| 11973 | IM_ASSERT(g.DragDropWithinTarget == false); |
| 11974 | g.DragDropTargetRect = display_rect; |
| 11975 | g.DragDropTargetId = id; |
| 11976 | g.DragDropWithinTarget = true; |
| 11977 | return true; |
| 11978 | } |
| 11979 | |
| 11980 | bool ImGui::IsDragDropPayloadBeingAccepted() |
| 11981 | { |
nothing calls this directly
no test coverage detected