Commit 6a1d3445 authored by Maciej Suminski's avatar Maciej Suminski

Instant dragging (without prior selection).

parent 9783aaf3
......@@ -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;
}
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment