Commit 38ea6008 authored by lajos kamocsay's avatar lajos kamocsay Committed by jean-pierre charras
Browse files

Fix small issue when panning with middle button.

parent b4bb924e
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -338,6 +338,9 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
    GetClientSize( &csizeX, &csizeY );
    GetClientSize( &csizeX, &csizeY );
    GetVirtualSize( &unitsX, &unitsY );
    GetVirtualSize( &unitsX, &unitsY );


    int tmpX = x;
    int tmpY = y;

    csizeX /= ppux;
    csizeX /= ppux;
    csizeY /= ppuy;
    csizeY /= ppuy;


@@ -399,6 +402,13 @@ void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event )
                wxT( "Setting scroll bars ppuX=%d, ppuY=%d, unitsX=%d, unitsY=%d, posX=%d, posY=%d" ),
                wxT( "Setting scroll bars ppuX=%d, ppuY=%d, unitsX=%d, unitsY=%d, posX=%d, posY=%d" ),
                ppux, ppuy, unitsX, unitsY, x, y );
                ppux, ppuy, unitsX, unitsY, x, y );


    double scale = GetParent()->GetScreen()->GetScalingFactor();

    wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
    center.x += wxRound( (double) ( x - tmpX ) / scale );
    center.y += wxRound( (double) ( y - tmpY ) / scale );
    GetParent()->GetScreen()->SetScrollCenterPosition( center );

    Scroll( x, y );
    Scroll( x, y );
    event.Skip();
    event.Skip();
}
}
@@ -1007,11 +1017,13 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
        if( m_panScrollbarLimits )
        if( m_panScrollbarLimits )
        {
        {
            int x, y;
            int x, y;
            int tmpX, tmpY;
            int ppux, ppuy;
            int ppux, ppuy;
            int maxX, maxY;
            int maxX, maxY;
            int vsizeX, vsizeY;
            int vsizeX, vsizeY;
            int csizeX, csizeY;
            int csizeX, csizeY;


            GetViewStart( &tmpX, &tmpY );
            GetScrollPixelsPerUnit( &ppux, &ppuy );
            GetScrollPixelsPerUnit( &ppux, &ppuy );
            GetVirtualSize( &vsizeX, &vsizeY );
            GetVirtualSize( &vsizeX, &vsizeY );
            GetClientSize( &csizeX, &csizeY );
            GetClientSize( &csizeX, &csizeY );
@@ -1057,6 +1069,13 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )


            Scroll( x/ppux, y/ppuy );
            Scroll( x/ppux, y/ppuy );


            double scale = GetParent()->GetScreen()->GetScalingFactor();

            wxPoint center = GetParent()->GetScreen()->GetScrollCenterPosition();
            center.x += wxRound( (double) ( x - tmpX ) / scale ) / ppux;
            center.y += wxRound( (double) ( y - tmpY ) / scale ) / ppuy;
            GetParent()->GetScreen()->SetScrollCenterPosition( center );

            Refresh();
            Refresh();
            Update();
            Update();
        }
        }