Skip to content

Commit b0d3c3a

Browse files
committed
Drag and Drop: prev/curr storage for DragDropAcceptFlags. ImGuiDragDropFlags_AcceptNoPreviewTooltip test uses DragDropAcceptFlagsPrev for consistency. (#143)
I don't think this would have materialized as a visible bug.
1 parent dacd080 commit b0d3c3a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

imgui.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,7 +4190,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
41904190
DragDropMouseButton = -1;
41914191
DragDropTargetId = 0;
41924192
DragDropTargetFullViewport = 0;
4193-
DragDropAcceptFlags = ImGuiDragDropFlags_None;
4193+
DragDropAcceptFlagsCurr = DragDropAcceptFlagsPrev = ImGuiDragDropFlags_None;
41944194
DragDropAcceptIdCurrRectSurface = 0.0f;
41954195
DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
41964196
DragDropAcceptFrameCount = -1;
@@ -5528,6 +5528,8 @@ void ImGui::NewFrame()
55285528
// Drag and drop
55295529
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
55305530
g.DragDropAcceptIdCurr = 0;
5531+
g.DragDropAcceptFlagsPrev = g.DragDropAcceptFlagsCurr;
5532+
g.DragDropAcceptFlagsCurr = ImGuiDragDropFlags_None;
55315533
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
55325534
g.DragDropWithinSource = false;
55335535
g.DragDropWithinTarget = false;
@@ -14552,7 +14554,7 @@ void ImGui::ClearDragDrop()
1455214554
IMGUI_DEBUG_LOG_ACTIVEID("[dragdrop] ClearDragDrop()\n");
1455314555
g.DragDropActive = false;
1455414556
g.DragDropPayload.Clear();
14555-
g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
14557+
g.DragDropAcceptFlagsCurr = ImGuiDragDropFlags_None;
1455614558
g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
1455714559
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
1455814560
g.DragDropAcceptFrameCount = -1;
@@ -14681,7 +14683,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
1468114683
// Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
1468214684
// We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
1468314685
bool ret;
14684-
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
14686+
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlagsPrev & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
1468514687
ret = BeginTooltipHidden();
1468614688
else
1468714689
ret = BeginTooltip();
@@ -14862,7 +14864,7 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
1486214864
if (r_surface > g.DragDropAcceptIdCurrRectSurface)
1486314865
return NULL;
1486414866

14865-
g.DragDropAcceptFlags = flags;
14867+
g.DragDropAcceptFlagsCurr = flags;
1486614868
g.DragDropAcceptIdCurr = g.DragDropTargetId;
1486714869
g.DragDropAcceptIdCurrRectSurface = r_surface;
1486814870
//IMGUI_DEBUG_LOG("AcceptDragDropPayload(): %08X: accept\n", g.DragDropTargetId);

imgui_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2380,7 +2380,8 @@ struct ImGuiContext
23802380
ImRect DragDropTargetClipRect; // Store ClipRect at the time of item's drawing
23812381
ImGuiID DragDropTargetId;
23822382
ImGuiID DragDropTargetFullViewport;
2383-
ImGuiDragDropFlags DragDropAcceptFlags;
2383+
ImGuiDragDropFlags DragDropAcceptFlagsCurr;
2384+
ImGuiDragDropFlags DragDropAcceptFlagsPrev;
23842385
float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
23852386
ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
23862387
ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)

0 commit comments

Comments
 (0)