From c2c1fe4f894e20b4ce6ef54c2070c4e666f0ae6d Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 19 Jun 2012 07:44:26 -0700 Subject: [PATCH] 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. --- .../org/eehouse/android/xw4/BoardView.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java index 070f6b1c8..66898d4f1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardView.java @@ -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 );