Use common actions where possible.

This commit is contained in:
Jeff Young 2019-07-04 20:56:52 +01:00
parent 29df4f809e
commit bcd48d4bc2
4 changed files with 10 additions and 22 deletions

View File

@ -151,14 +151,14 @@ bool EDIT_TOOL::Init()
menu.AddItem( PCB_ACTIONS::rotateCcw, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::rotateCw, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::remove, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( ACTIONS::doDelete, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::properties, SELECTION_CONDITIONS::Count( 1 )
|| SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
menu.AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( ACTIONS::duplicate, SELECTION_CONDITIONS::NotEmpty );
menu.AddItem( PCB_ACTIONS::createArray, SELECTION_CONDITIONS::NotEmpty );
@ -427,12 +427,12 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
// Dispatch TOOL_ACTIONs
else if( evt->Category() == TC_COMMAND )
{
if( evt->IsAction( &PCB_ACTIONS::remove ) )
if( evt->IsAction( &ACTIONS::doDelete ) )
{
// exit the loop, as there is no further processing for removed items
break;
}
else if( evt->IsAction( &PCB_ACTIONS::duplicate ) )
else if( evt->IsAction( &ACTIONS::duplicate ) )
{
// On duplicate, stop moving this item
// The duplicate tool should then select the new item and start
@ -1374,11 +1374,11 @@ void EDIT_TOOL::setTransitions()
Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCw.MakeEvent() );
Go( &EDIT_TOOL::Rotate, PCB_ACTIONS::rotateCcw.MakeEvent() );
Go( &EDIT_TOOL::Flip, PCB_ACTIONS::flip.MakeEvent() );
Go( &EDIT_TOOL::Remove, PCB_ACTIONS::remove.MakeEvent() );
Go( &EDIT_TOOL::Remove, ACTIONS::doDelete.MakeEvent() );
Go( &EDIT_TOOL::Remove, PCB_ACTIONS::deleteFull.MakeEvent() );
Go( &EDIT_TOOL::Properties, PCB_ACTIONS::properties.MakeEvent() );
Go( &EDIT_TOOL::MoveExact, PCB_ACTIONS::moveExact.MakeEvent() );
Go( &EDIT_TOOL::Duplicate, PCB_ACTIONS::duplicate.MakeEvent() );
Go( &EDIT_TOOL::Duplicate, ACTIONS::duplicate.MakeEvent() );
Go( &EDIT_TOOL::Duplicate, PCB_ACTIONS::duplicateIncrement.MakeEvent() );
Go( &EDIT_TOOL::CreateArray, PCB_ACTIONS::createArray.MakeEvent() );
Go( &EDIT_TOOL::Mirror, PCB_ACTIONS::mirror.MakeEvent() );

View File

@ -157,8 +157,8 @@ bool PAD_TOOL::Init()
if( selTool )
{
auto& toolMenu = selTool->GetToolMenu();
auto& menu = toolMenu.GetMenu();
TOOL_MENU& toolMenu = selTool->GetToolMenu();
CONDITIONAL_MENU& menu = toolMenu.GetMenu();
toolMenu.AddSubMenu( ctxMenu );

View File

@ -191,16 +191,10 @@ TOOL_ACTION PCB_ACTIONS::move( "pcbnew.InteractiveMove.move",
_( "Move" ), _( "Moves the selected item(s)" ),
move_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::duplicate( "pcbnew.InteractiveEdit.duplicate",
AS_GLOBAL,
MD_CTRL + 'D', LEGACY_HK_NAME( "Duplicate Item" ),
_( "Duplicate" ), _( "Duplicates the selected item(s)" ),
duplicate_xpm );
TOOL_ACTION PCB_ACTIONS::duplicateIncrement( "pcbnew.InteractiveEdit.duplicateIncrementPads",
AS_GLOBAL,
MD_SHIFT + MD_CTRL + 'D', LEGACY_HK_NAME( "Duplicate Item and Increment" ),
_( "Duplicate" ), _( "Duplicates the selected item(s), incrementing pad numbers" ),
_( "Duplicate and Increment" ), _( "Duplicates the selected item(s), incrementing pad numbers" ),
duplicate_xpm );
TOOL_ACTION PCB_ACTIONS::moveExact( "pcbnew.InteractiveEdit.moveExact",
@ -239,12 +233,6 @@ TOOL_ACTION PCB_ACTIONS::mirror( "pcbnew.InteractiveEdit.mirror",
_( "Mirror" ), _( "Mirrors selected item" ),
mirror_h_xpm );
TOOL_ACTION PCB_ACTIONS::remove( "pcbnew.InteractiveEdit.remove",
AS_GLOBAL,
WXK_BACK, "",
_( "Delete" ), _( "Deletes selected item(s)" ),
delete_xpm, AF_NONE, (void*) REMOVE_FLAGS::NORMAL );
TOOL_ACTION PCB_ACTIONS::deleteFull( "pcbnew.InteractiveEdit.deleteFull",
AS_GLOBAL,
WXK_DELETE, LEGACY_HK_NAME( "Delete Full Track" ),

View File

@ -509,7 +509,7 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
selectionTool->UnbrightenItem( m_pickerItem );
selectionTool->AddItemToSel( m_pickerItem, true );
m_toolMgr->RunAction( PCB_ACTIONS::remove, true );
m_toolMgr->RunAction( ACTIONS::doDelete, true );
m_pickerItem = nullptr;
}