@ -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 ;
if ( ! g . DragDropActive )
{
IM_ASSERT ( source_id ! = 0 ) ;
ClearDragDrop ( ) ;
ImGuiPayload & payload = g . DragDropPayload ;
payload . SourceId = source_id ;
payload . SourceParentId = source_parent_id ;
g . DragDropActive = true ;
g . DragDropSourceFlags = flags ;
g . DragDropMouseButton = mouse_button ;
if ( payload . SourceId = = g . ActiveId )
g . ActiveIdNoClearOnFocusLoss = true ;
}
g . DragDropSourceFrameCount = g . FrameCount ;
g . DragDropWithinSource = true ;
if ( ! ( flags & ImGuiDragDropFlags_SourceNoPreviewTooltip ) )
// Activate drag and drop
{
if ( ! g . DragDropActive )
// 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.
IM_ASSERT ( source_id ! = 0 ) ;
bool ret ;
ClearDragDrop ( ) ;
if ( g . DragDropAcceptIdPrev & & ( g . DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip ) )
IMGUI_DEBUG_LOG_ACTIVEID ( " [dragdrop] BeginDragDropSource() DragDropActive = true, source_id = %08X \n " , source_id ) ;
ret = BeginTooltipHidden ( ) ;
ImGuiPayload & payload = g . DragDropPayload ;
else
payload . SourceId = source_id ;
ret = BeginTooltip ( ) ;
payload . SourceParentId = source_parent_id ;
IM_ASSERT ( ret ) ; // FIXME-NEWBEGIN: If this ever becomes false, we need to Begin("##Hidden", NULL, ImGuiWindowFlags_NoSavedSettings) + SetWindowHiddendAndSkipItemsForCurrentFrame().
g . DragDropActive = true ;
IM_UNUSED ( ret ) ;
g . DragDropSourceFlags = flags ;
}
g . DragDropMouseButton = mouse_button ;
if ( payload . SourceId = = g . ActiveId )
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 ) )
if ( ! ( flags & ImGuiDragDropFlags_SourceNoDisableHover ) & & ! ( flags & ImGuiDragDropFlags_SourceExtern ) )
g . LastItemData . StatusFlags & = ~ ImGuiItemStatusFlags_HoveredRect ;
g . LastItemData . StatusFlags & = ~ ImGuiItemStatusFlags_HoveredRect ;
return true ;
return true ;
}
return false ;
}
}
void ImGui : : EndDragDropSource ( )
void ImGui : : EndDragDropSource ( )