diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index 332f287101..fa4fbb50fd 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -1108,27 +1108,22 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const { - - // subject to change, borrow from old BASE_SCREEN for now. - if( IsGalCanvasActive() ) - { - VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition(); - - - return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y ); - } - else - { - BASE_SCREEN* screen = GetScreen(); // virtual call - return screen->getCrossHairPosition( aInvertY ); - } + VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition(); + return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y ); } void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid ) { + // While we're now a GAL canvas, we still have a pre-GAL toolset so some code is going + // to look for the crosshair position in the BASE_SCREEN and some code is going to look + // for it in the VIEW_CONTROLS. Better set it in both. + BASE_SCREEN* screen = GetScreen(); // virtual call screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid ); + + wxPoint snappedPosition = screen->getCrossHairPosition( false ); + GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( snappedPosition, false ); } diff --git a/common/view/wx_view_controls.cpp b/common/view/wx_view_controls.cpp index 2eff2af7a0..81e0e5752e 100644 --- a/common/view/wx_view_controls.cpp +++ b/common/view/wx_view_controls.cpp @@ -459,10 +459,8 @@ void WX_VIEW_CONTROLS::SetCrossHairCursorPosition( const VECTOR2D& aPosition, bo BOX2I screen( VECTOR2I( 0, 0 ), screenSize ); VECTOR2D screenPos = m_view->ToScreen( aPosition ); - if( !screen.Contains( screenPos ) ) - { + if( aWarpView && !screen.Contains( screenPos ) ) m_view->SetCenter( aPosition ); - } m_cursorPos = aPosition; } diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index a11edb8f90..348f54ca25 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -387,7 +387,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event ) } // Calling the general function on mouse changes (and pseudo key commands) - GetParent()->GeneralControl( nullptr, wxPoint(0, 0), /*event.GetLogicalPosition( DC )*/ 0 ); + GetParent()->GeneralControl( nullptr, mousePos ); /*******************************/ /* Control of block commands : */ @@ -604,6 +604,7 @@ void SCH_DRAW_PANEL::Refresh( bool aEraseBackground, const wxRect* aRect ) EDA_DRAW_PANEL_GAL::Refresh( aEraseBackground, aRect ); } + void SCH_DRAW_PANEL::OnCharHook( wxKeyEvent& event ) { event.Skip(); @@ -673,6 +674,7 @@ void SCH_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) event.Skip(); } + void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent ) { if( m_painter ) diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 75470e3159..7f7efb89a3 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -785,7 +785,7 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC ) // (for instance large hierarchical sheets od componants can have // the anchor position outside the canvas) // these items return IsMovableFromAnchorPoint() == false - // For these items, do not wrap the cursor + // For these items, do not warp the cursor if( aItem->IsMovableFromAnchorPoint() ) { SetCrossHairPosition( aItem->GetPosition() );