From 0f4bdbd1848e2bea196718b37dac7b805bf22103 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 16 Jun 2019 01:06:43 +0100 Subject: [PATCH] Tighten down the POINT_EDITORs a bit more. --- eeschema/tools/ee_point_editor.cpp | 5 ++-- pagelayout_editor/tools/pl_point_editor.cpp | 28 ++++++++++++--------- pcbnew/tools/point_editor.cpp | 25 ++++-------------- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 36db8cfc81..8b18a17ad3 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -310,8 +310,6 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent ) { controls->SetAutoPan( false ); inDrag = false; - - m_toolMgr->PassEvent(); } else if( evt->IsCancel() ) @@ -322,6 +320,9 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent ) modified = false; } + // ESC should clear selection along with edit points + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + break; } diff --git a/pagelayout_editor/tools/pl_point_editor.cpp b/pagelayout_editor/tools/pl_point_editor.cpp index 6fb0b68292..c2b32e6475 100644 --- a/pagelayout_editor/tools/pl_point_editor.cpp +++ b/pagelayout_editor/tools/pl_point_editor.cpp @@ -180,18 +180,8 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { - if( !m_editPoints || evt->IsCancel() || TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) ) - { - if( inDrag ) // Restore the last change - { - m_frame->PopTool(); - m_frame->RollbackFromUndo(); - inDrag = false; - modified = false; - } - + if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) ) break; - } if ( !inDrag ) updateEditedPoint( *evt ); @@ -218,8 +208,22 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent ) controls->SetAutoPan( false ); m_frame->PopTool(); inDrag = false; + } - m_toolMgr->PassEvent(); + else if( evt->IsCancel() ) + { + if( inDrag ) // Restore the last change + { + m_frame->PopTool(); + m_frame->RollbackFromUndo(); + inDrag = false; + modified = false; + } + + // ESC should clear selection along with edit points + m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true ); + + break; } else diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index de9aecf7fd..69ec0984b2 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -330,7 +330,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) setEditedPoint( nullptr ); m_refill = false; bool modified = false; - bool revert = false; BOARD_COMMIT commit( editFrame ); LSET snapLayers = item->GetLayerSet(); @@ -341,20 +340,12 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { - if( revert ) - break; - grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); controls->SetSnapping( !evt->Modifier( MD_ALT ) ); - if( !m_editPoints || - evt->Matches( EVENTS::ClearedEvent ) || - evt->Matches( EVENTS::UnselectedEvent ) || - evt->Matches( EVENTS::SelectedEvent ) ) - { + if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) ) break; - } if ( !modified ) updateEditedPoint( *evt ); @@ -403,20 +394,17 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) modified = false; m_refill = true; } - - m_toolMgr->PassEvent(); } else if( evt->IsCancel() ) { if( modified ) // Restore the last change - revert = true; + commit.Revert(); - // Let the selection tool receive the event too - m_toolMgr->PassEvent(); + // ESC should clear selection along with edit points + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - // Do not exit right now, let the selection clear the selection - //break; + break; } else @@ -429,9 +417,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) { view->Remove( m_editPoints.get() ); - if( modified && revert ) - commit.Revert(); - finishItem(); m_editPoints.reset(); }