|
@@ -4160,6 +4160,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|
DragDropSourceFrameCount = -1;
|
|
DragDropSourceFrameCount = -1;
|
|
DragDropMouseButton = -1;
|
|
DragDropMouseButton = -1;
|
|
DragDropTargetId = 0;
|
|
DragDropTargetId = 0;
|
|
|
|
+ DragDropTargetFullViewport = 0;
|
|
DragDropAcceptFlags = ImGuiDragDropFlags_None;
|
|
DragDropAcceptFlags = ImGuiDragDropFlags_None;
|
|
DragDropAcceptIdCurrRectSurface = 0.0f;
|
|
DragDropAcceptIdCurrRectSurface = 0.0f;
|
|
DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
|
|
DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
|
|
@@ -14722,6 +14723,31 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
|
|
g.DragDropTargetRect = bb;
|
|
g.DragDropTargetRect = bb;
|
|
g.DragDropTargetClipRect = window->ClipRect; // May want to be overridden by user depending on use case?
|
|
g.DragDropTargetClipRect = window->ClipRect; // May want to be overridden by user depending on use case?
|
|
g.DragDropTargetId = id;
|
|
g.DragDropTargetId = id;
|
|
|
|
+ g.DragDropTargetFullViewport = 0;
|
|
|
|
+ g.DragDropWithinTarget = true;
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 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.
|
|
|
|
+bool ImGui::BeginDragDropTargetViewport(ImGuiViewport* viewport, const ImRect* p_bb)
|
|
|
|
+{
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
+ if (!g.DragDropActive)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ ImRect bb = p_bb ? *p_bb : ((ImGuiViewportP*)viewport)->GetWorkRect();
|
|
|
|
+ ImGuiID id = viewport->ID;
|
|
|
|
+ if (!IsMouseHoveringRect(bb.Min, bb.Max, false) || (id == g.DragDropPayload.SourceId))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ IM_ASSERT(g.DragDropWithinTarget == false && g.DragDropWithinSource == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
|
|
|
|
+ g.DragDropTargetRect = bb;
|
|
|
|
+ g.DragDropTargetClipRect = bb;
|
|
|
|
+ g.DragDropTargetId = id;
|
|
|
|
+ g.DragDropTargetFullViewport = id;
|
|
g.DragDropWithinTarget = true;
|
|
g.DragDropWithinTarget = true;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -14792,8 +14818,17 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
|
// Render default drop visuals
|
|
// Render default drop visuals
|
|
payload.Preview = was_accepted_previously;
|
|
payload.Preview = was_accepted_previously;
|
|
flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that live for 1 frame)
|
|
flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that live for 1 frame)
|
|
- if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
|
|
|
|
|
|
+ const bool draw_target_rect = payload.Preview && !(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect);
|
|
|
|
+ if (draw_target_rect && g.DragDropTargetFullViewport != 0)
|
|
|
|
+ {
|
|
|
|
+ ImRect bb = g.DragDropTargetRect;
|
|
|
|
+ bb.Expand(-3.5f);
|
|
|
|
+ RenderDragDropTargetRectEx(GetForegroundDrawList(), bb);
|
|
|
|
+ }
|
|
|
|
+ else if (draw_target_rect)
|
|
|
|
+ {
|
|
RenderDragDropTargetRectForItem(r);
|
|
RenderDragDropTargetRectForItem(r);
|
|
|
|
+ }
|
|
|
|
|
|
g.DragDropAcceptFrameCount = g.FrameCount;
|
|
g.DragDropAcceptFrameCount = g.FrameCount;
|
|
if ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) && g.DragDropMouseButton == -1)
|
|
if ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) && g.DragDropMouseButton == -1)
|