mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-02 06:20:14 +01:00
center board when it must be narrower than screen
This commit is contained in:
parent
c0f6f6a959
commit
088dd1bd75
4 changed files with 16 additions and 9 deletions
|
@ -166,6 +166,7 @@ static const SetInfo bd_ints[] = {
|
||||||
,ARR_MEMBER( BoardDims, height )
|
,ARR_MEMBER( BoardDims, height )
|
||||||
,ARR_MEMBER( BoardDims, scoreHt )
|
,ARR_MEMBER( BoardDims, scoreHt )
|
||||||
,ARR_MEMBER( BoardDims, scoreWidth )
|
,ARR_MEMBER( BoardDims, scoreWidth )
|
||||||
|
,ARR_MEMBER( BoardDims, boardWidth )
|
||||||
,ARR_MEMBER( BoardDims, boardHt )
|
,ARR_MEMBER( BoardDims, boardHt )
|
||||||
,ARR_MEMBER( BoardDims, trayTop )
|
,ARR_MEMBER( BoardDims, trayTop )
|
||||||
,ARR_MEMBER( BoardDims, trayHt )
|
,ARR_MEMBER( BoardDims, trayHt )
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class BoardDims {
|
||||||
public int left, top;
|
public int left, top;
|
||||||
public int width, height; // of the bitmap
|
public int width, height; // of the bitmap
|
||||||
public int scoreWidth, scoreHt;
|
public int scoreWidth, scoreHt;
|
||||||
public int boardHt;
|
public int boardWidth, boardHt;
|
||||||
public int trayTop, trayHt;
|
public int trayTop, trayHt;
|
||||||
public int cellSize, maxCellSize;
|
public int cellSize, maxCellSize;
|
||||||
public int timerWidth;
|
public int timerWidth;
|
||||||
|
|
|
@ -410,14 +410,14 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
|
||||||
|
|
||||||
ldims.left = bLeft;
|
ldims.left = bLeft;
|
||||||
ldims.top = bTop;
|
ldims.top = bTop;
|
||||||
|
|
||||||
for ( firstPass = XP_TRUE; ; ) {
|
|
||||||
ldims.width = bWidth;
|
ldims.width = bWidth;
|
||||||
|
|
||||||
XP_U16 cellSize = bWidth / nCells;
|
ldims.boardWidth = bWidth;
|
||||||
|
for ( firstPass = XP_TRUE; ; ) {
|
||||||
|
XP_U16 cellSize = ldims.boardWidth / nCells;
|
||||||
if ( cellSize > maxCellSize ) {
|
if ( cellSize > maxCellSize ) {
|
||||||
cellSize = maxCellSize;
|
cellSize = maxCellSize;
|
||||||
ldims.width = nCells * cellSize;
|
ldims.boardWidth = nCells * cellSize;
|
||||||
}
|
}
|
||||||
ldims.maxCellSize = maxCellSize;
|
ldims.maxCellSize = maxCellSize;
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
|
||||||
int cellWidth = 2 * (bHeight / ( 4 + 3 + (2*nCells)));
|
int cellWidth = 2 * (bHeight / ( 4 + 3 + (2*nCells)));
|
||||||
if ( firstPass && cellWidth >= fontHt ) {
|
if ( firstPass && cellWidth >= fontHt ) {
|
||||||
firstPass = XP_FALSE;
|
firstPass = XP_FALSE;
|
||||||
bWidth = nCells * cellWidth;
|
ldims.boardWidth = nCells * cellWidth;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
nToScroll = nCells -
|
nToScroll = nCells -
|
||||||
|
@ -491,8 +491,9 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
|
||||||
void
|
void
|
||||||
board_applyLayout( BoardCtxt* board, const BoardDims* dims )
|
board_applyLayout( BoardCtxt* board, const BoardDims* dims )
|
||||||
{
|
{
|
||||||
board_setPos( board, dims->left, dims->top + dims->scoreHt,
|
XP_U16 margin = (dims->width - dims->boardWidth) / 2;
|
||||||
dims->width, dims->top + dims->scoreHt + dims->boardHt,
|
board_setPos( board, dims->left + margin, dims->top + dims->scoreHt,
|
||||||
|
dims->boardWidth, dims->top + dims->scoreHt + dims->boardHt,
|
||||||
dims->maxCellSize, XP_FALSE );
|
dims->maxCellSize, XP_FALSE );
|
||||||
|
|
||||||
board_setScoreboardLoc( board, dims->left, dims->top,
|
board_setScoreboardLoc( board, dims->left, dims->top,
|
||||||
|
|
|
@ -76,11 +76,16 @@ void board_reset( BoardCtxt* board );
|
||||||
#ifdef COMMON_LAYOUT
|
#ifdef COMMON_LAYOUT
|
||||||
|
|
||||||
typedef struct _BoardDims {
|
typedef struct _BoardDims {
|
||||||
|
/* The whole board */
|
||||||
XP_U16 left, top;
|
XP_U16 left, top;
|
||||||
XP_U16 width, height;
|
XP_U16 width, height;
|
||||||
|
/* scoreboard (full width) */
|
||||||
XP_U16 scoreWidth, scoreHt;
|
XP_U16 scoreWidth, scoreHt;
|
||||||
XP_U16 boardHt;
|
/* board */
|
||||||
|
XP_U16 boardWidth, boardHt;
|
||||||
|
/* tray (full width) */
|
||||||
XP_U16 trayTop, trayHt;
|
XP_U16 trayTop, trayHt;
|
||||||
|
/* other */
|
||||||
XP_U16 cellSize, maxCellSize;
|
XP_U16 cellSize, maxCellSize;
|
||||||
XP_U16 timerWidth;
|
XP_U16 timerWidth;
|
||||||
} BoardDims;
|
} BoardDims;
|
||||||
|
|
Loading…
Reference in a new issue