Add cancel to the selection context menu if a tool is running
The selection tool's context menu is displayed during the move tool, so it should contain the ability to cancel the current action.
This commit is contained in:
parent
779ed40588
commit
da6d0c9de6
|
@ -174,10 +174,17 @@ bool EDIT_TOOL::Init()
|
||||||
return frame()->ToolStackIsEmpty();
|
return frame()->ToolStackIsEmpty();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto notMovingCondition =
|
||||||
|
[ this ] ( const SELECTION& aSelection )
|
||||||
|
{
|
||||||
|
return !frame()->IsCurrentTool( PCB_ACTIONS::move )
|
||||||
|
&& !frame()->IsCurrentTool( PCB_ACTIONS::moveWithReference );
|
||||||
|
};
|
||||||
|
|
||||||
// Add context menu entries that are displayed when selection tool is active
|
// Add context menu entries that are displayed when selection tool is active
|
||||||
CONDITIONAL_MENU& menu = m_selectionTool->GetToolMenu().GetMenu();
|
CONDITIONAL_MENU& menu = m_selectionTool->GetToolMenu().GetMenu();
|
||||||
|
|
||||||
menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( PCB_ACTIONS::move, SELECTION_CONDITIONS::NotEmpty && notMovingCondition );
|
||||||
menu.AddItem( PCB_ACTIONS::inlineBreakTrack, SELECTION_CONDITIONS::Count( 1 )
|
menu.AddItem( PCB_ACTIONS::inlineBreakTrack, SELECTION_CONDITIONS::Count( 1 )
|
||||||
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
&& SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||||
menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
menu.AddItem( PCB_ACTIONS::drag45Degree, SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||||
|
@ -213,21 +220,6 @@ bool EDIT_TOOL::Init()
|
||||||
menu.AddItem( PCB_ACTIONS::updateFootprint, singleModuleCondition );
|
menu.AddItem( PCB_ACTIONS::updateFootprint, singleModuleCondition );
|
||||||
menu.AddItem( PCB_ACTIONS::changeFootprint, singleModuleCondition );
|
menu.AddItem( PCB_ACTIONS::changeFootprint, singleModuleCondition );
|
||||||
|
|
||||||
// Populate the context menu displayed during the edit tool (primarily the measure tool)
|
|
||||||
auto activeToolCondition = [ this ] ( const SELECTION& aSel ) {
|
|
||||||
return !frame()->ToolStackIsEmpty();
|
|
||||||
};
|
|
||||||
|
|
||||||
auto frame = getEditFrame<PCB_BASE_FRAME>();
|
|
||||||
auto& ctxMenu = m_menu.GetMenu();
|
|
||||||
|
|
||||||
// "Cancel" goes at the top of the context menu when a tool is active
|
|
||||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
|
|
||||||
ctxMenu.AddSeparator( 1 );
|
|
||||||
|
|
||||||
if( frame )
|
|
||||||
frame->AddStandardSubMenus( m_menu );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,9 +157,19 @@ bool SELECTION_TOOL::Init()
|
||||||
|
|
||||||
auto& menu = m_menu.GetMenu();
|
auto& menu = m_menu.GetMenu();
|
||||||
|
|
||||||
|
auto activeToolCondition =
|
||||||
|
[ frame ] ( const SELECTION& aSel )
|
||||||
|
{
|
||||||
|
return !frame->ToolStackIsEmpty();
|
||||||
|
};
|
||||||
|
|
||||||
menu.AddMenu( selectMenu.get(), SELECTION_CONDITIONS::NotEmpty );
|
menu.AddMenu( selectMenu.get(), SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddSeparator( 1000 );
|
menu.AddSeparator( 1000 );
|
||||||
|
|
||||||
|
// "Cancel" goes at the top of the context menu when a tool is active
|
||||||
|
menu.AddItem( ACTIONS::cancelInteractive, activeToolCondition, 1 );
|
||||||
|
menu.AddSeparator( 1 );
|
||||||
|
|
||||||
if( frame )
|
if( frame )
|
||||||
frame->AddStandardSubMenus( m_menu );
|
frame->AddStandardSubMenus( m_menu );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue