Instant dragging (without prior selection).

This commit is contained in:
Maciej Suminski 2014-03-18 16:25:46 +01:00
parent 9783aaf3e6
commit 6a1d344541
2 changed files with 30 additions and 9 deletions

View File

@ -140,11 +140,19 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
else if( evt->IsDrag( BUT_LEFT ) )
{
if( m_selection.Empty() || m_additive )
{
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<BOARD>( 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;
}

View File

@ -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()