diff --git a/common/base_screen.cpp b/common/base_screen.cpp index c60dadce28..764b054424 100644 --- a/common/base_screen.cpp +++ b/common/base_screen.cpp @@ -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() ) - m_Zoom = m_ZoomScalar; - else + { + if( m_Zoom != m_ZoomScalar ) + { + m_Zoom = m_ZoomScalar; + 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; } diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 585513b5f6..eaee5f3fbe 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -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; diff --git a/common/zoom.cpp b/common/zoom.cpp index db93f9aaf9..e47a939f4a 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -67,8 +67,8 @@ 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() ); - Recadre_Trace( move_mouse_cursor ); + if( GetBaseScreen()->SetZoom( BestZoom() ) + Recadre_Trace( move_mouse_cursor ); } @@ -122,8 +122,8 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) case ID_ZOOM_IN: if( id == ID_ZOOM_IN ) screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); - screen->SetPreviousZoom(); - Recadre_Trace( zoom_at_cursor ); + if( screen->SetPreviousZoom() ) + Recadre_Trace( zoom_at_cursor ); break; case ID_POPUP_ZOOM_OUT: @@ -133,8 +133,8 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) case ID_ZOOM_OUT: if( id == ID_ZOOM_OUT ) screen->m_Curseur = DrawPanel->GetScreenCenterRealPosition(); - screen->SetNextZoom(); - Recadre_Trace( zoom_at_cursor ); + if( screen->SetNextZoom() ) + Recadre_Trace( zoom_at_cursor ); break; case ID_ZOOM_REDRAW: @@ -170,8 +170,8 @@ void WinEDA_DrawFrame::OnZoom( wxCommandEvent& event ) "the zoom list." ), i ); return; } - screen->SetZoom( screen->m_ZoomList[i] ); - Recadre_Trace( true ); + if( screen->SetZoom( screen->m_ZoomList[i] ) ) + Recadre_Trace( true ); } Affiche_Status_Box(); diff --git a/include/class_base_screen.h b/include/class_base_screen.h index 1ece0e103b..ab4b7e7d3e 100644 --- a/include/class_base_screen.h +++ b/include/class_base_screen.h @@ -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 */ //-------------------------------------------------------------- wxRealPoint GetGrid(); /* retourne la grille */