diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index fb99b6979c..976b2a5053 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -1093,14 +1093,6 @@ TOOL_ACTION EE_ACTIONS::drag( "eeschema.InteractiveMove.drag", 'G', LEGACY_HK_NAME( "Drag Item" ), _( "Drag" ), _( "Drags the selected item(s)" ), BITMAPS::move, AF_ACTIVATE ); -TOOL_ACTION EE_ACTIONS::moveActivate( "eeschema.InteractiveMove", - AS_GLOBAL, 0, "", - _( "Move Activate" ), "", BITMAPS::move, AF_ACTIVATE ); - -TOOL_ACTION EE_ACTIONS::symbolMoveActivate( "eeschema.SymbolMoveTool", - AS_GLOBAL, 0, "", - _( "Symbol Move Activate" ), "", BITMAPS::move, AF_ACTIVATE ); - TOOL_ACTION EE_ACTIONS::alignToGrid( "eeschema.AlignToGrid", AS_GLOBAL, 0, "", _( "Align Elements to Grid" ), "", BITMAPS::move, AF_ACTIVATE ); diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 67a2fa06ed..42ccc70179 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -116,8 +116,6 @@ public: // Interactive Editing static TOOL_ACTION alignToGrid; - static TOOL_ACTION symbolMoveActivate; // Symbol editor move tool activate - static TOOL_ACTION moveActivate; // Schematic editor move tool activate static TOOL_ACTION move; static TOOL_ACTION drag; static TOOL_ACTION repeatDrawItem; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index e345ff87dc..0a241c748b 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -546,11 +546,10 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // Check if dragging has started within any of selected items bounding box if( selectionContains( evt->DragOrigin() ) ) { - // Yes -> run the move tool and wait till it finishes - if( m_isSymbolEditor ) - m_toolMgr->InvokeTool( "eeschema.SymbolMoveTool" ); + if( m_frame->eeconfig()->m_Input.drag_is_move ) + m_toolMgr->RunSynchronousAction( EE_ACTIONS::move, nullptr ); else - m_toolMgr->InvokeTool( "eeschema.InteractiveMove" ); + m_toolMgr->RunSynchronousAction( EE_ACTIONS::drag, nullptr ); } else { @@ -1141,7 +1140,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const if( line ) { - dist = DistanceLinePoint( line->GetStartPoint(), line->GetEndPoint(), pos ); + dist = KiROUND( DistanceLinePoint( line->GetStartPoint(), line->GetEndPoint(), pos ) ); } else if( text ) { @@ -1177,13 +1176,13 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() ); if( bbox.Contains( pos ) ) - dist = EuclideanNorm( bbox.GetCenter() - pos ); + dist = KiROUND( EuclideanNorm( bbox.GetCenter() - pos ) ); else rect.Collide( poss, closestDist, &dist ); } else { - dist = EuclideanNorm( bbox.GetCenter() - pos ); + dist = KiROUND( EuclideanNorm( bbox.GetCenter() - pos ) ); } } else @@ -1413,9 +1412,7 @@ bool EE_SELECTION_TOOL::selectMultiple() // We changed one line endpoint on a selected line, // update the view at least. if( flags && !anySubtracted ) - { getView()->Update( aItem ); - } } else { @@ -1533,7 +1530,7 @@ bool EE_SELECTION_TOOL::selectMultiple() } -EDA_ITEM* EE_SELECTION_TOOL::GetNode( VECTOR2I aPosition ) +EDA_ITEM* EE_SELECTION_TOOL::GetNode( const VECTOR2I& aPosition ) { EE_COLLECTOR collector; @@ -1560,7 +1557,6 @@ int EE_SELECTION_TOOL::SelectNode( const TOOL_EVENT& aEvent ) VECTOR2I cursorPos = getViewControls()->GetCursorPosition( false ); SelectPoint( cursorPos, connectedTypes ); - return 0; } @@ -1607,7 +1603,6 @@ int EE_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent ) int EE_SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent ) { ClearSelection(); - return 0; } @@ -1720,13 +1715,13 @@ void EE_SELECTION_TOOL::ZoomFitCrossProbeBBox( const BOX2I& aBBox ) } -int EE_SELECTION_TOOL::SyncSelection( std::optional targetSheetPath, - SCH_ITEM* focusItem, std::vector items ) +void EE_SELECTION_TOOL::SyncSelection( const std::optional& targetSheetPath, + SCH_ITEM* focusItem, const std::vector& items ) { SCH_EDIT_FRAME* editFrame = dynamic_cast( m_frame ); - if( !editFrame || m_isSymbolEditor || m_isSymbolViewer ) - return 0; + if( !editFrame ) + return; if( targetSheetPath && targetSheetPath != editFrame->Schematic().CurrentSheet() ) { @@ -1758,8 +1753,6 @@ int EE_SELECTION_TOOL::SyncSelection( std::optional targetSheetP if( m_selection.Size() > 0 ) m_toolMgr->ProcessEvent( EVENTS::SelectedEvent ); - - return 0; } diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index bc655bc844..bdd5479e6c 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -119,7 +119,7 @@ public: * @param aPosition Cursor position from which the search should be made. * @return a connected item or nullptr. */ - EDA_ITEM* GetNode( VECTOR2I aPosition ); + EDA_ITEM* GetNode( const VECTOR2I& aPosition ); /** * Selects the connected item at the current cursor position. Iterative process with a @@ -176,8 +176,8 @@ public: ///< Set selection to items passed by parameter. ///< Zooms to fit, if enabled. - int SyncSelection( std::optional targetSheetPath, SCH_ITEM* focusItem, - std::vector items ); + void SyncSelection( const std::optional& targetSheetPath, SCH_ITEM* focusItem, + const std::vector& items ); protected: SELECTION& selection() override { return m_selection; } diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 023af824e6..87165380a6 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -355,23 +355,7 @@ void SCH_MOVE_TOOL::orthoLineDrag( SCH_COMMIT* aCommit, SCH_LINE* line, const VE int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) { - if( aEvent.IsAction( &EE_ACTIONS::move ) ) - { - m_isDrag = false; - } - else if( aEvent.IsAction( &EE_ACTIONS::drag ) ) - { - m_isDrag = true; - } - else if( aEvent.IsAction( &EE_ACTIONS::moveActivate ) ) - { - EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); - m_isDrag = !cfg->m_Input.drag_is_move; - } - else - { - return false; - } + m_isDrag = aEvent.IsAction( &EE_ACTIONS::drag ); if( SCH_COMMIT* commit = dynamic_cast( aEvent.Commit() ) ) { @@ -485,8 +469,7 @@ bool SCH_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COMMIT* aComm grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); - if( evt->IsAction( &EE_ACTIONS::moveActivate ) - || evt->IsAction( &EE_ACTIONS::restartMove ) + if( evt->IsAction( &EE_ACTIONS::restartMove ) || evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag ) || evt->IsMotion() @@ -1777,7 +1760,6 @@ void SCH_MOVE_TOOL::clearNewDragLines() void SCH_MOVE_TOOL::setTransitions() { - Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::moveActivate.MakeEvent() ); Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() ); Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() ); Go( &SCH_MOVE_TOOL::AlignElements, EE_ACTIONS::alignToGrid.MakeEvent() ); diff --git a/eeschema/tools/symbol_editor_move_tool.cpp b/eeschema/tools/symbol_editor_move_tool.cpp index d6f5153e14..f76bc29e48 100644 --- a/eeschema/tools/symbol_editor_move_tool.cpp +++ b/eeschema/tools/symbol_editor_move_tool.cpp @@ -159,8 +159,7 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) - || evt->IsAction( &ACTIONS::refreshPreview ) - || evt->IsAction( &EE_ACTIONS::symbolMoveActivate ) ) + || evt->IsAction( &ACTIONS::refreshPreview ) ) { if( !m_moveInProgress ) // Prepare to start moving/dragging { @@ -192,11 +191,11 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM for( LIB_PIN* pin : pins ) { if( !got_unit[pin->GetUnit()] - && pin->GetPosition() == cur_pin->GetPosition() - && pin->GetOrientation() == cur_pin->GetOrientation() - && pin->GetConvert() == cur_pin->GetConvert() - && pin->GetType() == cur_pin->GetType() - && pin->GetName() == cur_pin->GetName() ) + && pin->GetPosition() == cur_pin->GetPosition() + && pin->GetOrientation() == cur_pin->GetOrientation() + && pin->GetConvert() == cur_pin->GetConvert() + && pin->GetType() == cur_pin->GetType() + && pin->GetName() == cur_pin->GetName() ) { if( sync_pins.insert( pin ).second ) got_unit[pin->GetUnit()] = true; @@ -374,5 +373,4 @@ void SYMBOL_EDITOR_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta void SYMBOL_EDITOR_MOVE_TOOL::setTransitions() { Go( &SYMBOL_EDITOR_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() ); - Go( &SYMBOL_EDITOR_MOVE_TOOL::Main, EE_ACTIONS::symbolMoveActivate.MakeEvent() ); }