Commit 07bd76a0 authored by stambaughw's avatar stambaughw
Browse files

Zoom bug fix and optimization.

Prevent drawing center from moving when client zoom size exceeds drawing size.
Prevent drawing refresh when zoom level doesn't change to eliminate flicker.
parent c6f68578
Loading
Loading
Loading
Loading
+34 −17
Original line number Diff line number Diff line
@@ -69,10 +69,6 @@ void BASE_SCREEN::InitDatas()
        m_Curseur.y = ReturnPageSize().y / 2;
    }

    // DrawOrg est rendu multiple du zoom min :
    m_DrawOrg.x -= m_DrawOrg.x % 256;
    m_DrawOrg.y -= m_DrawOrg.y % 256;

    m_O_Curseur = m_Curseur;

    SetCurItem( NULL );
@@ -230,12 +226,23 @@ void BASE_SCREEN::SetZoomList( const wxArrayInt& zoomlist )
}


void BASE_SCREEN::SetFirstZoom()
bool BASE_SCREEN::SetFirstZoom()
{
    if( m_ZoomList.IsEmpty() )
    {
        if( m_Zoom != m_ZoomScalar )
        {
            m_Zoom = m_ZoomScalar;
    else
            return true;
        }
    }
    else if( m_Zoom != m_ZoomList[0] )
    {
        m_Zoom = m_ZoomList[0];
        return true;
    }

    return false;
}


@@ -245,57 +252,67 @@ int BASE_SCREEN::GetZoom() const
}


void BASE_SCREEN::SetZoom( int coeff )
bool BASE_SCREEN::SetZoom( int coeff )
{
    if( coeff == m_Zoom )
        return false;

    m_Zoom = coeff;

    if( m_Zoom < 1 )
        m_Zoom = 1;

    return true;
}


void BASE_SCREEN::SetNextZoom()
bool BASE_SCREEN::SetNextZoom()
{
    size_t i;

    if( m_ZoomList.IsEmpty() || m_Zoom >= m_ZoomList.Last() )
        return;
        return false;

    for( i = 0; i < m_ZoomList.GetCount(); i++ )
    {
        if( m_Zoom < m_ZoomList[i] )
        {
            m_Zoom = m_ZoomList[i];
            break;
            return true;
        }
    }

    return false;
}


void BASE_SCREEN::SetPreviousZoom()
bool BASE_SCREEN::SetPreviousZoom()
{
    size_t i;

    if( m_ZoomList.IsEmpty() || m_Zoom <= m_ZoomList[0] )
        return;
        return false;

    for( i = m_ZoomList.GetCount(); i != 0; i-- )
    {
        if( m_Zoom > m_ZoomList[i - 1] )
        {
            m_Zoom = m_ZoomList[i - 1];
            break;
            return true;
        }
    }

    return false;
}


void BASE_SCREEN::SetLastZoom()
bool BASE_SCREEN::SetLastZoom()
{
    if( m_ZoomList.IsEmpty() )
        return;
    if( m_ZoomList.IsEmpty() || m_Zoom == m_ZoomList.Last() )
        return false;

    m_Zoom = m_ZoomList.Last();
    return true;
}


+6 −5
Original line number Diff line number Diff line
@@ -584,8 +584,13 @@ void WinEDA_DrawFrame::AdjustScrollBars()
    // la surface de trace doit etre augmentee
    panel_size = DrawPanel->GetClientSize();
    screen->Unscale( panel_size );
    draw_size += panel_size / 2;

    /* Adjust drawing size when zooming way out to prevent centering around
     * cursor problems. */
    if( panel_size.x > draw_size.x || panel_size.y > draw_size.y )
        draw_size = panel_size;

    draw_size += panel_size / 2;

    if( screen->m_Center )
    {
@@ -598,10 +603,6 @@ void WinEDA_DrawFrame::AdjustScrollBars()
        screen->m_DrawOrg.y = -panel_size.y / 2;
    }

    // DrawOrg est rendu multiple du zoom min :
    screen->m_DrawOrg.x -= screen->m_DrawOrg.x % 256;
    screen->m_DrawOrg.y -= screen->m_DrawOrg.y % 256;

    // Calcul du nombre de scrolls  (en unites de scrool )
    scrollbar_number = draw_size / screen->Unscale( screen->m_ZoomScalar );
    xUnit = yUnit = screen->m_ZoomScalar;
+8 −8
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ void WinEDA_DrawFrame::Zoom_Automatique( bool move_mouse_cursor )
/** Redraw the screen with the zoom level which shows all the page or the board
 */
{
    GetBaseScreen()->SetZoom( BestZoom() );
    if( GetBaseScreen()->SetZoom( BestZoom() )
        Recadre_Trace( move_mouse_cursor );
}

@@ -122,7 +122,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
    case ID_ZOOM_IN:
        if( id == ID_ZOOM_IN )
            screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
        screen->SetPreviousZoom();
        if( screen->SetPreviousZoom() )
            Recadre_Trace( zoom_at_cursor );
        break;

@@ -133,7 +133,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
    case ID_ZOOM_OUT:
        if( id == ID_ZOOM_OUT )
            screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition();
        screen->SetNextZoom();
        if( screen->SetNextZoom() )
            Recadre_Trace( zoom_at_cursor );
        break;

@@ -170,7 +170,7 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event )
                            "the zoom list." ), i );
            return;
        }
        screen->SetZoom( screen->m_ZoomList[i] );
        if( screen->SetZoom( screen->m_ZoomList[i] ) )
            Recadre_Trace( true );
    }

+5 −5
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public:
     * Function SetZoom
     * adjusts the current zoom factor
     */
    void   SetZoom( int coeff );
    bool   SetZoom( int coeff );

    /**
     * Function SetZoomList
@@ -246,10 +246,10 @@ public:
    void   Unscale( wxPoint& pt );
    void   Unscale( wxSize& sz );

    void   SetNextZoom();                   /* ajuste le prochain coeff de zoom */
    void   SetPreviousZoom();               /* ajuste le precedent coeff de zoom */
    void   SetFirstZoom();                  /* ajuste le coeff de zoom a 1*/
    void   SetLastZoom();                   /* ajuste le coeff de zoom au max */
    bool   SetNextZoom();               /* ajuste le prochain coeff de zoom */
    bool   SetPreviousZoom();           /* ajuste le precedent coeff de zoom */
    bool   SetFirstZoom();              /* ajuste le coeff de zoom a 1*/
    bool   SetLastZoom();               /* ajuste le coeff de zoom au max */

    //----<grid stuff>----------------------------------------------------------
    wxRealPoint GetGrid();                      /* retourne la grille */