From b857ba58ca106e09554314139c30c0e6f0b48939 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 18 Mar 2014 16:25:46 +0100 Subject: [PATCH] Instant dragging (without prior selection). --- pcbnew/tools/selection_tool.cpp | 34 +++++++++++++++++++++++++-------- pcbnew/tools/selection_tool.h | 5 ++++- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index de1624ad74..14f430fcca 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -141,10 +141,18 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) { if( m_selection.Empty() || m_additive ) { - // If nothings has been selected or user wants to select more - // draw the selection box - selectMultiple(); + if( !selectSingle( getView()->ToWorld( getViewControls()->GetMousePosition() ), false ) ) + { + // If nothings has been selected or user wants to select more + // draw the selection box + selectMultiple(); + } + else + { + m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" ); + } } + else { // Check if dragging has started within any of selected items bounding box @@ -205,7 +213,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) } -void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) +bool SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere, bool aAllowDisambiguation ) { BOARD* pcb = getModel( PCB_T ); BOARD_ITEM* item; @@ -220,11 +228,13 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) case 0: if( !m_additive ) clearSelection(); - break; + + return false; case 1: toggleSelection( collector[0] ); - break; + + return true; default: // Remove unselectable items @@ -238,17 +248,25 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere ) if( collector.GetCount() == 1 ) { toggleSelection( collector[0] ); + + return true; } - else if( collector.GetCount() > 1 ) + + else if( aAllowDisambiguation && collector.GetCount() > 1 ) { item = disambiguationMenu( &collector ); if( item ) + { toggleSelection( item ); - } + return true; + } + } break; } + + return false; } diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 7072c89655..ca46f8bbdd 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -130,8 +130,11 @@ private: * place, there is a menu displayed that allows to choose the item. * * @param aWhere is the place where the item should be selected. + * @param aAllowDisambiguation decides what to do in case of disambiguation. If true, then + * a menu is shown, otherise function finishes without selecting anything. + * @return True if an item was selected, false otherwise. */ - void selectSingle( const VECTOR2I& aWhere ); + bool selectSingle( const VECTOR2I& aWhere, bool aAllowDisambiguation = true ); /** * Function selectMultiple()