Specify relative height of scoreboard and tray in board_figureLayout,

and allow those to be 0.
This commit is contained in:
Eric House 2013-11-04 06:19:33 -08:00
parent f0b554213b
commit 9f1b0c5121
7 changed files with 67 additions and 45 deletions

View file

@ -648,7 +648,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1figureLayout
bounds.height = getInt( env, jbounds, "bottom" ) - bounds.top;
BoardDims dims;
board_figureLayout( state->game.board, gi, fontHt, fontWidth,
board_figureLayout( state->game.board, gi, 150, 200, fontHt, fontWidth,
squareTiles, &bounds, ((!!jdims) ? &dims : NULL) );
destroyGI( MPPARM(mpool) &gi );

View file

@ -392,6 +392,7 @@ board_reset( BoardCtxt* board )
#ifdef COMMON_LAYOUT
void
board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
XP_U16 scorePct, XP_U16 trayPct,
XP_U16 fontHt, XP_U16 fontWidth, XP_Bool squareTiles,
const XP_Rect* bounds, BoardDims* dimsp )
{
@ -426,8 +427,8 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
// 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.
trayHt = 2 * cellSize;
scoreHt = (cellSize * 3) / 2;
scoreHt = (scorePct * cellSize) / 100;
trayHt = (trayPct * cellSize) / 100;
wantHt = trayHt + scoreHt + (cellSize * nCells);
if ( wantHt <= bounds->height ) {
nToScroll = 0;
@ -452,9 +453,13 @@ board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
heightLeft = cellSize * 3 / 2;
}
heightLeft /= 3;
scoreHt += heightLeft;
trayHt += heightLeft * 2;
if ( 0 < scorePct ) {
scoreHt += heightLeft;
}
if ( 0 < trayPct ) {
trayHt += heightLeft * 2;
}
if ( squareTiles && trayHt > (bounds->width / 7) ) {
trayHt = bounds->width / 7;
}

View file

@ -86,6 +86,7 @@ typedef struct _BoardDims {
} BoardDims;
void board_figureLayout( BoardCtxt* board, const CurGameInfo* gi,
XP_U16 scorePct, XP_U16 trayPct,
XP_U16 fontHt, XP_U16 fontWidth,
XP_Bool squareTiles, const XP_Rect* bounds,
/* out */ BoardDims* dims );

View file

@ -280,51 +280,55 @@ drawScoreBoard( BoardCtxt* board )
totalDim += isVertical ? dp->height : dp->width;
}
gotPct = (*adjustDim * 100) / totalDim;
for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) {
if ( isVertical ) {
dp->height = (dp->height * gotPct) / 100;
} else {
dp->width = (dp->width * gotPct) / 100;
if ( 0 < totalDim ) {
gotPct = (*adjustDim * 100) / totalDim;
for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) {
if ( isVertical ) {
dp->height = (dp->height * gotPct) / 100;
} else {
dp->width = (dp->width * gotPct) / 100;
}
}
}
scoreRect = board->scoreBdBounds; /* reset */
scoreRect = board->scoreBdBounds; /* reset */
/* at this point, the scoreRect should be anchored at the
scoreboard rect's upper left. */
/* at this point, the scoreRect should be anchored at the
scoreboard rect's upper left. */
if ( remDim > 0 ) {
XP_Rect innerRect;
*adjustDim = remDim;
centerIn( &innerRect, &scoreRect, remWidth, remHeight );
draw_drawRemText( board->draw, &innerRect, &scoreRect,
nTilesInPool, focusAll || remFocussed );
*adjustPt += remDim;
if ( remDim > 0 ) {
XP_Rect innerRect;
*adjustDim = remDim;
centerIn( &innerRect, &scoreRect, remWidth, remHeight );
draw_drawRemText( board->draw, &innerRect, &scoreRect,
nTilesInPool,
focusAll || remFocussed );
*adjustPt += remDim;
#ifdef KEYBOARD_NAV
board->remRect = scoreRect;
/* Hack: don't let the cursor disappear if Rem: goes
away */
} else if ( board->scoreCursorLoc == CURSOR_LOC_REM ) {
board->scoreCursorLoc = selPlayer + 1;
board->remRect = scoreRect;
/* Hack: don't let the cursor disappear if Rem: goes
away */
} else if ( board->scoreCursorLoc == CURSOR_LOC_REM ) {
board->scoreCursorLoc = selPlayer + 1;
#endif
}
}
board->remDim = remDim;
board->remDim = remDim;
for ( dp = datum, ii = 0; ii < nPlayers; ++dp, ++ii ) {
XP_Rect innerRect;
XP_U16 dim = isVertical? dp->height:dp->width;
*adjustDim = board->pti[ii].scoreDims = dim;
for ( dp = datum, ii = 0; ii < nPlayers; ++dp, ++ii ) {
XP_Rect innerRect;
XP_U16 dim = isVertical? dp->height:dp->width;
*adjustDim = board->pti[ii].scoreDims = dim;
centerIn( &innerRect, &scoreRect, dp->width, dp->height );
draw_score_drawPlayer( board->draw, &innerRect, &scoreRect,
gotPct, &dp->dsi );
centerIn( &innerRect, &scoreRect, dp->width,
dp->height );
draw_score_drawPlayer( board->draw, &innerRect,
&scoreRect, gotPct, &dp->dsi );
#ifdef KEYBOARD_NAV
XP_MEMCPY( &board->pti[ii].scoreRects, &scoreRect,
sizeof(scoreRect) );
XP_MEMCPY( &board->pti[ii].scoreRects, &scoreRect,
sizeof(scoreRect) );
#endif
*adjustPt += *adjustDim;
*adjustPt += *adjustDim;
}
}
draw_objFinished( board->draw, OBJ_SCORE,

View file

@ -328,9 +328,11 @@ drawPendingScore( BoardCtxt* board, XP_S16 turnScore, XP_Bool hasCursor )
XP_Rect lastTileR;
figureTrayTileRect( board, MAX_TRAY_TILES-1, &lastTileR );
draw_score_pendingScore( board->draw, &lastTileR, turnScore,
selPlayer, curTurn,
hasCursor?CELL_ISCURSOR:CELL_NONE );
if ( 0 < lastTileR.width && 0 < lastTileR.height ) {
draw_score_pendingScore( board->draw, &lastTileR, turnScore,
selPlayer, curTurn,
hasCursor?CELL_ISCURSOR:CELL_NONE );
}
}
} /* drawPendingScore */
@ -509,7 +511,9 @@ dividerMoved( BoardCtxt* board, XP_U8 newLoc )
void
board_invalTrayTiles( BoardCtxt* board, TileBit what )
{
board->trayInvalBits |= what;
if ( 0 < board->trayBounds.width && 0 < board->trayBounds.height ) {
board->trayInvalBits |= what;
}
} /* invalTrayTiles */
void

View file

@ -116,6 +116,7 @@ DEFINES += -DXWFEATURE_COMMSACK
#DEFINES += -DXWFEATURE_ACTIVERECT
DEFINES += -DCOMMS_XPORT_FLAGSPROC
DEFINES += -DINITIAL_CLIENT_VERS=2
DEFINES += -DCOMMON_LAYOUT
# MAX_ROWS controls STREAM_VERS_BIGBOARD and with it move hashing
DEFINES += -DMAX_ROWS=32

View file

@ -617,7 +617,14 @@ configure_event( GtkWidget* widget, GdkEventConfigure* XP_UNUSED(event),
.width = bdWidth, .height = bdHeight
};
BoardDims dims;
board_figureLayout( board, cGlobals->gi, 16, 16, XP_FALSE, &rect, &dims );
board_figureLayout( board, cGlobals->gi,
#if 1
150, 200,
#else
0, 0,
#endif
16, 16,
XP_FALSE, &rect, &dims );
board_applyLayout( board, &dims );
#else