From 9e9946628a09ef805d0ee04e560d617cb7dcd07c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 19 Nov 2020 20:08:58 +0000 Subject: [PATCH] Go back to arrow cursor on a cancel (or finish). Fixes https://gitlab.com/kicad/code/kicad/issues/6421 --- common/tool/zoom_tool.cpp | 7 +- eeschema/tools/lib_drawing_tools.cpp | 50 +++++---- eeschema/tools/sch_drawing_tools.cpp | 93 +++++++++++----- eeschema/tools/sch_line_wire_bus_tool.cpp | 58 +++++----- gerbview/tools/gerbview_inspection_tool.cpp | 22 ++-- pagelayout_editor/tools/pl_drawing_tools.cpp | 26 +++-- pcbnew/microwave/microwave_tool.cpp | 32 +++--- pcbnew/router/length_tuner_tool.cpp | 2 + pcbnew/router/router_tool.cpp | 1 + pcbnew/tools/drawing_tool.cpp | 110 +++++++++++-------- pcbnew/tools/pad_tool.cpp | 8 +- pcbnew/tools/pcb_editor_control.cpp | 55 +++++----- pcbnew/tools/pcb_tool_base.cpp | 1 + pcbnew/tools/pcb_viewer_tools.cpp | 16 +-- 14 files changed, 272 insertions(+), 209 deletions(-) diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index d73d0bbb3f..11c4e34717 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -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; } diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 543541e65b..8ef51c525a 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -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,12 +111,14 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); - auto cleanup = [&] () { - m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_view->ClearPreview(); - delete item; - item = nullptr; - }; + auto cleanup = + [&] () + { + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + m_view->ClearPreview(); + delete item; + item = nullptr; + }; if( evt->IsCancelInteractive() ) { @@ -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( 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,12 +297,14 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); - auto cleanup = [&] () { - m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_view->ClearPreview(); - delete item; - item = nullptr; - }; + auto cleanup = + [&] () + { + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + m_view->ClearPreview(); + delete item; + item = nullptr; + }; if( evt->IsCancelInteractive() ) { @@ -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; } diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index cc6430c8bb..69d2e108c5 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -84,14 +84,18 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) std::vector* 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,17 +138,21 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) setCursor(); VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); - auto cleanup = [&] () { - m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_view->ClearPreview(); - delete component; - component = nullptr; - }; + auto cleanup = + [&] () + { + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + m_view->ClearPreview(); + delete component; + component = nullptr; + }; 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,17 +350,21 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) setCursor(); cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); - auto cleanup = [&] () { - m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_view->ClearPreview(); - delete image; - image = nullptr; - }; + auto cleanup = + [&] () + { + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + m_view->ClearPreview(); + delete image; + image = nullptr; + }; 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,17 +846,21 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); - auto cleanup = [&] () { - m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_view->ClearPreview(); - delete item; - item = nullptr; - }; + auto cleanup = + [&] () + { + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + m_view->ClearPreview(); + delete item; + item = nullptr; + }; if( evt->IsCancelInteractive() ) { if( item ) + { cleanup(); + } else { m_frame->PopTool( tool ); @@ -973,7 +998,9 @@ 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() ) ) { @@ -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,17 +1054,21 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); - auto cleanup = [&] () { - m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); - m_view->ClearPreview(); - delete sheet; - sheet = nullptr; - }; + auto cleanup = + [&] () + { + m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); + m_view->ClearPreview(); + delete sheet; + sheet = nullptr; + }; 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; } diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 8e05158ce9..f19efa9bf8 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -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,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; + 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: // - 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( 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; } diff --git a/gerbview/tools/gerbview_inspection_tool.cpp b/gerbview/tools/gerbview_inspection_tool.cpp index 577f24d9e9..420960af42 100644 --- a/gerbview/tools/gerbview_inspection_tool.cpp +++ b/gerbview/tools/gerbview_inspection_tool.cpp @@ -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 ); @@ -226,13 +226,13 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) const VECTOR2I cursorPos = controls.GetCursorPosition(); auto clearRuler = - [&] () - { - view.SetVisible( &ruler, false ); - controls.SetAutoPan( false ); - controls.CaptureCursor( false ); - originSet = false; - }; + [&] () + { + view.SetVisible( &ruler, false ); + controls.SetAutoPan( false ); + controls.CaptureCursor( false ); + originSet = false; + }; if( evt->IsCancelInteractive() ) { @@ -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; } diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index 7ee4f43063..2fa39462b2 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -110,15 +110,15 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent ) cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) ); auto cleanup = - [&] () - { - m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true ); - item = nullptr; + [&] () + { + m_toolMgr->RunAction( PL_ACTIONS::clearSelection, true ); + item = nullptr; - // There's nothing to roll-back, but we still need to pop the undo stack - // This also deletes the item being placed. - m_frame->RollbackFromUndo(); - }; + // There's nothing to roll-back, but we still need to pop the undo stack + // This also deletes the item being placed. + m_frame->RollbackFromUndo(); + }; if( evt->IsCancelInteractive() ) { @@ -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; } diff --git a/pcbnew/microwave/microwave_tool.cpp b/pcbnew/microwave/microwave_tool.cpp index dc2db8a1ce..20e1dc1e9d 100644 --- a/pcbnew/microwave/microwave_tool.cpp +++ b/pcbnew/microwave/microwave_tool.cpp @@ -111,9 +111,9 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent ) { using namespace KIGFX::PREVIEW; - KIGFX::VIEW& view = *getView(); + KIGFX::VIEW& view = *getView(); KIGFX::VIEW_CONTROLS& controls = *getViewControls(); - PCB_EDIT_FRAME& frame = *getEditFrame(); + PCB_EDIT_FRAME& frame = *getEditFrame(); std::string tool = aEvent.GetCommandStr().get(); frame.PushTool( tool ); @@ -149,13 +149,15 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent ) setCursor(); VECTOR2I cursorPos = controls.GetCursorPosition(); - auto cleanup = [&] () { - originSet = false; - controls.CaptureCursor( false ); - controls.SetAutoPan( false ); - view.SetVisible( &previewRect, false ); - view.Update( &previewRect, KIGFX::GEOMETRY ); - }; + auto cleanup = + [&] () + { + originSet = false; + controls.CaptureCursor( false ); + controls.SetAutoPan( false ); + view.SetVisible( &previewRect, false ); + view.Update( &previewRect, KIGFX::GEOMETRY ); + }; if( evt->IsCancelInteractive() ) { @@ -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; } diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 1dfcead993..7cd848d923 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -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; } diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index d3d912ace3..4443de47bb 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -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 ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 1b42e8f380..940c5dcdd0 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -450,16 +450,17 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) setCursor(); VECTOR2I cursorPos = m_controls->GetCursorPosition(); - auto cleanup = [&]() - { - m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - m_controls->ForceCursorPosition( false ); - m_controls->ShowCursor( true ); - m_controls->SetAutoPan( false ); - m_controls->CaptureCursor( false ); - delete text; - text = NULL; - }; + auto cleanup = + [&]() + { + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + m_controls->ForceCursorPosition( false ); + m_controls->ShowCursor( true ); + m_controls->SetAutoPan( false ); + m_controls->CaptureCursor( false ); + delete text; + text = NULL; + }; 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; } @@ -696,25 +698,28 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) cursorPos = grid.BestSnapAnchor( cursorPos, nullptr ); m_controls->ForceCursorPosition( true, cursorPos ); - auto cleanup = [&]() - { - m_controls->SetAutoPan( false ); - m_controls->CaptureCursor( false ); + auto cleanup = + [&]() + { + m_controls->SetAutoPan( false ); + m_controls->CaptureCursor( false ); - preview.Clear(); - m_view->Update( &preview ); + preview.Clear(); + m_view->Update( &preview ); - delete dimension; - dimension = nullptr; - step = SET_ORIGIN; - }; + delete dimension; + dimension = nullptr; + step = SET_ORIGIN; + }; if( evt->IsCancelInteractive() ) { 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,16 +1325,17 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic, if( evt->Modifier( MD_CTRL ) ) limit45 = !limit45; - auto cleanup = [&]() - { - preview.Clear(); - m_view->Update( &preview ); - delete graphic; - graphic = nullptr; + auto cleanup = + [&]() + { + preview.Clear(); + m_view->Update( &preview ); + delete graphic; + graphic = nullptr; - if( !isLocalOriginSet ) - m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 ); - }; + if( !isLocalOriginSet ) + m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 ); + }; 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( &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,11 +1615,13 @@ 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 = [&] () { - preview.Clear(); - delete *aGraphic; - *aGraphic = nullptr; - }; + auto cleanup = + [&] () + { + preview.Clear(); + delete *aGraphic; + *aGraphic = nullptr; + }; if( evt->IsCancelInteractive() ) { @@ -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,14 +1907,15 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) else polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT ); - auto cleanup = [&] () - { - polyGeomMgr.Reset(); - started = false; - grid.ClearSkipPoint(); - m_controls->SetAutoPan( false ); - m_controls->CaptureCursor( false ); - }; + auto cleanup = + [&] () + { + polyGeomMgr.Reset(); + started = false; + grid.ClearSkipPoint(); + m_controls->SetAutoPan( false ); + m_controls->CaptureCursor( false ); + }; if( evt->IsCancelInteractive()) { @@ -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; } diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index 602bdd7773..c297bd798c 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -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; } diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 5e97090179..7a32ae0db9 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -802,25 +802,26 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) if( reselect && fp ) m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, fp ); - auto cleanup = [&] () - { - m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - commit.Revert(); - - if( fromOtherCommand ) - { - PICKED_ITEMS_LIST* undo = m_frame->PopCommandFromUndoList(); - - if( undo ) + auto cleanup = + [&] () { - m_frame->PutDataInPreviousState( undo, false ); - undo->ClearListAndDeleteItems(); - delete undo; - } - } + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + commit.Revert(); - 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() ) { @@ -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; } diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index 1d9a756306..9f984f919b 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -247,6 +247,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool, } view()->Remove( &preview ); + frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW ); } diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index 9ac141216f..c93a45b440 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -238,13 +238,13 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) controls.ForceCursorPosition(true, cursorPos ); auto clearRuler = - [&] () - { - view.SetVisible( &ruler, false ); - controls.SetAutoPan( false ); - controls.CaptureCursor( false ); - originSet = false; - }; + [&] () + { + view.SetVisible( &ruler, false ); + controls.SetAutoPan( false ); + controls.CaptureCursor( false ); + originSet = false; + }; if( evt->IsCancelInteractive() ) { @@ -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; }