fix board dimensioning for small (needs-scrolling) screens. Since this

effects larger screens needs some testing.
This commit is contained in:
Eric House 2012-06-05 07:38:58 -07:00 committed by Eric House
parent 00102ec20a
commit d7f576d6b7
2 changed files with 37 additions and 16 deletions

View file

@ -256,24 +256,41 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
}
result.maxCellSize = maxCellSize;
result.trayHt = cellSize * 3;
result.scoreHt = 2 * m_defaultFontHt;
int wantHt = result.trayHt + result.scoreHt + (cellSize * nCells);
int nToScroll = 0;
// Now determine if vertical scrolling will be necessary.
// There's a minimum tray and scoreboard height. If we can
// fit them and all cells no scrolling's needed. Otherwise
// determine the minimum number that must be hidden to fit.
// Finally grow scoreboard and tray to use whatever's left.
int trayHt = (5 * cellSize) / 2;
int scoreHt = (cellSize * 3) / 2;
int wantHt = trayHt + scoreHt + (cellSize * nCells);
int nToScroll;
if ( wantHt <= height ) {
result.top = (height - wantHt) / 2;
nToScroll = 0;
} else {
int minTray = 3 * m_defaultFontHt;
nToScroll =
nCells - ((height - minTray - result.scoreHt) / cellSize);
result.trayHt =
height - result.scoreHt - (cellSize * (nCells-nToScroll));
result.top = 0;
nToScroll = nCells - ((height - trayHt - scoreHt) / cellSize);
}
result.boardHt = cellSize * (nCells-nToScroll);
result.trayTop = result.scoreHt + result.boardHt;
result.height = result.scoreHt + result.boardHt + result.trayHt;
int heightUsed = trayHt + scoreHt + (nCells - nToScroll) * cellSize;
int heightLeft = height - heightUsed;
if ( 0 < heightLeft ) {
if ( heightLeft > (cellSize * 3 / 2) ) {
heightLeft = cellSize * 3 / 2;
}
heightLeft /= 3;
trayHt += heightLeft * 2;
scoreHt += heightLeft;
}
heightUsed = trayHt + scoreHt + ((nCells - nToScroll) * cellSize);
heightLeft = height - heightUsed;
result.top = heightLeft / 2;
result.trayHt = trayHt;
result.scoreHt = scoreHt;
result.boardHt = cellSize * nCells;
result.trayTop = scoreHt + (cellSize * (nCells-nToScroll));
result.height = heightUsed;
result.cellSize = cellSize;
if ( gi.timerEnabled ) {

View file

@ -233,12 +233,16 @@ public class JNIThread extends Thread {
XwJNI.board_setScoreboardLoc( m_jniGamePtr, 0, 0, scoreWidth,
dims.scoreHt, true );
// Have no idea why I was doing -1 below, but it breaks layout
// for small (QVGA) boards. If it needs to be done, do it
// early in figureBoardDims so the calculations that follow
// are consistent.
XwJNI.board_setPos( m_jniGamePtr, 0, dims.scoreHt,
dims.width-1, dims.boardHt, dims.maxCellSize,
dims.width/*-1*/, dims.boardHt, dims.maxCellSize,
false );
XwJNI.board_setTrayLoc( m_jniGamePtr, 0, dims.trayTop,
dims.width-1, dims.trayHt, kMinDivWidth );
dims.width/*-1*/, dims.trayHt, kMinDivWidth );
XwJNI.board_invalAll( m_jniGamePtr );
}