@ -12171,12 +12171,13 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
const bool was_accepted_previously = ( g . DragDropAcceptIdPrev = = g . DragDropTargetId ) ;
const bool was_accepted_previously = ( g . DragDropAcceptIdPrev = = g . DragDropTargetId ) ;
ImRect r = g . DragDropTargetRect ;
ImRect r = g . DragDropTargetRect ;
float r_surface = r . GetWidth ( ) * r . GetHeight ( ) ;
float r_surface = r . GetWidth ( ) * r . GetHeight ( ) ;
if ( r_surface < = g . DragDropAcceptIdCurrRectSurface )
if ( r_surface > g . DragDropAcceptIdCurrRectSurface )
{
return NULL ;
g . DragDropAcceptFlags = flags ;
g . DragDropAcceptIdCurr = g . DragDropTargetId ;
g . DragDropAcceptFlags = flags ;
g . DragDropAcceptIdCurrRectSurface = r_surface ;
g . DragDropAcceptIdCurr = g . DragDropTargetId ;
}
g . DragDropAcceptIdCurrRectSurface = r_surface ;
//IMGUI_DEBUG_LOG("AcceptDragDropPayload(): %08X: accept\n", g.DragDropTargetId);
// Render default drop visuals
// Render default drop visuals
payload . Preview = was_accepted_previously ;
payload . Preview = was_accepted_previously ;
@ -12185,10 +12186,11 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
window - > DrawList - > AddRect ( r . Min - ImVec2 ( 3.5f , 3.5f ) , r . Max + ImVec2 ( 3.5f , 3.5f ) , GetColorU32 ( ImGuiCol_DragDropTarget ) , 0.0f , 0 , 2.0f ) ;
window - > DrawList - > AddRect ( r . Min - ImVec2 ( 3.5f , 3.5f ) , r . Max + ImVec2 ( 3.5f , 3.5f ) , GetColorU32 ( ImGuiCol_DragDropTarget ) , 0.0f , 0 , 2.0f ) ;
g . DragDropAcceptFrameCount = g . FrameCount ;
g . DragDropAcceptFrameCount = g . FrameCount ;
payload . Delivery = was_accepted_previously & & ! IsMouseDown ( g . DragDropMouseButton ) ; // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
payload . Delivery = was_accepted_previously & & ! IsMouseDown ( g . DragDropMouseButton ) ; // For extern drag sources affecting OS window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
if ( ! payload . Delivery & & ! ( flags & ImGuiDragDropFlags_AcceptBeforeDelivery ) )
if ( ! payload . Delivery & & ! ( flags & ImGuiDragDropFlags_AcceptBeforeDelivery ) )
return NULL ;
return NULL ;
//IMGUI_DEBUG_LOG("AcceptDragDropPayload(): %08X: return payload\n", g.DragDropTargetId);
return & payload ;
return & payload ;
}
}
@ -12204,13 +12206,16 @@ const ImGuiPayload* ImGui::GetDragDropPayload()
return ( g . DragDropActive & & g . DragDropPayload . DataFrameCount ! = - 1 ) ? & g . DragDropPayload : NULL ;
return ( g . DragDropActive & & g . DragDropPayload . DataFrameCount ! = - 1 ) ? & g . DragDropPayload : NULL ;
}
}
// We don't really use/need this now, but added it for the sake of consistency and because we might need it later.
void ImGui : : EndDragDropTarget ( )
void ImGui : : EndDragDropTarget ( )
{
{
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
IM_ASSERT ( g . DragDropActive ) ;
IM_ASSERT ( g . DragDropActive ) ;
IM_ASSERT ( g . DragDropWithinTarget ) ;
IM_ASSERT ( g . DragDropWithinTarget ) ;
g . DragDropWithinTarget = false ;
g . DragDropWithinTarget = false ;
// Clear drag and drop state payload right after delivery
if ( g . DragDropPayload . Delivery )
ClearDragDrop ( ) ;
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------