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" ), 'G', LEGACY_HK_NAME( "Drag Item" ),
_( "Drag" ), _( "Drags the selected item(s)" ), BITMAPS::move, AF_ACTIVATE ); _( "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", TOOL_ACTION EE_ACTIONS::alignToGrid( "eeschema.AlignToGrid",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Align Elements to Grid" ), "", BITMAPS::move, AF_ACTIVATE ); _( "Align Elements to Grid" ), "", BITMAPS::move, AF_ACTIVATE );

View File

@ -116,8 +116,6 @@ public:
// Interactive Editing // Interactive Editing
static TOOL_ACTION alignToGrid; 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 move;
static TOOL_ACTION drag; static TOOL_ACTION drag;
static TOOL_ACTION repeatDrawItem; 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 // Check if dragging has started within any of selected items bounding box
if( selectionContains( evt->DragOrigin() ) ) if( selectionContains( evt->DragOrigin() ) )
{ {
// Yes -> run the move tool and wait till it finishes if( m_frame->eeconfig()->m_Input.drag_is_move )
if( m_isSymbolEditor ) m_toolMgr->RunSynchronousAction( EE_ACTIONS::move, nullptr );
m_toolMgr->InvokeTool( "eeschema.SymbolMoveTool" );
else else
m_toolMgr->InvokeTool( "eeschema.InteractiveMove" ); m_toolMgr->RunSynchronousAction( EE_ACTIONS::drag, nullptr );
} }
else else
{ {
@ -1141,7 +1140,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
if( line ) if( line )
{ {
dist = DistanceLinePoint( line->GetStartPoint(), line->GetEndPoint(), pos ); dist = KiROUND( DistanceLinePoint( line->GetStartPoint(), line->GetEndPoint(), pos ) );
} }
else if( text ) 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() ); SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() );
if( bbox.Contains( pos ) ) if( bbox.Contains( pos ) )
dist = EuclideanNorm( bbox.GetCenter() - pos ); dist = KiROUND( EuclideanNorm( bbox.GetCenter() - pos ) );
else else
rect.Collide( poss, closestDist, &dist ); rect.Collide( poss, closestDist, &dist );
} }
else else
{ {
dist = EuclideanNorm( bbox.GetCenter() - pos ); dist = KiROUND( EuclideanNorm( bbox.GetCenter() - pos ) );
} }
} }
else else
@ -1413,9 +1412,7 @@ bool EE_SELECTION_TOOL::selectMultiple()
// We changed one line endpoint on a selected line, // We changed one line endpoint on a selected line,
// update the view at least. // update the view at least.
if( flags && !anySubtracted ) if( flags && !anySubtracted )
{
getView()->Update( aItem ); getView()->Update( aItem );
}
} }
else 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; EE_COLLECTOR collector;
@ -1560,7 +1557,6 @@ int EE_SELECTION_TOOL::SelectNode( const TOOL_EVENT& aEvent )
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( false ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( false );
SelectPoint( cursorPos, connectedTypes ); SelectPoint( cursorPos, connectedTypes );
return 0; return 0;
} }
@ -1607,7 +1603,6 @@ int EE_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent )
int EE_SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent ) int EE_SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent )
{ {
ClearSelection(); ClearSelection();
return 0; 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, void EE_SELECTION_TOOL::SyncSelection( const std::optional<SCH_SHEET_PATH>& targetSheetPath,
SCH_ITEM* focusItem, std::vector<SCH_ITEM*> items ) SCH_ITEM* focusItem, const std::vector<SCH_ITEM*>& items )
{ {
SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ); SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
if( !editFrame || m_isSymbolEditor || m_isSymbolViewer ) if( !editFrame )
return 0; return;
if( targetSheetPath && targetSheetPath != editFrame->Schematic().CurrentSheet() ) 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 ) if( m_selection.Size() > 0 )
m_toolMgr->ProcessEvent( EVENTS::SelectedEvent ); 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. * @param aPosition Cursor position from which the search should be made.
* @return a connected item or nullptr. * @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 * 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. ///< Set selection to items passed by parameter.
///< Zooms to fit, if enabled. ///< Zooms to fit, if enabled.
int SyncSelection( std::optional<SCH_SHEET_PATH> targetSheetPath, SCH_ITEM* focusItem, void SyncSelection( const std::optional<SCH_SHEET_PATH>& targetSheetPath, SCH_ITEM* focusItem,
std::vector<SCH_ITEM*> items ); const std::vector<SCH_ITEM*>& items );
protected: protected:
SELECTION& selection() override { return m_selection; } 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 ) int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
{ {
if( aEvent.IsAction( &EE_ACTIONS::move ) ) m_isDrag = aEvent.IsAction( &EE_ACTIONS::drag );
{
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;
}
if( SCH_COMMIT* commit = dynamic_cast<SCH_COMMIT*>( aEvent.Commit() ) ) 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.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
if( evt->IsAction( &EE_ACTIONS::moveActivate ) if( evt->IsAction( &EE_ACTIONS::restartMove )
|| evt->IsAction( &EE_ACTIONS::restartMove )
|| evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::move )
|| evt->IsAction( &EE_ACTIONS::drag ) || evt->IsAction( &EE_ACTIONS::drag )
|| evt->IsMotion() || evt->IsMotion()
@ -1777,7 +1760,6 @@ void SCH_MOVE_TOOL::clearNewDragLines()
void SCH_MOVE_TOOL::setTransitions() 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::move.MakeEvent() );
Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() ); Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() );
Go( &SCH_MOVE_TOOL::AlignElements, EE_ACTIONS::alignToGrid.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 ) if( evt->IsAction( &EE_ACTIONS::move )
|| evt->IsMotion() || evt->IsMotion()
|| evt->IsDrag( BUT_LEFT ) || evt->IsDrag( BUT_LEFT )
|| evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsAction( &ACTIONS::refreshPreview ) )
|| evt->IsAction( &EE_ACTIONS::symbolMoveActivate ) )
{ {
if( !m_moveInProgress ) // Prepare to start moving/dragging 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 ) for( LIB_PIN* pin : pins )
{ {
if( !got_unit[pin->GetUnit()] if( !got_unit[pin->GetUnit()]
&& pin->GetPosition() == cur_pin->GetPosition() && pin->GetPosition() == cur_pin->GetPosition()
&& pin->GetOrientation() == cur_pin->GetOrientation() && pin->GetOrientation() == cur_pin->GetOrientation()
&& pin->GetConvert() == cur_pin->GetConvert() && pin->GetConvert() == cur_pin->GetConvert()
&& pin->GetType() == cur_pin->GetType() && pin->GetType() == cur_pin->GetType()
&& pin->GetName() == cur_pin->GetName() ) && pin->GetName() == cur_pin->GetName() )
{ {
if( sync_pins.insert( pin ).second ) if( sync_pins.insert( pin ).second )
got_unit[pin->GetUnit()] = true; 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() void SYMBOL_EDITOR_MOVE_TOOL::setTransitions()
{ {
Go( &SYMBOL_EDITOR_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() ); Go( &SYMBOL_EDITOR_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
Go( &SYMBOL_EDITOR_MOVE_TOOL::Main, EE_ACTIONS::symbolMoveActivate.MakeEvent() );
} }