Go back to arrow cursor on a cancel (or finish).

Fixes https://gitlab.com/kicad/code/kicad/issues/6421
This commit is contained in:
Jeff Young 2020-11-19 20:08:58 +00:00
parent c2ba68cdfa
commit 9e9946628a
14 changed files with 272 additions and 209 deletions

View File

@ -63,19 +63,22 @@ int ZOOM_TOOL::Main( const TOOL_EVENT& aEvent )
setCursor(); setCursor();
if( evt->IsCancelInteractive() || evt->IsActivate() ) if( evt->IsCancelInteractive() || evt->IsActivate() )
{
break; break;
}
else if( evt->IsDrag( BUT_LEFT ) || evt->IsDrag( BUT_RIGHT ) ) else if( evt->IsDrag( BUT_LEFT ) || evt->IsDrag( BUT_RIGHT ) )
{ {
if( selectRegion() ) if( selectRegion() )
break; break;
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
} }
// Exit zoom tool // Exit zoom tool
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->PopTool( tool ); m_frame->PopTool( tool );
return 0; return 0;
} }

View File

@ -95,8 +95,10 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
{ {
if( item ) if( item )
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PLACE ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PLACE );
else if( isText )
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
else else
m_frame->GetCanvas()->SetCurrentCursor( isText ? KICURSOR::TEXT : KICURSOR::PENCIL ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
}; };
// Set initial cursor // Set initial cursor
@ -109,12 +111,14 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = [&] () { auto cleanup =
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); [&] ()
m_view->ClearPreview(); {
delete item; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
item = nullptr; m_view->ClearPreview();
}; delete item;
item = nullptr;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -142,7 +146,6 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
LIB_PART* part = m_frame->GetCurPart(); LIB_PART* part = m_frame->GetCurPart();
@ -201,7 +204,6 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
getViewControls()->SetCursorPosition( cursorPos, false ); getViewControls()->SetCursorPosition( cursorPos, false );
} }
// ... and second click places: // ... and second click places:
else else
{ {
@ -235,22 +237,23 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() ); m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
} }
else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) ) else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{ {
static_cast<LIB_ITEM*>( item )->SetPosition( wxPoint( cursorPos.x, -cursorPos.y ) ); static_cast<LIB_ITEM*>( item )->SetPosition( wxPoint( cursorPos.x, -cursorPos.y ) );
m_view->ClearPreview(); m_view->ClearPreview();
m_view->AddToPreview( item->Clone() ); m_view->AddToPreview( item->Clone() );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is an item to be placed // Enable autopanning and cursor capture only when there is an item to be placed
getViewControls()->SetAutoPan( item != nullptr ); getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -294,12 +297,14 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = [&] () { auto cleanup =
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); [&] ()
m_view->ClearPreview(); {
delete item; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
item = nullptr; m_view->ClearPreview();
}; delete item;
item = nullptr;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -311,7 +316,6 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
if( item ) if( item )
@ -332,7 +336,6 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsClick( BUT_LEFT ) && !item ) else if( evt->IsClick( BUT_LEFT ) && !item )
{ {
if( !part ) if( !part )
@ -364,7 +367,6 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_selectionTool->AddItemToSel( item ); m_selectionTool->AddItemToSel( item );
} }
else if( item && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) else if( item && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT )
|| evt->IsAction( &EE_ACTIONS::finishDrawing ) ) ) || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
{ {
@ -384,19 +386,16 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::activatePointEditor ); m_toolMgr->RunAction( ACTIONS::activatePointEditor );
} }
} }
else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) ) else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{ {
item->CalcEdit( wxPoint( cursorPos.x, -cursorPos.y) ); item->CalcEdit( wxPoint( cursorPos.x, -cursorPos.y) );
m_view->ClearPreview(); m_view->ClearPreview();
m_view->AddToPreview( item->Clone() ); m_view->AddToPreview( item->Clone() );
} }
else if( evt->IsDblClick( BUT_LEFT ) && !item ) else if( evt->IsDblClick( BUT_LEFT ) && !item )
{ {
m_toolMgr->RunAction( EE_ACTIONS::properties, true ); m_toolMgr->RunAction( EE_ACTIONS::properties, true );
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
// Warp after context menu only if dragging... // Warp after context menu only if dragging...
@ -405,15 +404,17 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() ); m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a shape being drawn // Enable autopanning and cursor capture only when there is a shape being drawn
getViewControls()->SetAutoPan( item != nullptr ); getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -478,6 +479,7 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
evt->SetPassEvent(); evt->SetPassEvent();
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }

