mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Added ImGuiDragDropFlags_AcceptNoPreviewTooltip flag to disable drag source tooltip from the target site (#143)
This commit is contained in:
11
imgui.cpp
11
imgui.cpp
@ -13145,6 +13145,7 @@ void ImGui::ClearDragDrop()
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.DragDropActive = false;
|
||||
g.DragDropPayload.Clear();
|
||||
g.DragDropAcceptFlags = 0;
|
||||
g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
|
||||
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
||||
g.DragDropAcceptFrameCount = -1;
|
||||
@ -13239,6 +13240,15 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
||||
SetNextWindowPos(tooltip_pos);
|
||||
PushStyleColor(ImGuiCol_PopupBg, GetStyleColorVec4(ImGuiCol_PopupBg) * ImVec4(1.0f, 1.0f, 1.0f, 0.6f));
|
||||
BeginTooltip();
|
||||
|
||||
// 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.
|
||||
if (g.DragDropActive && g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
||||
{
|
||||
ImGuiWindow* tooltip_window = g.CurrentWindow;
|
||||
tooltip_window->SkipItems = true;
|
||||
tooltip_window->HiddenFrames = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
|
||||
@ -13379,6 +13389,7 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
||||
float r_surface = r.GetWidth() * r.GetHeight();
|
||||
if (r_surface < g.DragDropAcceptIdCurrRectSurface)
|
||||
{
|
||||
g.DragDropAcceptFlags = flags;
|
||||
g.DragDropAcceptIdCurr = g.DragDropTargetId;
|
||||
g.DragDropAcceptIdCurrRectSurface = r_surface;
|
||||
}
|
||||
|
Reference in New Issue
Block a user