attempt to improve scoreboard drawing when names are long or numerous

enough to crowd by using same math to figure height when measuring as
when drawing, but it still needs work.
This commit is contained in:
Eric House 2012-06-19 07:44:26 -07:00
parent df907f6cb3
commit c2c1fe4f89

View file

@ -54,6 +54,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
private static Bitmap s_bitmap; // the board
private static final int IN_TRADE_ALPHA = 0x3FFFFFFF;
private static final int PINCH_THRESHOLD = 40;
private static final int SCORE_HT_DROP = 2;
private static final boolean DEBUG_DRAWFRAMES = false;
private Context m_context;
private Paint m_drawPaint;
@ -466,7 +468,15 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
scoreInfo[indx] = sb.toString();
m_scores[dsi.playerNum] = scoreInfo;
m_fillPaint.setTextSize( dsi.isTurn? rect.height() : m_defaultFontHt );
int rectHt = rect.height();
if ( !dsi.isTurn ) {
rectHt /= 2;
}
int textHeight = rectHt - SCORE_HT_DROP;
if ( textHeight < m_defaultFontHt ) {
textHeight = m_defaultFontHt;
}
m_fillPaint.setTextSize( textHeight );
int needWidth = 0;
for ( int ii = 0; ii < scoreInfo.length; ++ii ) {
@ -489,6 +499,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
{
if ( 0 != (dsi.flags & CELL_ISCURSOR) ) {
fillRectOther( rOuter, CommonPrefs.COLOR_FOCUS );
} else if ( DEBUG_DRAWFRAMES && dsi.selected ) {
fillRectOther( rOuter, CommonPrefs.COLOR_FOCUS );
}
String[] texts = m_scores[dsi.playerNum];
int color = m_playerColors[dsi.playerNum];
@ -503,6 +515,10 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
drawCentered( text, rOuter, null );
rOuter.offset( 0, height );
}
if ( DEBUG_DRAWFRAMES ) {
m_strokePaint.setColor( BLACK );
m_canvas.drawRect( rInner, m_strokePaint );
}
}
public void drawTimer( Rect rect, int player, int secondsLeft )
@ -773,7 +789,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
int descent = -1;
int textSize;
if ( null == fontDims ) {
textSize = rect.height() - 2;
textSize = rect.height() - SCORE_HT_DROP;
} else {
int height = rect.height() - 4; // borders and padding, 2 each
descent = fontDims.descentFor( height );