Fix middle mouse panning bug and cross-hair drawing bug. (fixes lp:1462067).
* Update cross-hair position when using mouse wheel to pan. * Add ugly hack when mouse cursor enters canvas to force the cross-hair visibility counter back to zero. There was a bug on Windows when using the middle mouse button to pan and the user released the middle mouse button off of the canvas, the cross-hair would no longer be displayed until the window was closed and reopened.
This commit is contained in:
parent
068b1d035f
commit
49d8b90e0b
|
@ -70,6 +70,7 @@ static const int CURSOR_SIZE = 12; ///< Cursor size in pixels
|
||||||
// Events used by EDA_DRAW_PANEL
|
// Events used by EDA_DRAW_PANEL
|
||||||
BEGIN_EVENT_TABLE( EDA_DRAW_PANEL, wxScrolledWindow )
|
BEGIN_EVENT_TABLE( EDA_DRAW_PANEL, wxScrolledWindow )
|
||||||
EVT_LEAVE_WINDOW( EDA_DRAW_PANEL::OnMouseLeaving )
|
EVT_LEAVE_WINDOW( EDA_DRAW_PANEL::OnMouseLeaving )
|
||||||
|
EVT_ENTER_WINDOW( EDA_DRAW_PANEL::OnMouseEntering )
|
||||||
EVT_MOUSEWHEEL( EDA_DRAW_PANEL::OnMouseWheel )
|
EVT_MOUSEWHEEL( EDA_DRAW_PANEL::OnMouseWheel )
|
||||||
#ifdef USE_OSX_MAGNIFY_EVENT
|
#ifdef USE_OSX_MAGNIFY_EVENT
|
||||||
EVT_MAGNIFY( EDA_DRAW_PANEL::OnMagnify )
|
EVT_MAGNIFY( EDA_DRAW_PANEL::OnMagnify )
|
||||||
|
@ -187,6 +188,7 @@ BASE_SCREEN* EDA_DRAW_PANEL::GetScreen()
|
||||||
return parentFrame->GetScreen();
|
return parentFrame->GetScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxPoint EDA_DRAW_PANEL::ToDeviceXY( const wxPoint& pos )
|
wxPoint EDA_DRAW_PANEL::ToDeviceXY( const wxPoint& pos )
|
||||||
{
|
{
|
||||||
wxPoint ret;
|
wxPoint ret;
|
||||||
|
@ -196,6 +198,7 @@ wxPoint EDA_DRAW_PANEL::ToDeviceXY( const wxPoint& pos )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxPoint EDA_DRAW_PANEL::ToLogicalXY( const wxPoint& pos )
|
wxPoint EDA_DRAW_PANEL::ToLogicalXY( const wxPoint& pos )
|
||||||
{
|
{
|
||||||
wxPoint ret;
|
wxPoint ret;
|
||||||
|
@ -205,6 +208,7 @@ wxPoint EDA_DRAW_PANEL::ToLogicalXY( const wxPoint& pos )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor )
|
void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, EDA_COLOR_T aColor )
|
||||||
{
|
{
|
||||||
if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
|
if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
|
||||||
|
@ -886,6 +890,17 @@ bool EDA_DRAW_PANEL::OnRightClick( wxMouseEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EDA_DRAW_PANEL::OnMouseEntering( wxMouseEvent& aEvent )
|
||||||
|
{
|
||||||
|
// This is an ugly hack that fixes some cross hair display bugs when the mouse leaves the
|
||||||
|
// canvas area during middle button mouse panning.
|
||||||
|
if( m_cursorLevel != 0 )
|
||||||
|
m_cursorLevel = 0;
|
||||||
|
|
||||||
|
aEvent.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event )
|
void EDA_DRAW_PANEL::OnMouseLeaving( wxMouseEvent& event )
|
||||||
{
|
{
|
||||||
if( m_mouseCaptureCallback == NULL ) // No command in progress.
|
if( m_mouseCaptureCallback == NULL ) // No command in progress.
|
||||||
|
@ -1151,6 +1166,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
|
||||||
if( event.MiddleIsDown() && m_enableMiddleButtonPan )
|
if( event.MiddleIsDown() && m_enableMiddleButtonPan )
|
||||||
{
|
{
|
||||||
wxPoint currentPosition = event.GetPosition();
|
wxPoint currentPosition = event.GetPosition();
|
||||||
|
|
||||||
if( m_panScrollbarLimits )
|
if( m_panScrollbarLimits )
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -1201,7 +1217,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
|
||||||
shouldMoveCursor = true;
|
shouldMoveCursor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( shouldMoveCursor )
|
if( shouldMoveCursor )
|
||||||
WarpPointer( currentPosition.x, currentPosition.y );
|
WarpPointer( currentPosition.x, currentPosition.y );
|
||||||
|
|
||||||
Scroll( x/ppux, y/ppuy );
|
Scroll( x/ppux, y/ppuy );
|
||||||
|
@ -1460,15 +1476,21 @@ void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event )
|
||||||
int ppux, ppuy;
|
int ppux, ppuy;
|
||||||
int unitsX, unitsY;
|
int unitsX, unitsY;
|
||||||
int maxX, maxY;
|
int maxX, maxY;
|
||||||
|
int tmpX, tmpY;
|
||||||
|
|
||||||
GetViewStart( &x, &y );
|
GetViewStart( &x, &y );
|
||||||
GetScrollPixelsPerUnit( &ppux, &ppuy );
|
GetScrollPixelsPerUnit( &ppux, &ppuy );
|
||||||
GetVirtualSize( &unitsX, &unitsY );
|
GetVirtualSize( &unitsX, &unitsY );
|
||||||
|
tmpX = x;
|
||||||
|
tmpY = y;
|
||||||
maxX = unitsX;
|
maxX = unitsX;
|
||||||
maxY = unitsY;
|
maxY = unitsY;
|
||||||
unitsX /= ppux;
|
unitsX /= ppux;
|
||||||
unitsY /= ppuy;
|
unitsY /= ppuy;
|
||||||
|
|
||||||
|
wxLogTrace( KICAD_TRACE_COORDS,
|
||||||
|
wxT( "Scroll center position before pan: (%d, %d)" ), tmpX, tmpY );
|
||||||
|
|
||||||
switch( event.GetId() )
|
switch( event.GetId() )
|
||||||
{
|
{
|
||||||
case ID_PAN_UP:
|
case ID_PAN_UP:
|
||||||
|
@ -1491,17 +1513,45 @@ void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event )
|
||||||
wxLogDebug( wxT( "Unknown ID %d in EDA_DRAW_PANEL::OnPan()." ), event.GetId() );
|
wxLogDebug( wxT( "Unknown ID %d in EDA_DRAW_PANEL::OnPan()." ), event.GetId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool updateCenterScrollPos = true;
|
||||||
|
|
||||||
if( x < 0 )
|
if( x < 0 )
|
||||||
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
|
updateCenterScrollPos = false;
|
||||||
|
}
|
||||||
|
|
||||||
if( y < 0 )
|
if( y < 0 )
|
||||||
|
{
|
||||||
y = 0;
|
y = 0;
|
||||||
|
updateCenterScrollPos = false;
|
||||||
|
}
|
||||||
|
|
||||||
if( x > maxX )
|
if( x > maxX )
|
||||||
|
{
|
||||||
x = maxX;
|
x = maxX;
|
||||||
|
updateCenterScrollPos = false;
|
||||||
|
}
|
||||||
|
|
||||||
if( y > maxY )
|
if( y > maxY )
|
||||||
|
{
|
||||||
y = maxY;
|
y = maxY;
|
||||||
|
updateCenterScrollPos = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't update the scroll position beyond the scroll limits.
|
||||||
|
if( updateCenterScrollPos )
|
||||||
|
{
|
||||||
|
double scale = GetParent()->GetScreen()->GetScalingFactor();
|
||||||
|
|
||||||
|
wxPoint center = GetParent()->GetScrollCenterPosition();
|
||||||
|
center.x += KiROUND( (double) ( x - tmpX ) / scale );
|
||||||
|
center.y += KiROUND( (double) ( y - tmpY ) / scale );
|
||||||
|
GetParent()->SetScrollCenterPosition( center );
|
||||||
|
|
||||||
|
wxLogTrace( KICAD_TRACE_COORDS,
|
||||||
|
wxT( "Scroll center position after pan: (%d, %d)" ), center.x, center.y );
|
||||||
|
}
|
||||||
|
|
||||||
Scroll( x/ppux, y/ppuy );
|
Scroll( x/ppux, y/ppuy );
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,6 +267,7 @@ public:
|
||||||
void OnMagnify( wxMouseEvent& event );
|
void OnMagnify( wxMouseEvent& event );
|
||||||
#endif
|
#endif
|
||||||
void OnMouseEvent( wxMouseEvent& event );
|
void OnMouseEvent( wxMouseEvent& event );
|
||||||
|
void OnMouseEntering( wxMouseEvent& aEvent );
|
||||||
void OnMouseLeaving( wxMouseEvent& event );
|
void OnMouseLeaving( wxMouseEvent& event );
|
||||||
void OnKeyEvent( wxKeyEvent& event );
|
void OnKeyEvent( wxKeyEvent& event );
|
||||||
void OnCharHook( wxKeyEvent& event );
|
void OnCharHook( wxKeyEvent& event );
|
||||||
|
|
Loading…
Reference in New Issue