View File

@ -84,14 +84,18 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
std::vector<PICKED_SYMBOL>* historyList = nullptr; std::vector<PICKED_SYMBOL>* historyList = nullptr;
if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) ) if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
{
historyList = &m_symbolHistoryList; historyList = &m_symbolHistoryList;
}
else if (aEvent.IsAction( &EE_ACTIONS::placePower ) ) else if (aEvent.IsAction( &EE_ACTIONS::placePower ) )
{ {
historyList = &m_powerHistoryList; historyList = &m_powerHistoryList;
filter.FilterPowerParts( true ); filter.FilterPowerParts( true );
} }
else else
{
wxFAIL_MSG( "PlaceCompontent(): unexpected request" ); wxFAIL_MSG( "PlaceCompontent(): unexpected request" );
}
getViewControls()->ShowCursor( true ); getViewControls()->ShowCursor( true );
@ -115,7 +119,9 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( ACTIONS::refreshPreview ); m_toolMgr->RunAction( ACTIONS::refreshPreview );
} }
else if( aEvent.HasPosition() ) else if( aEvent.HasPosition() )
{
m_toolMgr->RunAction( EE_ACTIONS::cursorClick ); m_toolMgr->RunAction( EE_ACTIONS::cursorClick );
}
auto setCursor = auto setCursor =
[&]() [&]()
@ -132,17 +138,21 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
setCursor(); setCursor();
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = [&] () { auto cleanup =
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); [&] ()
m_view->ClearPreview(); {
delete component; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
component = nullptr; m_view->ClearPreview();
}; delete component;
component = nullptr;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
if( component ) if( component )
{
cleanup(); cleanup();
}
else else
{ {
m_frame->PopTool( tool ); m_frame->PopTool( tool );
@ -184,8 +194,8 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
if( !part ) if( !part )
continue; continue;
component = new SCH_COMPONENT( component = new SCH_COMPONENT( *part, &m_frame->GetCurrentSheet(), sel,
*part, &m_frame->GetCurrentSheet(), sel, (wxPoint) cursorPos ); (wxPoint) cursorPos );
component->SetParent( m_frame->GetCurrentSheet().LastScreen() ); component->SetParent( m_frame->GetCurrentSheet().LastScreen() );
component->SetFlags( IS_NEW | IS_MOVED ); component->SetFlags( IS_NEW | IS_MOVED );
@ -221,9 +231,13 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
if( m_frame->eeconfig()->m_SymChooserPanel.place_all_units if( m_frame->eeconfig()->m_SymChooserPanel.place_all_units
&& component->GetUnit() < component->GetUnitCount() ) && component->GetUnit() < component->GetUnitCount() )
{
new_unit++; new_unit++;
}
else else
{
new_unit = 1; new_unit = 1;
}
// We are either stepping to the next unit or next component // We are either stepping to the next unit or next component
if( m_frame->eeconfig()->m_SymChooserPanel.keep_symbol || new_unit > 1 ) if( m_frame->eeconfig()->m_SymChooserPanel.keep_symbol || new_unit > 1 )
@ -286,6 +300,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( component != nullptr ); getViewControls()->CaptureCursor( component != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -335,17 +350,21 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
setCursor(); setCursor();
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = [&] () { auto cleanup =
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); [&] ()
m_view->ClearPreview(); {
delete image; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
image = nullptr; m_view->ClearPreview();
}; delete image;
image = nullptr;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
if( image ) if( image )
{
cleanup(); cleanup();
}
else else
{ {
m_frame->PopTool( tool ); m_frame->PopTool( tool );
@ -452,6 +471,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
getViewControls()->CaptureCursor( image != nullptr ); getViewControls()->CaptureCursor( image != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -661,6 +681,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
delete previewItem; delete previewItem;
m_view->ClearPreview(); m_view->ClearPreview();
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -825,17 +846,21 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = [&] () { auto cleanup =
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); [&] ()
m_view->ClearPreview(); {
delete item; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
item = nullptr; m_view->ClearPreview();
}; delete item;
item = nullptr;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
if( item ) if( item )
{
cleanup(); cleanup();
}
else else
{ {
m_frame->PopTool( tool ); m_frame->PopTool( tool );
@ -973,7 +998,9 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_view->AddToPreview( item->Clone() ); m_view->AddToPreview( item->Clone() );
} }
else else
{
item = nullptr; item = nullptr;
}
} }
else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) ) else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{ {
@ -982,13 +1009,16 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
m_view->AddToPreview( item->Clone() ); m_view->AddToPreview( item->Clone() );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a footprint to be placed // Enable autopanning and cursor capture only when there is a footprint to be placed
getViewControls()->SetAutoPan( item != nullptr ); getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -1024,17 +1054,21 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = [&] () { auto cleanup =
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); [&] ()
m_view->ClearPreview(); {
delete sheet; m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
sheet = nullptr; m_view->ClearPreview();
}; delete sheet;
sheet = nullptr;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
if( sheet ) if( sheet )
{
cleanup(); cleanup();
}
else else
{ {
m_frame->PopTool( tool ); m_frame->PopTool( tool );
@ -1061,7 +1095,6 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsClick( BUT_LEFT ) && !sheet ) else if( evt->IsClick( BUT_LEFT ) && !sheet )
{ {
EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); EESCHEMA_SETTINGS* cfg = m_frame->eeconfig();
@ -1082,7 +1115,6 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
m_view->ClearPreview(); m_view->ClearPreview();
m_view->AddToPreview( sheet->Clone() ); m_view->AddToPreview( sheet->Clone() );
} }
else if( sheet && ( evt->IsClick( BUT_LEFT ) else if( sheet && ( evt->IsClick( BUT_LEFT )
|| evt->IsAction( &EE_ACTIONS::finishSheet ) ) ) || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
{ {
@ -1106,14 +1138,12 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
sheet = nullptr; sheet = nullptr;
} }
else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) ) else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
{ {
sizeSheet( sheet, cursorPos ); sizeSheet( sheet, cursorPos );
m_view->ClearPreview(); m_view->ClearPreview();
m_view->AddToPreview( sheet->Clone() ); m_view->AddToPreview( sheet->Clone() );
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
// Warp after context menu only if dragging... // Warp after context menu only if dragging...
@ -1123,13 +1153,16 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() ); m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a sheet to be placed // Enable autopanning and cursor capture only when there is a sheet to be placed
getViewControls()->SetAutoPan( sheet != nullptr ); getViewControls()->SetAutoPan( sheet != nullptr );
getViewControls()->CaptureCursor( sheet != nullptr ); getViewControls()->CaptureCursor( sheet != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }

View File

@ -469,7 +469,6 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
controls->ShowCursor( true ); controls->ShowCursor( true );
Activate(); Activate();
// Add the new label to the selection so the rotate command operates on it // Add the new label to the selection so the rotate command operates on it
@ -508,35 +507,37 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
bool forceHV = m_frame->eeconfig()->m_Drawing.hv_lines_only; bool forceHV = m_frame->eeconfig()->m_Drawing.hv_lines_only;
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
for( auto wire : m_wires )
delete wire;
m_wires.clear();
segment = nullptr;
if( m_busUnfold.entry )
m_frame->RemoveFromScreen( m_busUnfold.entry, screen );
if( m_busUnfold.label && !m_busUnfold.label_placed )
m_selectionTool->RemoveItemFromSel( m_busUnfold.label, true );
if( m_busUnfold.label && m_busUnfold.label_placed )
m_frame->RemoveFromScreen( m_busUnfold.label, screen );
delete m_busUnfold.entry;
delete m_busUnfold.label;
m_busUnfold = {};
m_view->ClearPreview();
m_view->ShowPreview( false );
};
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Handle cancel: // Handle cancel:
// //
auto cleanup = [&] () {
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
for( auto wire : m_wires )
delete wire;
m_wires.clear();
segment = nullptr;
if( m_busUnfold.entry )
m_frame->RemoveFromScreen( m_busUnfold.entry, screen );
if( m_busUnfold.label && !m_busUnfold.label_placed )
m_selectionTool->RemoveItemFromSel( m_busUnfold.label, true );
if( m_busUnfold.label && m_busUnfold.label_placed )
m_frame->RemoveFromScreen( m_busUnfold.label, screen );
delete m_busUnfold.entry;
delete m_busUnfold.label;
m_busUnfold = {};
m_view->ClearPreview();
m_view->ShowPreview( false );
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
if( segment || m_busUnfold.in_progress ) if( segment || m_busUnfold.in_progress )
@ -730,13 +731,16 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
} }
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a segment to be placed // Enable autopanning and cursor capture only when there is a segment to be placed
controls->SetAutoPan( segment != nullptr ); controls->SetAutoPan( segment != nullptr );
controls->CaptureCursor( segment != nullptr ); controls->CaptureCursor( segment != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls->ForceCursorPosition( false ); controls->ForceCursorPosition( false );
return 0; return 0;
} }

View File

@ -191,9 +191,9 @@ int GERBVIEW_INSPECTION_TOOL::ShowSource( const TOOL_EVENT& aEvent )
int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
{ {
auto& view = *getView(); KIGFX::VIEW& view = *getView();
auto& controls = *getViewControls(); KIGFX::VIEW_CONTROLS& controls = *getViewControls();
auto previous_settings = controls.GetSettings(); KIGFX::VC_SETTINGS previous_settings = controls.GetSettings();
std::string tool = aEvent.GetCommandStr().get(); std::string tool = aEvent.GetCommandStr().get();
m_frame->PushTool( tool ); m_frame->PushTool( tool );
@ -226,13 +226,13 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
const VECTOR2I cursorPos = controls.GetCursorPosition(); const VECTOR2I cursorPos = controls.GetCursorPosition();
auto clearRuler = auto clearRuler =
[&] () [&] ()
{ {
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
controls.SetAutoPan( false ); controls.SetAutoPan( false );
controls.CaptureCursor( false ); controls.CaptureCursor( false );
originSet = false; originSet = false;
}; };
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -312,7 +312,9 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
view.Remove( &ruler ); view.Remove( &ruler );
controls.ApplySettings( previous_settings ); controls.ApplySettings( previous_settings );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }

View File

@ -110,15 +110,15 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
auto cleanup = auto cleanup =
[&] () [&] ()
{ {
m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true ); m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true );
item = nullptr; item = nullptr;
// There's nothing to roll-back, but we still need to pop the undo stack // There's nothing to roll-back, but we still need to pop the undo stack
// This also deletes the item being placed. // This also deletes the item being placed.
m_frame->RollbackFromUndo(); m_frame->RollbackFromUndo();
}; };
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -195,13 +195,16 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
getView()->Update( item ); getView()->Update( item );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is an item to be placed // Enable autopanning and cursor capture only when there is an item to be placed
getViewControls()->SetAutoPan( item != nullptr ); getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -261,7 +264,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( evt->IsActivate() && !evt->IsPointEditor() && !evt->IsMoveTool() ) if( evt->IsActivate() && !evt->IsPointEditor() && !evt->IsMoveTool() )
break; break;
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
if( !item ) // start drawing if( !item ) // start drawing
@ -285,7 +287,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_frame->OnModify(); m_frame->OnModify();
} }
} }
else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
{ {
if( item ) if( item )
@ -295,7 +296,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
getView()->Update( item ); getView()->Update( item );
} }
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
// Warp after context menu only if dragging... // Warp after context menu only if dragging...
@ -304,15 +304,17 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_menu.ShowContextMenu( m_selectionTool->GetSelection() ); m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a shape being drawn // Enable autopanning and cursor capture only when there is a shape being drawn
getViewControls()->SetAutoPan( item != nullptr ); getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr ); getViewControls()->CaptureCursor( item != nullptr );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->PopTool( tool ); m_frame->PopTool( tool );
return 0; return 0;
} }

