From a6e595dbda6590c5d46c7c51dab3b9f9ff476b2d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 20 Dec 2020 10:41:02 -0500 Subject: [PATCH] Don't start dragging unselected zones from their filled areas Fixes https://gitlab.com/kicad/code/kicad/-/issues/6795 --- pcbnew/tools/pcb_selection_tool.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 8ced8d609b..f7a27d3495 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -346,9 +346,34 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) } else { + // Don't allow starting a drag from a zone filled area that isn't already selected + auto zoneFilledAreaFilter = + []( const VECTOR2I& aWhere, GENERAL_COLLECTOR& aCollector, + PCB_SELECTION_TOOL* aTool ) + { + wxPoint location = wxPoint( aWhere ); + int accuracy = KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() ); + std::set remove; + + for( EDA_ITEM* item : aCollector ) + { + if( item->Type() == PCB_ZONE_T ) + { + ZONE* zone = static_cast( item ); + + if( !zone->HitTestForCorner( location, accuracy * 2 ) && + !zone->HitTestForEdge( location, accuracy ) ) + remove.insert( zone ); + } + } + + for( EDA_ITEM* item : remove ) + aCollector.Remove( item ); + }; + // Selection is empty? try to start dragging the item under the point where drag // started - if( m_selection.Empty() && selectCursor() ) + if( m_selection.Empty() && selectCursor( false, zoneFilledAreaFilter ) ) m_selection.SetIsHover( true ); // Check if dragging has started within any of selected items bounding box.