don't zoom in if doing so will make cells larger than the limit passed

in.
This commit is contained in:
eehouse 2010-06-03 04:57:11 +00:00
parent 43181f5cd2
commit 628f8d9cf3
2 changed files with 14 additions and 4 deletions

View file

@ -360,7 +360,7 @@ board_reset( BoardCtxt* board )
void
board_setPos( BoardCtxt* board, XP_U16 left, XP_U16 top,
XP_U16 width, XP_U16 height, XP_U16 maxWidth,
XP_U16 width, XP_U16 height, XP_U16 maxCellSz,
XP_Bool leftHanded )
{
XP_LOGF( "%s(%d,%d,%d,%d)", __func__, left, top, width, height );
@ -369,7 +369,7 @@ board_setPos( BoardCtxt* board, XP_U16 left, XP_U16 top,
board->boardBounds.top = top;
board->boardBounds.width = width;
board->heightAsSet = height;
board->maxWidth = maxWidth;
board->maxCellSz = maxCellSz;
board->leftHanded = leftHanded;
figureBoardRect( board );
@ -556,6 +556,16 @@ board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canIn, XP_Bool* canOut )
}
changed = zoomCount != board->zoomCount;
/* If we're zooming in, make sure we'll stay inside the limit */
if ( changed && zoomBy > 0 ) {
XP_U16 nVisCols = model_numCols( board->model ) - zoomCount;
XP_U16 scale = board->boardBounds.width / nVisCols;
if ( scale > board->maxCellSz ) {
changed = XP_FALSE;
}
}
if ( changed ) {
/* Try to distribute the zoom */
hsd->offset = adjustOffset( hsd->offset, zoomBy );
@ -567,7 +577,7 @@ board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canIn, XP_Bool* canOut )
}
if ( !!canIn ) {
*canIn = maxCount > zoomCount && hsd->scale < board->maxWidth;
*canIn = maxCount > zoomCount && hsd->scale < board->maxCellSz;
}
if ( !!canOut ) {
*canOut = zoomCount > 0;

View file

@ -151,7 +151,7 @@ struct BoardCtxt {
XP_Rect boardBounds;
XP_U16 heightAsSet;
XP_U16 maxWidth;
XP_U16 maxCellSz;
BoardObjectType penDownObject;