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();
if( evt->IsCancelInteractive() || evt->IsActivate() )
{
break;
}
else if( evt->IsDrag( BUT_LEFT ) || evt->IsDrag( BUT_RIGHT ) )
{
if( selectRegion() )
break;
}
else
{
evt->SetPassEvent();
}
}
// Exit zoom tool
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->PopTool( tool );
return 0;
}

View File

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

View File

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

View File

@ -469,7 +469,6 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
controls->ShowCursor( true );
Activate();
// Add the new label to the selection so the rotate command operates on it
@ -508,10 +507,9 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
bool forceHV = m_frame->eeconfig()->m_Drawing.hv_lines_only;
//------------------------------------------------------------------------
// Handle cancel:
//
auto cleanup = [&] () {
auto cleanup =
[&] ()
{
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
for( auto wire : m_wires )
@ -537,6 +535,9 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
m_view->ShowPreview( false );
};
//------------------------------------------------------------------------
// Handle cancel:
//
if( evt->IsCancelInteractive() )
{
if( segment || m_busUnfold.in_progress )
@ -730,13 +731,16 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
}
}
else
{
evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a segment to be placed
controls->SetAutoPan( segment != nullptr );
controls->CaptureCursor( segment != nullptr );
}
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls->ForceCursorPosition( false );
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 )
{
auto& view = *getView();
auto& controls = *getViewControls();
auto previous_settings = controls.GetSettings();
KIGFX::VIEW& view = *getView();
KIGFX::VIEW_CONTROLS& controls = *getViewControls();
KIGFX::VC_SETTINGS previous_settings = controls.GetSettings();
std::string tool = aEvent.GetCommandStr().get();
m_frame->PushTool( tool );
@ -312,7 +312,9 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
view.SetVisible( &ruler, false );
view.Remove( &ruler );
controls.ApplySettings( previous_settings );
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0;
}

View File

@ -195,13 +195,16 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
getView()->Update( item );
}
else
{
evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is an item to be placed
getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr );
}
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0;
}
@ -261,7 +264,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
if( evt->IsActivate() && !evt->IsPointEditor() && !evt->IsMoveTool() )
break;
}
else if( evt->IsClick( BUT_LEFT ) )
{
if( !item ) // start drawing
@ -285,7 +287,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
m_frame->OnModify();
}
}
else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
{
if( item )
@ -295,7 +296,6 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
getView()->Update( item );
}
}
else if( evt->IsClick( BUT_RIGHT ) )
{
// 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() );
}
else
{
evt->SetPassEvent();
}
// Enable autopanning and cursor capture only when there is a shape being drawn
getViewControls()->SetAutoPan( item != nullptr );
getViewControls()->CaptureCursor( item != nullptr );
}
m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
m_frame->PopTool( tool );
return 0;
}

View File

@ -149,7 +149,9 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
setCursor();
VECTOR2I cursorPos = controls.GetCursorPosition();
auto cleanup = [&] () {
auto cleanup =
[&] ()
{
originSet = false;
controls.CaptureCursor( false );
controls.SetAutoPan( false );
@ -167,7 +169,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
break;
}
}
else if( evt->IsActivate() )
{
if( originSet )
@ -184,7 +185,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
break;
}
}
// A click or drag starts
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.SetAutoPan( true );
}
// another click after origin set is the end
// 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 ) ) )
@ -212,7 +211,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
view.SetVisible( &previewRect, false );
view.Update( &previewRect, KIGFX::GEOMETRY );
}
// any move or drag once the origin was set updates
// the end point
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.Update( &previewRect, KIGFX::GEOMETRY );
}
else if( evt->IsClick( BUT_RIGHT ) )
{
m_menu.ShowContextMenu( selection() );
}
else
{
evt->SetPassEvent();
}
}
view.Remove( &previewRect );
frame.GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
controls.CaptureCursor( false );
controls.SetAutoPan( false );
view.Remove( &previewRect );
return 0;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -323,6 +323,8 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
view.SetVisible( &ruler, false );
view.Remove( &ruler );
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
return 0;
}