View File

@ -111,9 +111,9 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
{ {
using namespace KIGFX::PREVIEW; using namespace KIGFX::PREVIEW;
KIGFX::VIEW& view = *getView(); KIGFX::VIEW& view = *getView();
KIGFX::VIEW_CONTROLS& controls = *getViewControls(); KIGFX::VIEW_CONTROLS& controls = *getViewControls();
PCB_EDIT_FRAME& frame = *getEditFrame<PCB_EDIT_FRAME>(); PCB_EDIT_FRAME& frame = *getEditFrame<PCB_EDIT_FRAME>();
std::string tool = aEvent.GetCommandStr().get(); std::string tool = aEvent.GetCommandStr().get();
frame.PushTool( tool ); frame.PushTool( tool );
@ -149,13 +149,15 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
setCursor(); setCursor();
VECTOR2I cursorPos = controls.GetCursorPosition(); VECTOR2I cursorPos = controls.GetCursorPosition();
auto cleanup = [&] () { auto cleanup =
originSet = false; [&] ()
controls.CaptureCursor( false ); {
controls.SetAutoPan( false ); originSet = false;
view.SetVisible( &previewRect, false ); controls.CaptureCursor( false );
view.Update( &previewRect, KIGFX::GEOMETRY ); controls.SetAutoPan( false );
}; view.SetVisible( &previewRect, false );
view.Update( &previewRect, KIGFX::GEOMETRY );
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -167,7 +169,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
if( originSet ) if( originSet )
@ -184,7 +185,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
break; break;
} }
} }
// A click or drag starts // A click or drag starts
else if( !originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) ) ) else if( !originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) ) )
{ {
@ -195,7 +195,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
controls.CaptureCursor( true ); controls.CaptureCursor( true );
controls.SetAutoPan( true ); controls.SetAutoPan( true );
} }
// another click after origin set is the end // another click after origin set is the end
// left up is also the end, as you'll only get that after a drag // left up is also the end, as you'll only get that after a drag
else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) ) else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
@ -212,7 +211,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
view.SetVisible( &previewRect, false ); view.SetVisible( &previewRect, false );
view.Update( &previewRect, KIGFX::GEOMETRY ); view.Update( &previewRect, KIGFX::GEOMETRY );
} }
// any move or drag once the origin was set updates // any move or drag once the origin was set updates
// the end point // the end point
else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) ) else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
@ -223,19 +221,21 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
view.SetVisible( &previewRect, true ); view.SetVisible( &previewRect, true );
view.Update( &previewRect, KIGFX::GEOMETRY ); view.Update( &previewRect, KIGFX::GEOMETRY );
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
m_menu.ShowContextMenu( selection() ); m_menu.ShowContextMenu( selection() );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
} }
view.Remove( &previewRect );
frame.GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls.CaptureCursor( false ); controls.CaptureCursor( false );
controls.SetAutoPan( false ); controls.SetAutoPan( false );
view.Remove( &previewRect );
return 0; return 0;
} }

View File

@ -254,6 +254,7 @@ void LENGTH_TUNER_TOOL::performTuning()
m_router->StopRouting(); m_router->StopRouting();
controls()->SetAutoPan( false ); controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false ); controls()->ForceCursorPosition( false );
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
highlightNet( false ); highlightNet( false );
} }
@ -323,6 +324,7 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
// Store routing settings till the next invocation // Store routing settings till the next invocation
m_savedSizes = m_router->Sizes(); m_savedSizes = m_router->Sizes();
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
frame()->PopTool( tool ); frame()->PopTool( tool );
return 0; return 0;
} }

View File

@ -962,6 +962,7 @@ bool ROUTER_TOOL::finishInteractive()
{ {
m_router->StopRouting(); m_router->StopRouting();
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls()->SetAutoPan( false ); controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false ); controls()->ForceCursorPosition( false );
frame()->UndoRedoBlock( false ); frame()->UndoRedoBlock( false );

View File

@ -450,16 +450,17 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
setCursor(); setCursor();
VECTOR2I cursorPos = m_controls->GetCursorPosition(); VECTOR2I cursorPos = m_controls->GetCursorPosition();
auto cleanup = [&]() auto cleanup =
{ [&]()
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); {
m_controls->ForceCursorPosition( false ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true ); m_controls->ForceCursorPosition( false );
m_controls->SetAutoPan( false ); m_controls->ShowCursor( true );
m_controls->CaptureCursor( false ); m_controls->SetAutoPan( false );
delete text; m_controls->CaptureCursor( false );
text = NULL; delete text;
}; text = NULL;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -619,7 +620,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
} }
} }
frame()->SetMsgPanel( board() ); m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->SetMsgPanel( board() );
return 0; return 0;
} }
@ -696,25 +698,28 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
cursorPos = grid.BestSnapAnchor( cursorPos, nullptr ); cursorPos = grid.BestSnapAnchor( cursorPos, nullptr );
m_controls->ForceCursorPosition( true, cursorPos ); m_controls->ForceCursorPosition( true, cursorPos );
auto cleanup = [&]() auto cleanup =
{ [&]()
m_controls->SetAutoPan( false ); {
m_controls->CaptureCursor( false ); m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
preview.Clear(); preview.Clear();
m_view->Update( &preview ); m_view->Update( &preview );
delete dimension; delete dimension;
dimension = nullptr; dimension = nullptr;
step = SET_ORIGIN; step = SET_ORIGIN;
}; };
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
m_controls->SetAutoPan( false ); m_controls->SetAutoPan( false );
if( step != SET_ORIGIN ) // start from the beginning if( step != SET_ORIGIN ) // start from the beginning
{
cleanup(); cleanup();
}
else else
{ {
m_frame->PopTool( tool ); m_frame->PopTool( tool );
@ -980,9 +985,10 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
m_controls->SetAutoPan( false ); m_controls->SetAutoPan( false );
m_controls->ForceCursorPosition( false ); m_controls->ForceCursorPosition( false );
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_view->Remove( &preview ); m_view->Remove( &preview );
frame()->SetMsgPanel( board() ); m_frame->SetMsgPanel( board() );
return 0; return 0;
} }
@ -1156,6 +1162,8 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
preview.Clear(); preview.Clear();
m_view->Remove( &preview ); m_view->Remove( &preview );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->PopTool( tool ); m_frame->PopTool( tool );
return 0; return 0;
} }
@ -1231,6 +1239,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
} }
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -1316,16 +1325,17 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic,
if( evt->Modifier( MD_CTRL ) ) if( evt->Modifier( MD_CTRL ) )
limit45 = !limit45; limit45 = !limit45;
auto cleanup = [&]() auto cleanup =
{ [&]()
preview.Clear(); {
m_view->Update( &preview ); preview.Clear();
delete graphic; m_view->Update( &preview );
graphic = nullptr; delete graphic;
graphic = nullptr;
if( !isLocalOriginSet ) if( !isLocalOriginSet )
m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 ); m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
}; };
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -1520,7 +1530,9 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic,
m_view->Remove( &twoPointAsst ); m_view->Remove( &twoPointAsst );
m_view->Remove( &preview ); m_view->Remove( &preview );
frame()->SetMsgPanel( board() ); m_frame->SetMsgPanel( board() );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_controls->SetAutoPan( false ); m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_controls->ForceCursorPosition( false ); m_controls->ForceCursorPosition( false );
@ -1603,11 +1615,13 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic );
m_controls->ForceCursorPosition( true, cursorPos ); m_controls->ForceCursorPosition( true, cursorPos );
auto cleanup = [&] () { auto cleanup =
preview.Clear(); [&] ()
delete *aGraphic; {
*aGraphic = nullptr; preview.Clear();
}; delete *aGraphic;
*aGraphic = nullptr;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -1760,7 +1774,9 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool
preview.Remove( graphic ); preview.Remove( graphic );
m_view->Remove( &arcAsst ); m_view->Remove( &arcAsst );
m_view->Remove( &preview ); m_view->Remove( &preview );
frame()->SetMsgPanel( board() ); m_frame->SetMsgPanel( board() );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_controls->SetAutoPan( false ); m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false ); m_controls->CaptureCursor( false );
m_controls->ForceCursorPosition( false ); m_controls->ForceCursorPosition( false );
@ -1891,14 +1907,15 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
else else
polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT ); polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
auto cleanup = [&] () auto cleanup =
{ [&] ()
polyGeomMgr.Reset(); {
started = false; polyGeomMgr.Reset();
grid.ClearSkipPoint(); started = false;
m_controls->SetAutoPan( false ); grid.ClearSkipPoint();
m_controls->CaptureCursor( false ); m_controls->SetAutoPan( false );
}; m_controls->CaptureCursor( false );
};
if( evt->IsCancelInteractive()) if( evt->IsCancelInteractive())
{ {
@ -2030,6 +2047,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
} // end while } // end while
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_controls->ForceCursorPosition( false ); m_controls->ForceCursorPosition( false );
return 0; return 0;
} }

