mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Drag and Drop: Clear state on EndDragDropTarget() with delivery + fixed handling of overlapping targets when smaller one is submitted before and can accept the same data type. (#6183, #5817)
This commit is contained in:
parent
2ee77aa6be
commit
e9743d85dd
@ -47,6 +47,10 @@ Breaking Changes:
|
||||
|
||||
Other changes:
|
||||
|
||||
- Drag and Drop: Fixed handling of overlapping targets when smaller one is submitted
|
||||
before and can accept the same data type. (#6183).
|
||||
- Drag and Drop: Clear drag and drop state as soon as delivery is accepted in order to
|
||||
avoid inteferences. (#5817, #6183) [@DimaKoltun]
|
||||
- Backends: Win32: Use WM_NCMOUSEMOVE / WM_NCMOUSELEAVE to track mouse positions over
|
||||
non-client area (e.g. OS decorations) when app is not focused. (#6045, #6162)
|
||||
|
||||
|
21
imgui.cpp
21
imgui.cpp
@ -12171,12 +12171,13 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
||||
const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId);
|
||||
ImRect r = g.DragDropTargetRect;
|
||||
float r_surface = r.GetWidth() * r.GetHeight();
|
||||
if (r_surface <= g.DragDropAcceptIdCurrRectSurface)
|
||||
{
|
||||
g.DragDropAcceptFlags = flags;
|
||||
g.DragDropAcceptIdCurr = g.DragDropTargetId;
|
||||
g.DragDropAcceptIdCurrRectSurface = r_surface;
|
||||
}
|
||||
if (r_surface > g.DragDropAcceptIdCurrRectSurface)
|
||||
return NULL;
|
||||
|
||||
g.DragDropAcceptFlags = flags;
|
||||
g.DragDropAcceptIdCurr = g.DragDropTargetId;
|
||||
g.DragDropAcceptIdCurrRectSurface = r_surface;
|
||||
//IMGUI_DEBUG_LOG("AcceptDragDropPayload(): %08X: accept\n", g.DragDropTargetId);
|
||||
|
||||
// Render default drop visuals
|
||||
payload.Preview = was_accepted_previously;
|
||||
@ -12185,10 +12186,11 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
||||
window->DrawList->AddRect(r.Min - ImVec2(3.5f,3.5f), r.Max + ImVec2(3.5f, 3.5f), GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f);
|
||||
|
||||
g.DragDropAcceptFrameCount = g.FrameCount;
|
||||
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
|
||||
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting OS window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
|
||||
if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery))
|
||||
return NULL;
|
||||
|
||||
//IMGUI_DEBUG_LOG("AcceptDragDropPayload(): %08X: return payload\n", g.DragDropTargetId);
|
||||
return &payload;
|
||||
}
|
||||
|
||||
@ -12204,13 +12206,16 @@ const ImGuiPayload* ImGui::GetDragDropPayload()
|
||||
return (g.DragDropActive && g.DragDropPayload.DataFrameCount != -1) ? &g.DragDropPayload : NULL;
|
||||
}
|
||||
|
||||
// We don't really use/need this now, but added it for the sake of consistency and because we might need it later.
|
||||
void ImGui::EndDragDropTarget()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.DragDropActive);
|
||||
IM_ASSERT(g.DragDropWithinTarget);
|
||||
g.DragDropWithinTarget = false;
|
||||
|
||||
// Clear drag and drop state payload right after delivery
|
||||
if (g.DragDropPayload.Delivery)
|
||||
ClearDragDrop();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user