mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
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.
This commit is contained in:
parent
dacd080639
commit
b0d3c3a674
2 changed files with 8 additions and 5 deletions
10
imgui.cpp
10
imgui.cpp
|
|
@ -4190,7 +4190,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
||||||
DragDropMouseButton = -1;
|
DragDropMouseButton = -1;
|
||||||
DragDropTargetId = 0;
|
DragDropTargetId = 0;
|
||||||
DragDropTargetFullViewport = 0;
|
DragDropTargetFullViewport = 0;
|
||||||
DragDropAcceptFlags = ImGuiDragDropFlags_None;
|
DragDropAcceptFlagsCurr = DragDropAcceptFlagsPrev = ImGuiDragDropFlags_None;
|
||||||
DragDropAcceptIdCurrRectSurface = 0.0f;
|
DragDropAcceptIdCurrRectSurface = 0.0f;
|
||||||
DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
|
DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0;
|
||||||
DragDropAcceptFrameCount = -1;
|
DragDropAcceptFrameCount = -1;
|
||||||
|
|
@ -5528,6 +5528,8 @@ void ImGui::NewFrame()
|
||||||
// Drag and drop
|
// Drag and drop
|
||||||
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
|
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
|
||||||
g.DragDropAcceptIdCurr = 0;
|
g.DragDropAcceptIdCurr = 0;
|
||||||
|
g.DragDropAcceptFlagsPrev = g.DragDropAcceptFlagsCurr;
|
||||||
|
g.DragDropAcceptFlagsCurr = ImGuiDragDropFlags_None;
|
||||||
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
||||||
g.DragDropWithinSource = false;
|
g.DragDropWithinSource = false;
|
||||||
g.DragDropWithinTarget = false;
|
g.DragDropWithinTarget = false;
|
||||||
|
|
@ -14552,7 +14554,7 @@ void ImGui::ClearDragDrop()
|
||||||
IMGUI_DEBUG_LOG_ACTIVEID("[dragdrop] ClearDragDrop()\n");
|
IMGUI_DEBUG_LOG_ACTIVEID("[dragdrop] ClearDragDrop()\n");
|
||||||
g.DragDropActive = false;
|
g.DragDropActive = false;
|
||||||
g.DragDropPayload.Clear();
|
g.DragDropPayload.Clear();
|
||||||
g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
|
g.DragDropAcceptFlagsCurr = ImGuiDragDropFlags_None;
|
||||||
g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
|
g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
|
||||||
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
||||||
g.DragDropAcceptFrameCount = -1;
|
g.DragDropAcceptFrameCount = -1;
|
||||||
|
|
@ -14681,7 +14683,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
||||||
// Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
|
// Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
|
||||||
// We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
|
// We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
|
||||||
bool ret;
|
bool ret;
|
||||||
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlagsPrev & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
||||||
ret = BeginTooltipHidden();
|
ret = BeginTooltipHidden();
|
||||||
else
|
else
|
||||||
ret = BeginTooltip();
|
ret = BeginTooltip();
|
||||||
|
|
@ -14862,7 +14864,7 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
||||||
if (r_surface > g.DragDropAcceptIdCurrRectSurface)
|
if (r_surface > g.DragDropAcceptIdCurrRectSurface)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
g.DragDropAcceptFlags = flags;
|
g.DragDropAcceptFlagsCurr = flags;
|
||||||
g.DragDropAcceptIdCurr = g.DragDropTargetId;
|
g.DragDropAcceptIdCurr = g.DragDropTargetId;
|
||||||
g.DragDropAcceptIdCurrRectSurface = r_surface;
|
g.DragDropAcceptIdCurrRectSurface = r_surface;
|
||||||
//IMGUI_DEBUG_LOG("AcceptDragDropPayload(): %08X: accept\n", g.DragDropTargetId);
|
//IMGUI_DEBUG_LOG("AcceptDragDropPayload(): %08X: accept\n", g.DragDropTargetId);
|
||||||
|
|
|
||||||
|
|
@ -2380,7 +2380,8 @@ struct ImGuiContext
|
||||||
ImRect DragDropTargetClipRect; // Store ClipRect at the time of item's drawing
|
ImRect DragDropTargetClipRect; // Store ClipRect at the time of item's drawing
|
||||||
ImGuiID DragDropTargetId;
|
ImGuiID DragDropTargetId;
|
||||||
ImGuiID DragDropTargetFullViewport;
|
ImGuiID DragDropTargetFullViewport;
|
||||||
ImGuiDragDropFlags DragDropAcceptFlags;
|
ImGuiDragDropFlags DragDropAcceptFlagsCurr;
|
||||||
|
ImGuiDragDropFlags DragDropAcceptFlagsPrev;
|
||||||
float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
|
float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface)
|
||||||
ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
|
ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload)
|
||||||
ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
|
ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue