From db90e97d0beaeeb5f04b4e407d78108a897f1133 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 27 May 2019 13:18:55 +0100 Subject: [PATCH] fixup! Implement undo for Page Settings in PlEditor, Eeschema and PCBNew. --- eeschema/tools/lib_edit_tool.cpp | 20 ++++++++----------- eeschema/tools/lib_move_tool.cpp | 2 +- pagelayout_editor/tools/pl_editor_control.cpp | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/eeschema/tools/lib_edit_tool.cpp b/eeschema/tools/lib_edit_tool.cpp index 043961018d..e4f51e854d 100644 --- a/eeschema/tools/lib_edit_tool.cpp +++ b/eeschema/tools/lib_edit_tool.cpp @@ -628,9 +628,7 @@ int LIB_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent ) if( !selection.Empty() ) { - LIB_ITEM* item = (LIB_ITEM*) selection.GetTopLeftItem(); - - selection.SetReferencePoint( wxPoint( item->GetPosition().x, -item->GetPosition().y ) ); + selection.SetReferencePoint( getViewControls()->GetCursorPosition( true ) ); m_toolMgr->RunAction( EE_ACTIONS::move, false ); } @@ -672,9 +670,7 @@ int LIB_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) if( !selection.Empty() ) { - LIB_ITEM* item = (LIB_ITEM*) selection.GetTopLeftItem(); - - selection.SetReferencePoint( wxPoint( item->GetPosition().x, -item->GetPosition().y ) ); + selection.SetReferencePoint( mapCoords( getViewControls()->GetCursorPosition( true ) ) ); m_toolMgr->RunAction( EE_ACTIONS::move, false ); } @@ -684,7 +680,13 @@ int LIB_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) void LIB_EDIT_TOOL::setTransitions() { + Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() ); + Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() ); + Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() ); + Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() ); + Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() ); Go( &LIB_EDIT_TOOL::Duplicate, ACTIONS::duplicate.MakeEvent() ); + Go( &LIB_EDIT_TOOL::Rotate, EE_ACTIONS::rotateCW.MakeEvent() ); Go( &LIB_EDIT_TOOL::Rotate, EE_ACTIONS::rotateCCW.MakeEvent() ); Go( &LIB_EDIT_TOOL::Mirror, EE_ACTIONS::mirrorX.MakeEvent() ); @@ -695,10 +697,4 @@ void LIB_EDIT_TOOL::setTransitions() Go( &LIB_EDIT_TOOL::Properties, EE_ACTIONS::properties.MakeEvent() ); Go( &LIB_EDIT_TOOL::Properties, EE_ACTIONS::symbolProperties.MakeEvent() ); Go( &LIB_EDIT_TOOL::PinTable, EE_ACTIONS::pinTable.MakeEvent() ); - - Go( &LIB_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() ); - Go( &LIB_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() ); - Go( &LIB_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() ); - Go( &LIB_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() ); - Go( &LIB_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() ); } diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index fd69f6beb5..eed35f41ce 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -143,7 +143,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) if( selection.HasReferencePoint() ) { - VECTOR2I delta = m_cursor - selection.GetReferencePoint(); + VECTOR2I delta = m_cursor - mapCoords( selection.GetReferencePoint() ); // Drag items to the current cursor position for( EDA_ITEM* item : selection ) diff --git a/pagelayout_editor/tools/pl_editor_control.cpp b/pagelayout_editor/tools/pl_editor_control.cpp index 5345116420..69e6821afe 100644 --- a/pagelayout_editor/tools/pl_editor_control.cpp +++ b/pagelayout_editor/tools/pl_editor_control.cpp @@ -34,7 +34,7 @@ #include #include #include - +#include TOOL_ACTION PL_ACTIONS::refreshPreview( "plEditor.EditorControl.refreshPreview", AS_GLOBAL, 0, "", "" );