Drag and Drop: Clear payload buffers more consistently in ClearDragAndDrop() + BeginDragDropTargetCustom() can't succeed with hidden contents. (#143)

This commit is contained in:
omar 2018-07-31 13:36:06 +02:00
parent e13e5982ff
commit 79ae6d3bf6

View File

@ -4444,11 +4444,7 @@ void ImGui::EndFrame()
// Drag and Drop: Elapse payload at the end of the frame if mouse has been released // Drag and Drop: Elapse payload at the end of the frame if mouse has been released
if (g.DragDropActive && g.DragDropPayload.DataFrameCount + 1 < g.FrameCount && !IsMouseDown(g.DragDropMouseButton)) if (g.DragDropActive && g.DragDropPayload.DataFrameCount + 1 < g.FrameCount && !IsMouseDown(g.DragDropMouseButton))
{
ClearDragDrop(); ClearDragDrop();
g.DragDropPayloadBufHeap.clear();
memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
}
// Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing. // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount) if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount)
@ -13629,6 +13625,9 @@ void ImGui::ClearDragDrop()
g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0; g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
g.DragDropAcceptIdCurrRectSurface = FLT_MAX; g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
g.DragDropAcceptFrameCount = -1; g.DragDropAcceptFrameCount = -1;
g.DragDropPayloadBufHeap.clear();
memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
} }
// Call when current ID is active. // Call when current ID is active.
@ -13802,6 +13801,8 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
IM_ASSERT(id != 0); IM_ASSERT(id != 0);
if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId)) if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId))
return false; return false;
if (window->SkipItems)
return false;
IM_ASSERT(g.DragDropWithinSourceOrTarget == false); IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
g.DragDropTargetRect = bb; g.DragDropTargetRect = bb;