diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 3540a8b7bd..ac3536f8e4 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -350,9 +350,15 @@ void TOOL_MANAGER::CancelTool() void TOOL_MANAGER::PrimeTool( const VECTOR2D& aPosition ) { int modifiers = 0; - modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0; - modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0; - modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0; + + /* + * Don't include any modifiers. They're part of the hotkey, not part of the resulting + * click. + * + * modifiers |= wxGetKeyState( WXK_SHIFT ) ? MD_SHIFT : 0; + * modifiers |= wxGetKeyState( WXK_CONTROL ) ? MD_CTRL : 0; + * modifiers |= wxGetKeyState( WXK_ALT ) ? MD_ALT : 0; + */ TOOL_EVENT evt( TC_MOUSE, TA_PRIME, BUT_LEFT | modifiers ); evt.SetMousePosition( aPosition ); diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 38085a7c34..65cc84fd46 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -187,7 +187,7 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent ) } else if( !aEvent.IsReactivate() ) { - m_toolMgr->RunAction( EE_ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); } // Main loop: keep receiving events @@ -430,7 +430,7 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent ) if( image ) m_toolMgr->RunAction( ACTIONS::refreshPreview ); else if( !aEvent.IsReactivate() ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) @@ -701,7 +701,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) // Prime the pump if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); else m_toolMgr->RunAction( ACTIONS::refreshPreview ); @@ -1106,16 +1106,12 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if the tool isn't being re-activated if( aEvent.HasPosition() ) { m_toolMgr->PrimeTool( aEvent.Position() ); } - else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() && ( isText - || isGlobalLabel - || isHierLabel - || isClassLabel - || isNetLabel ) ) + else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() + && ( isText || isGlobalLabel || isHierLabel || isClassLabel || isNetLabel ) ) { m_toolMgr->PrimeTool( { 0, 0 } ); ignorePrimePosition = true; @@ -1416,9 +1412,8 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( aEvent.HasPosition() ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) @@ -1583,9 +1578,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( aEvent.HasPosition() ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index cd774f4afc..04d4b5bbd8 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -111,7 +111,6 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( aEvent.HasPosition() ) { m_toolMgr->PrimeTool( aEvent.Position() ); @@ -336,9 +335,8 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( aEvent.HasPosition() ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index 6f75bbcc70..74895b6d36 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -101,9 +101,8 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( aEvent.HasPosition() || ( !aEvent.IsReactivate() && isText ) ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) @@ -248,9 +247,8 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( aEvent.HasPosition() ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index f55223854b..4c336a913a 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1382,9 +1382,8 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent ) m_router->SetMode( mode ); m_cancelled = false; - // Prime the pump if( aEvent.HasPosition() ) - m_toolMgr->PrimeTool( controls->GetCursorPosition( false ) ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index 12587dc466..2676faafcb 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -1032,7 +1032,7 @@ int BOARD_EDITOR_CONTROL::PlaceFootprint( const TOOL_EVENT& aEvent ) } else if( !aEvent.IsReactivate() ) { - m_toolMgr->RunAction( PCB_ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); } // Main loop: keep receiving events diff --git a/pcbnew/tools/drawing_stackup_table_tool.cpp b/pcbnew/tools/drawing_stackup_table_tool.cpp index db3fba6902..a94241da58 100644 --- a/pcbnew/tools/drawing_stackup_table_tool.cpp +++ b/pcbnew/tools/drawing_stackup_table_tool.cpp @@ -577,9 +577,8 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent, // Must be done after Activate() so that it gets set into the correct context m_controls->ShowCursor( true ); - // Prime the pump if( aEvent.HasPosition() ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events wxPoint wxCursorPosition = wxPoint(); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index a08dd66506..282230ca75 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -450,6 +450,7 @@ int DRAWING_TOOL::DrawCircle( const TOOL_EVENT& aEvent ) circle->SetShape( SHAPE_T::CIRCLE ); circle->SetFilled( false ); circle->SetFlags( IS_NEW ); + startingPoint = NULLOPT; } @@ -471,7 +472,7 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent ) PCB_SHAPE* arc = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE; BOARD_COMMIT commit( m_frame ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC ); - bool immediateMode = aEvent.HasPosition(); + OPT startingPoint = boost::make_optional( false, { 0, 0 } ); arc->SetShape( SHAPE_T::ARC ); arc->SetFlags( IS_NEW ); @@ -480,7 +481,10 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent ) m_frame->PushTool( tool ); Activate(); - while( drawArc( tool, &arc, immediateMode ) ) + if( aEvent.HasPosition() ) + startingPoint = aEvent.Position(); + + while( drawArc( tool, &arc, startingPoint ) ) { if( arc ) { @@ -496,7 +500,8 @@ int DRAWING_TOOL::DrawArc( const TOOL_EVENT& aEvent ) arc = m_isFootprintEditor ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE; arc->SetShape( SHAPE_T::ARC ); arc->SetFlags( IS_NEW ); - immediateMode = false; + + startingPoint = NULLOPT; } return 0; @@ -554,9 +559,8 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( !aEvent.IsReactivate() ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aEvent.Position() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) @@ -826,7 +830,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump m_toolMgr->RunAction( ACTIONS::refreshPreview ); if( aEvent.HasPosition() ) @@ -1553,11 +1556,10 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, PCB_SHAPE** aGraphic, // Set initial cursor setCursor(); - // Prime the pump m_toolMgr->RunAction( ACTIONS::refreshPreview ); if( aStartingPoint ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + m_toolMgr->PrimeTool( aStartingPoint.get() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) @@ -1831,7 +1833,8 @@ static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER } -bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool aImmediateMode ) +bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, + OPT aStartingPoint ) { PCB_SHAPE*& graphic = *aGraphic; @@ -1877,11 +1880,10 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool bool firstPoint = false; bool cancelled = false; - // Prime the pump m_toolMgr->RunAction( ACTIONS::refreshPreview ); - if( aImmediateMode ) - m_toolMgr->RunAction( ACTIONS::cursorClick ); + if( aStartingPoint ) + m_toolMgr->PrimeTool(aStartingPoint.get() ); // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) @@ -2203,7 +2205,6 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); - // Prime the pump if( aEvent.HasPosition() ) m_toolMgr->PrimeTool( aEvent.Position() ); diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index e689c2fcd3..e24a19176c 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -231,7 +231,7 @@ private: * @return False if the tool was canceled before the origin was set or origin and end are * the same point. */ - bool drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, bool aImmediateMode ); + bool drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, OPT aStartingPoint ); /** * Draw a polygon, that is added as a zone or a keepout area.