mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-17 18:12:01 +01:00
reduce min tray height to twice cell height, and tweak layout on
small-screen devices to make the value readable.
This commit is contained in:
parent
ac74e2e832
commit
266e9ba91a
1 changed files with 34 additions and 13 deletions
|
@ -76,6 +76,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private Drawable m_downArrow;
|
||||
private boolean m_blackArrow;
|
||||
private boolean m_inTrade = false;
|
||||
private boolean m_hasSmallScreen;
|
||||
// m_backgroundUsed: alpha not set ensures inequality
|
||||
private int m_backgroundUsed = 0x00000000;
|
||||
private boolean m_darkOnLight;
|
||||
|
@ -145,6 +146,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
super( context, attrs );
|
||||
|
||||
m_context = context;
|
||||
m_hasSmallScreen = Utils.hasSmallScreen( context );
|
||||
|
||||
final float scale = getResources().getDisplayMetrics().density;
|
||||
m_defaultFontHt = (int)(MIN_FONT_DIPS * scale + 0.5f);
|
||||
m_mediumFontHt = m_defaultFontHt * 3 / 2;
|
||||
|
@ -271,7 +274,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
// 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.
|
||||
int trayHt = (5 * cellSize) / 2;
|
||||
int trayHt = 2 * cellSize;
|
||||
int scoreHt = (cellSize * 3) / 2;
|
||||
int wantHt = trayHt + scoreHt + (cellSize * nCells);
|
||||
int nToScroll;
|
||||
|
@ -770,6 +773,12 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
} // drawTileImpl
|
||||
|
||||
private void drawCentered( String text, Rect rect, FontDims fontDims )
|
||||
{
|
||||
drawIn( text, rect, fontDims, Paint.Align.CENTER );
|
||||
}
|
||||
|
||||
private void drawIn( String text, Rect rect, FontDims fontDims,
|
||||
Paint.Align align )
|
||||
{
|
||||
int descent = -1;
|
||||
int textSize;
|
||||
|
@ -794,9 +803,12 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
drawScaled( text, rect, descent );
|
||||
} else {
|
||||
int bottom = rect.bottom - descent;
|
||||
int center = rect.left + ( rect.width() / 2 );
|
||||
m_fillPaint.setTextAlign( Paint.Align.CENTER );
|
||||
m_canvas.drawText( text, center, bottom, m_fillPaint );
|
||||
int origin = rect.left;
|
||||
if ( Paint.Align.CENTER == align ) {
|
||||
origin += rect.width() / 2;
|
||||
}
|
||||
m_fillPaint.setTextAlign( align );
|
||||
m_canvas.drawText( text, origin, bottom, m_fillPaint );
|
||||
}
|
||||
} // drawCentered
|
||||
|
||||
|
@ -820,26 +832,35 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
private void positionDrawTile( final Rect rect, String text, int val )
|
||||
{
|
||||
if ( figureFontDims() ) {
|
||||
int offset = m_hasSmallScreen ? 1 : 2;
|
||||
if ( null != text ) {
|
||||
if ( null == m_letterRect ) {
|
||||
m_letterRect = new Rect( 0, 0, rect.width() * 3 / 4,
|
||||
rect.height() * 3 / 4 );
|
||||
int width = rect.width();
|
||||
int height = rect.height();
|
||||
if ( m_hasSmallScreen ) {
|
||||
height = height * 2 / 3;
|
||||
} else {
|
||||
height = height * 3 / 4;
|
||||
}
|
||||
m_letterRect.offsetTo( rect.left+2, rect.top+2 );
|
||||
drawCentered( text, m_letterRect, m_fontDims );
|
||||
width -= offset;
|
||||
m_letterRect = new Rect( 0, 0, width, height );
|
||||
}
|
||||
m_letterRect.offsetTo( rect.left + offset, rect.top + offset );
|
||||
drawIn( text, m_letterRect, m_fontDims, Paint.Align.LEFT );
|
||||
if ( FRAME_TRAY_RECTS ) {
|
||||
m_canvas.drawRect( m_letterRect, m_strokePaint );
|
||||
}
|
||||
}
|
||||
|
||||
if ( val >= 0 ) {
|
||||
int divisor = m_hasSmallScreen ? 3 : 4;
|
||||
if ( null == m_valRect ) {
|
||||
m_valRect = new Rect( 0, 0, rect.width() / 4,
|
||||
rect.height() / 4 );
|
||||
m_valRect.inset( 2, 2 );
|
||||
m_valRect = new Rect( 0, 0, rect.width() / divisor,
|
||||
rect.height() / divisor );
|
||||
m_valRect.inset( offset, offset );
|
||||
}
|
||||
m_valRect.offsetTo( rect.right - (rect.width() / 4),
|
||||
rect.bottom - (rect.height() / 4) );
|
||||
m_valRect.offsetTo( rect.right - (rect.width() / divisor),
|
||||
rect.bottom - (rect.height() / divisor) );
|
||||
text = String.format( "%d", val );
|
||||
m_fillPaint.setTextSize( m_valRect.height() );
|
||||
m_fillPaint.setTextAlign( Paint.Align.RIGHT );
|
||||
|
|
Loading…
Reference in a new issue