mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-22 05:09:56 +01:00
Drag and Drop: tweaked BeginDragDropSource() to remove indent. Added debug log.
This commit is contained in:
parent
661c388515
commit
97a1111b94
75
imgui.cpp
75
imgui.cpp
@ -13096,6 +13096,8 @@ bool ImGui::IsDragDropActive()
|
|||||||
void ImGui::ClearDragDrop()
|
void ImGui::ClearDragDrop()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
if (g.DragDropActive)
|
||||||
|
IMGUI_DEBUG_LOG_ACTIVEID("[dragdrop] ClearDragDrop()\n");
|
||||||
g.DragDropActive = false;
|
g.DragDropActive = false;
|
||||||
g.DragDropPayload.Clear();
|
g.DragDropPayload.Clear();
|
||||||
g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
|
g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
|
||||||
@ -13134,7 +13136,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||||||
bool source_drag_active = false;
|
bool source_drag_active = false;
|
||||||
ImGuiID source_id = 0;
|
ImGuiID source_id = 0;
|
||||||
ImGuiID source_parent_id = 0;
|
ImGuiID source_parent_id = 0;
|
||||||
if (!(flags & ImGuiDragDropFlags_SourceExtern))
|
if ((flags & ImGuiDragDropFlags_SourceExtern) == 0)
|
||||||
{
|
{
|
||||||
source_id = g.LastItemData.ID;
|
source_id = g.LastItemData.ID;
|
||||||
if (source_id != 0)
|
if (source_id != 0)
|
||||||
@ -13196,43 +13198,44 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IM_ASSERT(g.DragDropWithinTarget == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
|
IM_ASSERT(g.DragDropWithinTarget == false); // Can't nest BeginDragDropSource() and BeginDragDropTarget()
|
||||||
if (source_drag_active)
|
if (!source_drag_active)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Activate drag and drop
|
||||||
|
if (!g.DragDropActive)
|
||||||
{
|
{
|
||||||
if (!g.DragDropActive)
|
IM_ASSERT(source_id != 0);
|
||||||
{
|
ClearDragDrop();
|
||||||
IM_ASSERT(source_id != 0);
|
IMGUI_DEBUG_LOG_ACTIVEID("[dragdrop] BeginDragDropSource() DragDropActive = true, source_id = %08X\n", source_id);
|
||||||
ClearDragDrop();
|
ImGuiPayload& payload = g.DragDropPayload;
|
||||||
ImGuiPayload& payload = g.DragDropPayload;
|
payload.SourceId = source_id;
|
||||||
payload.SourceId = source_id;
|
payload.SourceParentId = source_parent_id;
|
||||||
payload.SourceParentId = source_parent_id;
|
g.DragDropActive = true;
|
||||||
g.DragDropActive = true;
|
g.DragDropSourceFlags = flags;
|
||||||
g.DragDropSourceFlags = flags;
|
g.DragDropMouseButton = mouse_button;
|
||||||
g.DragDropMouseButton = mouse_button;
|
if (payload.SourceId == g.ActiveId)
|
||||||
if (payload.SourceId == g.ActiveId)
|
g.ActiveIdNoClearOnFocusLoss = true;
|
||||||
g.ActiveIdNoClearOnFocusLoss = true;
|
|
||||||
}
|
|
||||||
g.DragDropSourceFrameCount = g.FrameCount;
|
|
||||||
g.DragDropWithinSource = true;
|
|
||||||
|
|
||||||
if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
|
|
||||||
{
|
|
||||||
// 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.
|
|
||||||
bool ret;
|
|
||||||
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
|
||||||
ret = BeginTooltipHidden();
|
|
||||||
else
|
|
||||||
ret = BeginTooltip();
|
|
||||||
IM_ASSERT(ret); // FIXME-NEWBEGIN: If this ever becomes false, we need to Begin("##Hidden", NULL, ImGuiWindowFlags_NoSavedSettings) + SetWindowHiddendAndSkipItemsForCurrentFrame().
|
|
||||||
IM_UNUSED(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
|
|
||||||
g.LastItemData.StatusFlags &= ~ImGuiItemStatusFlags_HoveredRect;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
g.DragDropSourceFrameCount = g.FrameCount;
|
||||||
|
g.DragDropWithinSource = true;
|
||||||
|
|
||||||
|
if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
|
||||||
|
{
|
||||||
|
// 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.
|
||||||
|
bool ret;
|
||||||
|
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
|
||||||
|
ret = BeginTooltipHidden();
|
||||||
|
else
|
||||||
|
ret = BeginTooltip();
|
||||||
|
IM_ASSERT(ret); // FIXME-NEWBEGIN: If this ever becomes false, we need to Begin("##Hidden", NULL, ImGuiWindowFlags_NoSavedSettings) + SetWindowHiddendAndSkipItemsForCurrentFrame().
|
||||||
|
IM_UNUSED(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
|
||||||
|
g.LastItemData.StatusFlags &= ~ImGuiItemStatusFlags_HoveredRect;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::EndDragDropSource()
|
void ImGui::EndDragDropSource()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user