From 91fbb5c95706ee163fb4a4b0c6e8cf633712009c Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 30 Aug 2022 10:28:56 -0700 Subject: [PATCH] Don't prevent immediate actions while router active Immediate actions that can take place are useful. We should only be preventing immediate actions while actively routing or dragging Fixes https://gitlab.com/kicad/code/kicad/issues/12311 --- common/tool/tool_event.cpp | 7 +++++++ include/tool/tool_event.h | 7 +++++++ pcbnew/router/router_tool.cpp | 2 +- pcbnew/tools/edit_tool.cpp | 10 ++++++++-- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index 0448d1942c..26d13cbd61 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -241,6 +241,13 @@ bool TOOL_EVENT::IsMoveTool() const } +bool TOOL_EVENT::IsEditorTool() const +{ + return ( m_commandStr + && m_commandStr.value().find( "InteractiveEdit" ) != GetCommandStr()->npos ); +} + + bool TOOL_EVENT::IsSimulator() const { return ( m_commandStr && m_commandStr.value().find( "Simulation" ) != GetCommandStr()->npos ); diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index 88c105a40b..4491a7101d 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -421,6 +421,13 @@ public: */ bool IsMoveTool() const; + /** + * Indicate if the event is asking for an editor tool. + * + * Used to allow deleting an element without de-activating the current tool. + */ + bool IsEditorTool() const; + /** * Indicate if the event is from the simulator. */ diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 442e5568a7..5721f53256 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1522,7 +1522,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) } else if( evt->IsActivate() ) { - if( evt->IsMoveTool() ) + if( evt->IsMoveTool() || evt->IsEditorTool() ) { // leave ourselves on the stack so we come back after the move break; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index aa1276677f..9cb7679dcc 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -264,12 +264,11 @@ bool EDIT_TOOL::invokeInlineRouter( int aDragMode ) } - bool EDIT_TOOL::isRouterActive() const { ROUTER_TOOL* router = m_toolMgr->GetTool(); - return router && router->IsToolActive(); + return router && router->RoutingInProgress(); } @@ -1377,12 +1376,17 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) { + PCB_BASE_EDIT_FRAME* editFrame = getEditFrame(); + if( isRouterActive() ) { m_toolMgr->RunAction( PCB_ACTIONS::routerUndoLastSegment, true ); return 0; } + std::string tool = aEvent.GetCommandStr().value(); + editFrame->PushTool( tool ); + std::vector lockedItems; Activate(); @@ -1422,6 +1426,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) { wxBell(); canvas()->Refresh(); + editFrame->PopTool( tool ); return 0; } @@ -1617,6 +1622,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) else m_commit->Push( _( "Delete" ) ); + editFrame->PopTool( tool ); return 0; }