Don't always clobber the viewport Y when changing canvas grid.

This commit is contained in:
Jonathan Moore Liles 2008-06-15 12:45:57 -05:00
parent c71283fb85
commit 81f504f88b
2 changed files with 17 additions and 5 deletions

View File

@ -109,7 +109,7 @@ Canvas::grid ( Grid *g )
resize_grid(); resize_grid();
changed_mapping(); update_mapping();
m.shape = m.grid->draw_shape(); m.shape = m.grid->draw_shape();
@ -152,16 +152,14 @@ Canvas::_update_row_mapping ( void )
m.vp->h = min( m.vp->h, m.maxh ); m.vp->h = min( m.vp->h, m.maxh );
} }
/** change grid mapping */ /** update everything about mapping, leaving the viewport alone */
void void
Canvas::changed_mapping ( void ) Canvas::update_mapping ( void )
{ {
_update_row_mapping(); _update_row_mapping();
m.mapping_drawn = false; m.mapping_drawn = false;
m.vp->y = (m.maxh / 2) - (m.vp->h / 2);
resize(); resize();
int old_margin = m.margin_left; int old_margin = m.margin_left;
@ -181,6 +179,18 @@ Canvas::changed_mapping ( void )
signal_draw(); 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 * Grid *
Canvas::grid ( void ) Canvas::grid ( void )
{ {

View File

@ -109,6 +109,8 @@ class Canvas : public trackable
bool viewable_x ( int x ); bool viewable_x ( int x );
void draw_line ( int x, int flags ); void draw_line ( int x, int flags );
void update_mapping ( void );
public: public:
enum { OFF, ON, TOGGLE }; enum { OFF, ON, TOGGLE };