Beware of copying events and losing the m_passEvent flag.

Fixes: lp:1833031
* https://bugs.launchpad.net/kicad/+bug/1833031
This commit is contained in:
Jeff Young 2019-06-17 14:43:22 +01:00
parent 666705c1f8
commit 1f35ec5521
31 changed files with 113 additions and 155 deletions

View File

@ -54,7 +54,7 @@ void TOOL_INTERACTIVE::Activate()
}
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait( const TOOL_EVENT_LIST& aEventList )
TOOL_EVENT* TOOL_INTERACTIVE::Wait( const TOOL_EVENT_LIST& aEventList )
{
return m_toolMgr->ScheduleWait( this, aEventList );
}

View File

@ -470,9 +470,9 @@ int TOOL_MANAGER::GetPriority( int aToolId ) const
{
int priority = 0;
for( auto it = m_activeTools.begin(), itEnd = m_activeTools.end(); it != itEnd; ++it )
for( TOOL_ID tool : m_activeTools )
{
if( *it == aToolId )
if( tool == aToolId )
return priority;
++priority;
@ -505,7 +505,7 @@ void TOOL_MANAGER::RunMainStack( TOOL_BASE* aTool, std::function<void()> aFunc )
}
OPT<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool, const TOOL_EVENT_LIST& aConditions )
TOOL_EVENT* TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool, const TOOL_EVENT_LIST& aConditions )
{
TOOL_STATE* st = m_toolState[aTool];
@ -519,7 +519,7 @@ OPT<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool, const TOOL_EVENT_L
// switch context back to event dispatcher loop
st->cofunc->KiYield();
return st->wakeupEvent;
return &st->wakeupEvent;
}
@ -557,7 +557,7 @@ void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
}
// If the tool did not request the event be passed to other tools, we're done
if( !aEvent.PassEvent() )
if( !st->wakeupEvent.PassEvent() )
break;
}
}

View File

@ -72,7 +72,3 @@ void TOOL_MENU::ShowContextMenu()
}
void TOOL_MENU::CloseContextMenu( OPT_TOOL_EVENT& evt )
{
}

View File

@ -54,7 +54,7 @@ void CVPCB_SELECTION_TOOL::Reset( RESET_REASON aReason )
int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This is kind of hacky: activate RMB drag on any event.
// There doesn't seem to be any other good way to tell when another tool
@ -88,11 +88,6 @@ int CVPCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
clearSelection();
}
else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}
else
evt->SetPassEvent();
}

View File

@ -42,7 +42,7 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
setControls();
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
VECTOR2I cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
@ -75,7 +75,7 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
setControls();
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( m_cancelHandler )
{

View File

@ -271,9 +271,9 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
bool modified = false;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( *evt ) )
break;
if ( !inDrag )
@ -295,7 +295,7 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
updatePoints();
}
else if( evt->IsMouseUp( BUT_LEFT ) )
else if( inDrag && evt->IsMouseUp( BUT_LEFT ) )
{
controls->SetAutoPan( false );
inDrag = false;

View File

@ -292,7 +292,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
};
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// Should selected items be added to the current selection or
// become the new selection (discarding previously selected items)
@ -417,11 +417,6 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
ClearSelection();
}
else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}
else
evt->SetPassEvent();
}
@ -656,7 +651,7 @@ bool EE_SELECTION_TOOL::selectMultiple()
KIGFX::PREVIEW::SELECTION_AREA area;
view->Add( &area );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
{
@ -987,7 +982,7 @@ bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
menu.DisplayTitle( true );
SetContextMenu( &menu, CMENU_NOW );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->Action() == TA_CHOICE_MENU_UPDATE )
{
@ -1004,7 +999,7 @@ bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
}
else
{
current = NULL;
current = nullptr;
}
}
else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
@ -1018,7 +1013,7 @@ bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector )
if( id && ( *id > 0 ) )
current = ( *aCollector )[*id - 1];
else
current = NULL;
current = nullptr;
break;
}

View File