View File

@ -315,7 +315,6 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
frame()->PopTool( tool ); frame()->PopTool( tool );
break; break;
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
commit.Push( _( "Renumber pads" ) ); commit.Push( _( "Renumber pads" ) );
@ -323,7 +322,6 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
frame()->PopTool( tool ); frame()->PopTool( tool );
break; break;
} }
else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) else if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
{ {
selectedPads.clear(); selectedPads.clear();
@ -414,7 +412,6 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
} }
} }
} }
else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) || else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
evt->IsDblClick( BUT_LEFT ) ) evt->IsDblClick( BUT_LEFT ) )
{ {
@ -422,14 +419,14 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
frame()->PopTool( tool ); frame()->PopTool( tool );
break; break;
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
m_menu.ShowContextMenu( selection() ); m_menu.ShowContextMenu( selection() );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Prepare the next loop by updating the old cursor mouse position // Prepare the next loop by updating the old cursor mouse position
// to this last mouse cursor position // to this last mouse cursor position
@ -444,6 +441,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
} }
statusPopup.Hide(); statusPopup.Hide();
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }

View File

@ -802,25 +802,26 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
if( reselect && fp ) if( reselect && fp )
m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, fp ); m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, fp );
auto cleanup = [&] () auto cleanup =
{ [&] ()
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
commit.Revert();
if( fromOtherCommand )
{
PICKED_ITEMS_LIST* undo = m_frame->PopCommandFromUndoList();
if( undo )
{ {
m_frame->PutDataInPreviousState( undo, false ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
undo->ClearListAndDeleteItems(); commit.Revert();
delete undo;
}
}
fp = NULL; if( fromOtherCommand )
}; {
PICKED_ITEMS_LIST* undo = m_frame->PopCommandFromUndoList();
if( undo )
{
m_frame->PutDataInPreviousState( undo, false );
undo->ClearListAndDeleteItems();
delete undo;
}
}
fp = NULL;
};
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -832,7 +833,6 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
if( fp ) if( fp )
@ -849,7 +849,6 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
if( !fp ) if( !fp )
@ -890,33 +889,32 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
fp = NULL; // to indicate that there is no footprint that we currently modify fp = NULL; // to indicate that there is no footprint that we currently modify
} }
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
m_menu.ShowContextMenu( selection() ); m_menu.ShowContextMenu( selection() );
} }
else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) ) else if( fp && ( evt->IsMotion() || evt->IsAction( &ACTIONS::refreshPreview ) ) )
{ {
fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); fp->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
selection().SetReferencePoint( cursorPos ); selection().SetReferencePoint( cursorPos );
getView()->Update( & selection() ); getView()->Update( & selection() );
} }
else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) ) else if( fp && evt->IsAction( &PCB_ACTIONS::properties ) )
{ {
// Calling 'Properties' action clears the selection, so we need to restore it // Calling 'Properties' action clears the selection, so we need to restore it
reselect = true; reselect = true;
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a footprint to be placed // Enable autopanning and cursor capture only when there is a footprint to be placed
controls->SetAutoPan( !!fp ); controls->SetAutoPan( !!fp );
controls->CaptureCursor( !!fp ); controls->CaptureCursor( !!fp );
} }
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }
@ -1031,7 +1029,6 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
frame()->PopTool( tool ); frame()->PopTool( tool );
break; break;
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
if( evt->IsMoveTool() ) if( evt->IsMoveTool() )
@ -1045,13 +1042,11 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
break; break;
} }
} }
else if( evt->IsAction( &PCB_ACTIONS::incWidth ) ) else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
{ {
target->SetWidth( target->GetWidth() + WIDTH_STEP ); target->SetWidth( target->GetWidth() + WIDTH_STEP );
view->Update( &preview ); view->Update( &preview );
} }
else if( evt->IsAction( &PCB_ACTIONS::decWidth ) ) else if( evt->IsAction( &PCB_ACTIONS::decWidth ) )
{ {
int width = target->GetWidth(); int width = target->GetWidth();
@ -1062,7 +1057,6 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
view->Update( &preview ); view->Update( &preview );
} }
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
assert( target->GetSize() > 0 ); assert( target->GetSize() > 0 );
@ -1078,25 +1072,26 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
target = new PCB_TARGET( *target ); target = new PCB_TARGET( *target );
preview.Add( target ); preview.Add( target );
} }
else if( evt->IsClick( BUT_RIGHT ) ) else if( evt->IsClick( BUT_RIGHT ) )
{ {
m_menu.ShowContextMenu( selection() ); m_menu.ShowContextMenu( selection() );
} }
else if( evt->IsMotion() ) else if( evt->IsMotion() )
{ {
target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) ); target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
view->Update( &preview ); view->Update( &preview );
} }
else else
{
evt->SetPassEvent(); evt->SetPassEvent();
}
} }
preview.Clear(); preview.Clear();
delete target; delete target;
view->Remove( &preview ); view->Remove( &preview );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }

View File

@ -247,6 +247,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
} }
view()->Remove( &preview ); view()->Remove( &preview );
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
} }

View File

@ -238,13 +238,13 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
controls.ForceCursorPosition(true, cursorPos ); controls.ForceCursorPosition(true, cursorPos );
auto clearRuler = auto clearRuler =
[&] () [&] ()
{ {
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
controls.SetAutoPan( false ); controls.SetAutoPan( false );
controls.CaptureCursor( false ); controls.CaptureCursor( false );
originSet = false; originSet = false;
}; };
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )
{ {
@ -323,6 +323,8 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
view.SetVisible( &ruler, false ); view.SetVisible( &ruler, false );
view.Remove( &ruler ); view.Remove( &ruler );
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0; return 0;
} }