Fix offset issue when moving text.

This commit is contained in:
Jeff Young 2018-09-09 10:57:36 +01:00
parent d9d2822fe0
commit e2ea9b772a
4 changed files with 14 additions and 19 deletions

View File

@ -1108,27 +1108,22 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const 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(); VECTOR2I cursor = GetGalCanvas()->GetViewControls()->GetCursorPosition();
return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y ); return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y );
}
else
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCrossHairPosition( aInvertY );
}
} }
void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid ) 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 BASE_SCREEN* screen = GetScreen(); // virtual call
screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid ); screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
wxPoint snappedPosition = screen->getCrossHairPosition( false );
GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( snappedPosition, false );
} }

View File

@ -459,10 +459,8 @@ void WX_VIEW_CONTROLS::SetCrossHairCursorPosition( const VECTOR2D& aPosition, bo
BOX2I screen( VECTOR2I( 0, 0 ), screenSize ); BOX2I screen( VECTOR2I( 0, 0 ), screenSize );
VECTOR2D screenPos = m_view->ToScreen( aPosition ); VECTOR2D screenPos = m_view->ToScreen( aPosition );
if( !screen.Contains( screenPos ) ) if( aWarpView && !screen.Contains( screenPos ) )
{
m_view->SetCenter( aPosition ); m_view->SetCenter( aPosition );
}
m_cursorPos = aPosition; m_cursorPos = aPosition;
} }

View File

@ -387,7 +387,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
} }
// Calling the general function on mouse changes (and pseudo key commands) // 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 : */ /* 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 ); EDA_DRAW_PANEL_GAL::Refresh( aEraseBackground, aRect );
} }
void SCH_DRAW_PANEL::OnCharHook( wxKeyEvent& event ) void SCH_DRAW_PANEL::OnCharHook( wxKeyEvent& event )
{ {
event.Skip(); event.Skip();
@ -673,6 +674,7 @@ void SCH_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
event.Skip(); event.Skip();
} }
void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent ) void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent )
{ {
if( m_painter ) if( m_painter )

View File

@ -785,7 +785,7 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
// (for instance large hierarchical sheets od componants can have // (for instance large hierarchical sheets od componants can have
// the anchor position outside the canvas) // the anchor position outside the canvas)
// these items return IsMovableFromAnchorPoint() == false // these items return IsMovableFromAnchorPoint() == false
// For these items, do not wrap the cursor // For these items, do not warp the cursor
if( aItem->IsMovableFromAnchorPoint() ) if( aItem->IsMovableFromAnchorPoint() )
{ {
SetCrossHairPosition( aItem->GetPosition() ); SetCrossHairPosition( aItem->GetPosition() );