We no longer need activate actions with RunSynchronousAction.

This commit is contained in:
Jeff Young 2023-07-15 23:11:24 +01:00
parent 537d6bdb75
commit 5419055acb
6 changed files with 22 additions and 59 deletions

View File

@ -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 );

View File

@ -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;

View File

@ -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,10 +1412,8 @@ 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
{
aItem->SetFlags( flags );
@ -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<SCH_SHEET_PATH> targetSheetPath,
SCH_ITEM* focusItem, std::vector<SCH_ITEM*> items )
void EE_SELECTION_TOOL::SyncSelection( const std::optional<SCH_SHEET_PATH>& targetSheetPath,
SCH_ITEM* focusItem, const std::vector<SCH_ITEM*>& items )
{
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( 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<SCH_SHEET_PATH> targetSheetP
if( m_selection.Size() > 0 )
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent );
return 0;
}

View File

@ -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<SCH_SHEET_PATH> targetSheetPath, SCH_ITEM* focusItem,
std::vector<SCH_ITEM*> items );
void SyncSelection( const std::optional<SCH_SHEET_PATH>& targetSheetPath, SCH_ITEM* focusItem,
const std::vector<SCH_ITEM*>& items );
protected:
SELECTION& selection() override { return m_selection; }

View File

@ -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<EESCHEMA_SETTINGS>();
m_isDrag = !cfg->m_Input.drag_is_move;
}
else
{
return false;
}
m_isDrag = aEvent.IsAction( &EE_ACTIONS::drag );
if( SCH_COMMIT* commit = dynamic_cast<SCH_COMMIT*>( 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() );

View File

@ -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
{
@ -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() );
}