figure maxCellSize and pass to jni; call after doing layout to

correctly get whether zooming is possible.
This commit is contained in:
eehouse 2010-06-02 04:59:34 +00:00
parent 048e854d4e
commit 68bf571f26
3 changed files with 10 additions and 5 deletions

View file

@ -28,5 +28,5 @@ public class BoardDims {
public int scoreHt; public int scoreHt;
public int boardHt; public int boardHt;
public int trayTop, trayHt; public int trayTop, trayHt;
public int cellSize; public int cellSize, maxCellSize;
} }

View file

@ -239,14 +239,16 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
int nCells = gi.boardSize; int nCells = gi.boardSize;
int cellSize = width / nCells; int cellSize = width / nCells;
int maxHt = 3 * m_defaultFontHt; int maxCellSize = 3 * m_defaultFontHt;
if ( cellSize > maxHt ) { if ( cellSize > maxCellSize ) {
cellSize = maxHt; cellSize = maxCellSize;
int boardWidth = nCells * cellSize; int boardWidth = nCells * cellSize;
result.left = (width - boardWidth) / 2; result.left = (width - boardWidth) / 2;
result.width = boardWidth; result.width = boardWidth;
} }
result.maxCellSize = maxCellSize;
result.trayHt = cellSize * 3; result.trayHt = cellSize * 3;
result.scoreHt = 2 * m_defaultFontHt; result.scoreHt = 2 * m_defaultFontHt;
int wantHt = result.trayHt + result.scoreHt + (cellSize * nCells); int wantHt = result.trayHt + result.scoreHt + (cellSize * nCells);

View file

@ -169,7 +169,8 @@ public class JNIThread extends Thread {
dims.scoreHt, true ); dims.scoreHt, true );
XwJNI.board_setPos( m_jniGamePtr, 0, dims.scoreHt, XwJNI.board_setPos( m_jniGamePtr, 0, dims.scoreHt,
dims.width-1, dims.boardHt, false ); dims.width-1, dims.boardHt, dims.maxCellSize,
false );
XwJNI.board_setTrayLoc( m_jniGamePtr, 0, dims.trayTop, XwJNI.board_setTrayLoc( m_jniGamePtr, 0, dims.trayTop,
dims.width-1, dims.trayHt, kMinDivWidth ); dims.width-1, dims.trayHt, kMinDivWidth );
@ -264,6 +265,8 @@ public class JNIThread extends Thread {
case CMD_LAYOUT: case CMD_LAYOUT:
doLayout( (BoardDims)args[0] ); doLayout( (BoardDims)args[0] );
draw = true; draw = true;
// check and disable zoom button at limit
handle( JNICmd.CMD_ZOOM, 0 );
break; break;
case CMD_START: case CMD_START: