diff --git a/src/canvas.C b/src/canvas.C index f2eade8..c87484c 100644 --- a/src/canvas.C +++ b/src/canvas.C @@ -109,7 +109,7 @@ Canvas::grid ( Grid *g ) resize_grid(); - changed_mapping(); + update_mapping(); m.shape = m.grid->draw_shape(); @@ -152,16 +152,14 @@ Canvas::_update_row_mapping ( void ) m.vp->h = min( m.vp->h, m.maxh ); } -/** change grid mapping */ +/** update everything about mapping, leaving the viewport alone */ void -Canvas::changed_mapping ( void ) +Canvas::update_mapping ( void ) { _update_row_mapping(); m.mapping_drawn = false; - m.vp->y = (m.maxh / 2) - (m.vp->h / 2); - resize(); int old_margin = m.margin_left; @@ -181,6 +179,18 @@ Canvas::changed_mapping ( void ) signal_draw(); } +/** change grid mapping */ +void +Canvas::changed_mapping ( void ) +{ + update_mapping(); + + m.vp->h = min( m.vp->h, m.maxh ); + + if ( m.vp->y + m.vp->h > m.maxh ) + m.vp->y = (m.maxh / 2) - (m.vp->h / 2); +} + Grid * Canvas::grid ( void ) { diff --git a/src/canvas.H b/src/canvas.H index 1f6d636..9289a0f 100644 --- a/src/canvas.H +++ b/src/canvas.H @@ -109,6 +109,8 @@ class Canvas : public trackable bool viewable_x ( int x ); void draw_line ( int x, int flags ); + void update_mapping ( void ); + public: enum { OFF, ON, TOGGLE };