@ -118,11 +118,11 @@ int LIB_DRAWING_TOOLS::doTwoClickPlace( KICAD_T aType, bool aImmediateMode )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( item )
{
@ -282,7 +282,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
{
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();
@ -396,9 +396,9 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
Activate();
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
break;
}

View File

@ -89,10 +89,10 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
controls->ShowCursor( true );
controls->SetAutoPan( true );
bool restore_state = false;
bool chain_commands = false;
OPT_TOOL_EVENT evt = aEvent;
VECTOR2I prevPos;
bool restore_state = false;
bool chain_commands = false;
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
VECTOR2I prevPos;
if( !selection.Front()->IsNew() )
saveCopyInUndoList( m_frame->GetCurPart(), UR_LIBEDIT );
@ -193,7 +193,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
//------------------------------------------------------------------------
// Handle cancel
//
else if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( m_moveInProgress )
restore_state = true;
@ -254,7 +254,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
break; // Finish
}
} while( ( evt = Wait() ) ); //Should be assignment not equality test
} while( ( evt = Wait() ) ); // Assignment intentional; not equality test
controls->ForceCursorPosition( false );
controls->ShowCursor( false );

View File

@ -117,11 +117,11 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::cursorClick );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( component )
{
@ -254,11 +254,11 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( image )
{
@ -408,11 +408,11 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( !evt->IsActivate() && !immediateMode )
m_frame->PopTool();
@ -508,11 +508,11 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( item )
{
@ -621,7 +621,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
}
else if( item && TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
else if( item && TOOL_EVT_UTILS::IsSelectionEvent( *evt ) )
{
// This happens if our text was replaced out from under us by ConvertTextType()
EE_SELECTION& selection = m_selectionTool->GetSelection();
@ -644,8 +644,8 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
}
// Enable autopanning and cursor capture only when there is a module to be placed
getViewControls()->SetAutoPan( !!item );
getViewControls()->CaptureCursor( !!item );
getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr );
}
if( immediateMode )
@ -675,11 +675,11 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events
while( auto evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
m_view->ClearPreview();

View File

@ -313,7 +313,7 @@ int SCH_LINE_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
SetContextMenu( &unfoldMenu, CMENU_NOW );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->Action() == TA_CHOICE_MENU_CHOICE )
{
@ -495,14 +495,14 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment, bool
m_toolMgr->RunAction( ACTIONS::cursorClick );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
//------------------------------------------------------------------------
// Handle cancel:
//
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( aSegment || m_busUnfold.in_progress )
{

View File

@ -150,10 +150,10 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
Activate();
controls->ShowCursor( true );
bool restore_state = false;
bool chain_commands = false;
OPT_TOOL_EVENT evt = aEvent;
VECTOR2I prevPos;
bool restore_state = false;
bool chain_commands = false;
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
VECTOR2I prevPos;
m_cursor = controls->GetCursorPosition();
@ -334,7 +334,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
//------------------------------------------------------------------------
// Handle cancel
//
else if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( m_moveInProgress )
restore_state = true;

View File

@ -181,7 +181,7 @@ void GERBVIEW_SELECTION_TOOL::Reset( RESET_REASON aReason )
int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This is kind of hacky: activate RMB drag on any event.
// There doesn't seem to be any other good way to tell when another tool
@ -224,11 +224,6 @@ int GERBVIEW_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
clearSelection();
}
else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}
else
evt->SetPassEvent();
}
@ -355,7 +350,7 @@ bool GERBVIEW_SELECTION_TOOL::selectMultiple()
KIGFX::PREVIEW::SELECTION_AREA area;
view->Add( &area );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->IsCancel() )
{
@ -605,7 +600,7 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec
menu.DisplayTitle( true );
SetContextMenu( &menu, CMENU_NOW );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->Action() == TA_CHOICE_MENU_UPDATE )
{

View File

@ -90,7 +90,7 @@ public:
* Suspends execution of the tool until an event specified in aEventList arrives.
* No parameters means waiting for any event.
*/
OPT_TOOL_EVENT Wait( const TOOL_EVENT_LIST& aEventList = TOOL_EVENT( TC_ANY, TA_ANY ) );
TOOL_EVENT* Wait( const TOOL_EVENT_LIST& aEventList = TOOL_EVENT( TC_ANY, TA_ANY ) );
/** functions below are not yet implemented - their interface may change */
/*template <class Parameters, class ReturnValue>

View File

@ -318,8 +318,7 @@ public:
* The pause/resume operation is done through COROUTINE object.
* Called only from coroutines.
*/
OPT<TOOL_EVENT> ScheduleWait( TOOL_BASE* aTool,
const TOOL_EVENT_LIST& aConditions );
TOOL_EVENT* ScheduleWait( TOOL_BASE* aTool, const TOOL_EVENT_LIST& aConditions );
/**
* Sets behaviour of the tool's context popup menu.
@ -331,8 +330,7 @@ public:
* CMENU_OFF: menu is disabled.
* May be called from a coroutine context.
*/
void ScheduleContextMenu( TOOL_BASE* aTool, ACTION_MENU* aMenu,
CONTEXT_MENU_TRIGGER aTrigger );
void ScheduleContextMenu( TOOL_BASE* aTool, ACTION_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger );
/**
* Stores an information to the system clipboard.

View File

@ -110,14 +110,6 @@ public:
*/
void ShowContextMenu();
/**
* Function CloseContextMenu
*
* Helper function to close a menu previously opened with
* ShowContextMenu(), if a suitable event is received
*/
void CloseContextMenu( OPT_TOOL_EVENT& evt );
private:
/**
* The conditional menu displayed by the tool

View File

@ -108,11 +108,11 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
Activate();
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( item )
{
@ -230,11 +230,11 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
WS_DRAW_ITEM_BASE* item = nullptr;
// Main loop: keep receiving events
while( auto evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );

View File

@ -107,10 +107,10 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
controls->ShowCursor( true );
controls->SetAutoPan( true );
bool restore_state = false;
bool chain_commands = false;
OPT_TOOL_EVENT evt = aEvent;
VECTOR2I prevPos;
bool restore_state = false;
bool chain_commands = false;
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
VECTOR2I prevPos;
if( !selection.Front()->IsNew() )
m_frame->SaveCopyInUndoList();
@ -184,7 +184,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
//------------------------------------------------------------------------
// Handle cancel
//
else if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( m_moveInProgress )
restore_state = true;

View File

@ -70,7 +70,7 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
setControls();
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
VECTOR2I cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
@ -103,7 +103,7 @@ int PL_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
setControls();
}
else if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) )
else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
if( m_cancelHandler )
{

View File

@ -178,9 +178,9 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
bool modified = false;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( *evt ) )
break;
if ( !inDrag )
@ -203,7 +203,7 @@ int PL_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
updatePoints();
}
else if( evt->IsMouseUp( BUT_LEFT ) )
else if( inDrag && evt->IsMouseUp( BUT_LEFT ) )
{
controls->SetAutoPan( false );
m_frame->PopTool();

View File

@ -109,7 +109,7 @@ int PL_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent )
int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// Should selected items be added to the current selection or
// become the new selection (discarding previously selected items)
@ -187,11 +187,6 @@ int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
ClearSelection();
}
else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}
else
evt->SetPassEvent();
}
@ -308,9 +303,9 @@ bool PL_SELECTION_TOOL::selectMultiple()
KIGFX::PREVIEW::SELECTION_AREA area;
view->Add( &area );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
cancelled = true;
break;
@ -525,7 +520,7 @@ bool PL_SELECTION_TOOL::doSelectionMenu( COLLECTOR* aCollector )
menu.DisplayTitle( true );
SetContextMenu( &menu, CMENU_NOW );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->Action() == TA_CHOICE_MENU_UPDATE )
{

View File

@ -187,7 +187,7 @@ void LENGTH_TUNER_TOOL::performTuning()
m_router->Move( end, NULL );
updateStatusPopup( statusPopup );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
break;
@ -293,7 +293,7 @@ int LENGTH_TUNER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
SetContextMenu( ctxMenu.get() );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{

View File

@ -757,7 +757,7 @@ void ROUTER_TOOL::performRouting()
if( !prepareInteractive() )
return;
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// Don't crash if we missed an operation that cancelled routing.
wxCHECK2( m_router->RoutingInProgress(), break );
@ -914,7 +914,7 @@ int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
SetContextMenu( ctxMenu.get() );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
@ -1000,7 +1000,7 @@ void ROUTER_TOOL::performDragging( int aMode )
m_gridHelper->SetAuxAxes( true, m_startSnapPoint, true );
frame()->UndoRedoBlock( true );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
ctls->ForceCursorPosition( false );
@ -1153,7 +1153,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
controls()->SetAutoPan( true );
frame()->UndoRedoBlock( true );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->IsCancel() )
{

View File

@ -285,7 +285,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
bool reselect = false;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
@ -480,7 +480,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
int step = SET_ORIGIN;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
@ -770,7 +770,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
Activate();
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
cursorPos = m_controls->GetCursorPosition();
@ -848,7 +848,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
m_controls->SetAutoPan( true );
m_controls->CaptureCursor( false );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
@ -928,7 +928,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, OPT<VECTOR2D
}
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
@ -1142,7 +1142,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
bool firstPoint = false;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
PCB_LAYER_ID layer = getDrawingLayer();
aGraphic->SetLayer( layer );
@ -1329,7 +1329,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
status.SetTextColor( wxColour( 255, 0, 0 ) );
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );

View File

@ -291,11 +291,11 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
}
}
bool restore_state = false;
VECTOR2I totalMovement;
bool restore_state = false;
VECTOR2I totalMovement;
GRID_HELPER grid( editFrame );
OPT_TOOL_EVENT evt = aEvent;
VECTOR2I prevPos;
TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
VECTOR2I prevPos;
// Main loop: keep receiving events
do
@ -310,8 +310,8 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
if( m_dragging && evt->Category() == TC_MOUSE )
{
m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(),
item_layers, sel_items );
m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(), item_layers,
sel_items );
controls->ForceCursorPosition(true, m_cursor );
VECTOR2I movement( m_cursor - prevPos );
selection.SetReferencePoint( m_cursor );

View File

@ -367,7 +367,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
statusPopup.Popup();
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
{

View File

@ -533,7 +533,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
bool reselect = false;
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
@ -713,7 +713,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
m_frame->SetToolID( ID_PCB_TARGET_BUTT, wxCURSOR_PENCIL, _( "Add layer alignment target" ) );
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// This can be reset by some actions (e.g. Save Board), so ensure it stays set.
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );

View File

@ -71,7 +71,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer
}
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
VECTOR2I cursorPos = controls()->GetCursorPosition();
aPlacer->m_modifiers = evt->Modifier();

View File

@ -46,7 +46,7 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
setControls();
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );

View File

@ -318,7 +318,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
view->Add( m_editPoints.get() );
setEditedPoint( nullptr );
m_refill = false;
bool modified = false;
bool inDrag = false;
BOARD_COMMIT commit( editFrame );
LSET snapLayers = item->GetLayerSet();
@ -327,34 +327,34 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
snapLayers = LSET::AllLayersMask();
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( evt.get() ) )
if( !m_editPoints || TOOL_EVT_UTILS::IsSelectionEvent( *evt ) )
break;
if ( !modified )
if ( !inDrag )
updateEditedPoint( *evt );
if( evt->IsDrag( BUT_LEFT ) && m_editedPoint )
{
if( !modified )
if( !inDrag )
{
commit.StageItems( selection, CHT_MODIFY );
controls->ForceCursorPosition( false );
m_original = *m_editedPoint; // Save the original position
controls->SetAutoPan( true );
modified = true;
inDrag = true;
grid.SetAuxAxes( true, m_original.GetPosition(), true );
}
//TODO: unify the constraints to solve simultaneously instead of sequentially
m_editedPoint->SetPosition( grid.BestSnapAnchor( evt->Position(),
snapLayers, { item } ) );
snapLayers, { item } ) );
bool enableAltConstraint = !!evt->Modifier( MD_CTRL );
if( enableAltConstraint != (bool) m_altConstraint ) // alternative constraint
@ -366,28 +366,25 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
m_editedPoint->ApplyConstraint();
m_editedPoint->SetPosition( grid.BestSnapAnchor( m_editedPoint->GetPosition(),
snapLayers, { item } ) );
snapLayers, { item } ) );
updateItem();
updatePoints();
}
else if( evt->IsMouseUp( BUT_LEFT ) )
else if( inDrag && evt->IsMouseUp( BUT_LEFT ) )
{
controls->SetAutoPan( false );
setAltConstraint( false );
if( modified )
{
commit.Push( _( "Drag a corner" ) );
modified = false;
m_refill = true;
}
commit.Push( _( "Drag a corner" ) );
inDrag = false;
m_refill = true;
}
else if( evt->IsCancel() )
{
if( modified ) // Restore the last change
if( inDrag ) // Restore the last change
commit.Revert();
// ESC should clear selection along with edit points

View File

@ -188,7 +188,7 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Main loop: keep receiving events
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
// Should selected items be added to the current selection or
// become the new selection (discarding previously selected items)
@ -293,11 +293,6 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::clearHighlight, true );
}
else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
{
m_menu.CloseContextMenu( evt );
}
else
evt->SetPassEvent();
}
@ -528,7 +523,7 @@ bool SELECTION_TOOL::selectMultiple()
KIGFX::PREVIEW::SELECTION_AREA area;
view->Add( &area );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
{
@ -1358,7 +1353,7 @@ bool SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector, const wxStr
menu.DisplayTitle( true );
SetContextMenu( &menu, CMENU_NOW );
while( OPT_TOOL_EVENT evt = Wait() )
while( TOOL_EVENT* evt = Wait() )
{
if( evt->Action() == TA_CHOICE_MENU_UPDATE )
{