Promote pad renumberer to a proper tool.
This gives it a context menu with a Cancel item. Commit also includes a couple of fixes to the Pads submenu.
This commit is contained in:
parent
93999f7af6
commit
29b28de317
|
@ -156,12 +156,11 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
int padNumber = settingsDlg.GetStartNumber();
|
||||
wxString padPrefix = settingsDlg.GetPrefix();
|
||||
|
||||
frame()->DisplayToolMsg( _(
|
||||
"Hold left mouse button and move cursor over pads to enumerate them" ) );
|
||||
frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_HAND,
|
||||
_( "Click on successive pads to renumber them" ) );
|
||||
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
getViewControls()->ShowCursor( true );
|
||||
frame()->GetGalCanvas()->SetCursor( wxCURSOR_HAND );
|
||||
|
||||
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||
VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
|
||||
|
@ -244,16 +243,22 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
|
||||
evt->IsDblClick( BUT_LEFT ) )
|
||||
{
|
||||
commit.Push( _( "Enumerate pads" ) );
|
||||
commit.Push( _( "Renumber pads" ) );
|
||||
break;
|
||||
}
|
||||
|
||||
else if( evt->IsCancel() || evt->IsActivate() )
|
||||
else if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||
{
|
||||
commit.Revert();
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Delegate BUT_RIGHT, etc. to SELECTION_TOOL
|
||||
m_toolMgr->PassEvent();
|
||||
}
|
||||
|
||||
// Prepare the next loop by updating the old cursor mouse position
|
||||
// to this last mouse cursor position
|
||||
oldCursorPos = getViewControls()->GetCursorPosition();
|
||||
|
@ -265,7 +270,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
view->Update( p );
|
||||
}
|
||||
|
||||
frame()->DisplayToolMsg( wxEmptyString );
|
||||
frame()->SetNoToolSelected();
|
||||
frame()->GetGalCanvas()->SetCursor( wxCURSOR_ARROW );
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -185,9 +185,11 @@ bool PAD_TOOL::Init()
|
|||
|
||||
toolMenu.AddSubMenu( contextMenu );
|
||||
|
||||
SELECTION_CONDITION canShowMenuCond = [this, contextMenu] ( const SELECTION& aSel ) {
|
||||
auto canShowMenuCond = [this, contextMenu] ( const SELECTION& aSel ) {
|
||||
contextMenu->UpdateAll();
|
||||
return haveFootprints() && contextMenu->HasEnabledItems();
|
||||
return frame()->GetToolId() == ID_NO_TOOL_SELECTED
|
||||
&& haveFootprints()
|
||||
&& contextMenu->HasEnabledItems();
|
||||
};
|
||||
|
||||
// show menu when there is a footprint, and the menu has any items
|
||||
|
@ -196,6 +198,10 @@ bool PAD_TOOL::Init()
|
|||
|| SELECTION_CONDITIONS::Count( 0 ) );
|
||||
|
||||
menu.AddMenu( contextMenu.get(), false, showCond, 1000 );
|
||||
|
||||
// we need a separator only when the selection is empty
|
||||
auto separatorCond = canShowMenuCond && SELECTION_CONDITIONS::Count( 0 );
|
||||
menu.AddSeparator( separatorCond, 1000 );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue