center board when it must be narrower than screen

This commit is contained in:
Eric House 2013-11-15 20:46:22 -08:00
parent c0f6f6a959
commit 088dd1bd75
4 changed files with 16 additions and 9 deletions

View file

@ -166,6 +166,7 @@ static const SetInfo bd_ints[] = {
,ARR_MEMBER( BoardDims, height )
,ARR_MEMBER( BoardDims, scoreHt )
,ARR_MEMBER( BoardDims, scoreWidth )
,ARR_MEMBER( BoardDims, boardWidth )
,ARR_MEMBER( BoardDims, boardHt )
,ARR_MEMBER( BoardDims, trayTop )
,ARR_MEMBER( BoardDims, trayHt )

View file

@ -26,7 +26,7 @@ public class BoardDims {
public int left, top;
public int width, height; // of the bitmap
public int scoreWidth, scoreHt;
public int boardHt;
public int boardWidth, boardHt;
public int trayTop, trayHt;
public int cellSize, maxCellSize;
public int timerWidth;

View file

@ -410,14 +410,14 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
ldims.left = bLeft;
ldims.top = bTop;
ldims.width = bWidth;
ldims.boardWidth = bWidth;
for ( firstPass = XP_TRUE; ; ) {
ldims.width = bWidth;
XP_U16 cellSize = bWidth / nCells;
XP_U16 cellSize = ldims.boardWidth / nCells;
if ( cellSize > maxCellSize ) {
cellSize = maxCellSize;
ldims.width = nCells * cellSize;
ldims.boardWidth = nCells * cellSize;
}
ldims.maxCellSize = maxCellSize;
@ -437,7 +437,7 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
int cellWidth = 2 * (bHeight / ( 4 + 3 + (2*nCells)));
if ( firstPass && cellWidth >= fontHt ) {
firstPass = XP_FALSE;
bWidth = nCells * cellWidth;
ldims.boardWidth = nCells * cellWidth;
continue;
} else {
nToScroll = nCells -
@ -491,8 +491,9 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
void
board_applyLayout( BoardCtxt* board, const BoardDims* dims )
{
board_setPos( board, dims->left, dims->top + dims->scoreHt,
dims->width, dims->top + dims->scoreHt + dims->boardHt,
XP_U16 margin = (dims->width - dims->boardWidth) / 2;
board_setPos( board, dims->left + margin, dims->top + dims->scoreHt,
dims->boardWidth, dims->top + dims->scoreHt + dims->boardHt,
dims->maxCellSize, XP_FALSE );
board_setScoreboardLoc( board, dims->left, dims->top,

View file

@ -76,11 +76,16 @@ void board_reset( BoardCtxt* board );
#ifdef COMMON_LAYOUT
typedef struct _BoardDims {
/* The whole board */
XP_U16 left, top;
XP_U16 width, height;
/* scoreboard (full width) */
XP_U16 scoreWidth, scoreHt;
XP_U16 boardHt;
/* board */
XP_U16 boardWidth, boardHt;
/* tray (full width) */
XP_U16 trayTop, trayHt;
/* other */
XP_U16 cellSize, maxCellSize;
XP_U16 timerWidth;
} BoardDims;