mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +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 Drawable m_downArrow;
|
||||||
private boolean m_blackArrow;
|
private boolean m_blackArrow;
|
||||||
private boolean m_inTrade = false;
|
private boolean m_inTrade = false;
|
||||||
|
private boolean m_hasSmallScreen;
|
||||||
// m_backgroundUsed: alpha not set ensures inequality
|
// m_backgroundUsed: alpha not set ensures inequality
|
||||||
private int m_backgroundUsed = 0x00000000;
|
private int m_backgroundUsed = 0x00000000;
|
||||||
private boolean m_darkOnLight;
|
private boolean m_darkOnLight;
|
||||||
|
@ -145,6 +146,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
super( context, attrs );
|
super( context, attrs );
|
||||||
|
|
||||||
m_context = context;
|
m_context = context;
|
||||||
|
m_hasSmallScreen = Utils.hasSmallScreen( context );
|
||||||
|
|
||||||
final float scale = getResources().getDisplayMetrics().density;
|
final float scale = getResources().getDisplayMetrics().density;
|
||||||
m_defaultFontHt = (int)(MIN_FONT_DIPS * scale + 0.5f);
|
m_defaultFontHt = (int)(MIN_FONT_DIPS * scale + 0.5f);
|
||||||
m_mediumFontHt = m_defaultFontHt * 3 / 2;
|
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
|
// fit them and all cells no scrolling's needed. Otherwise
|
||||||
// determine the minimum number that must be hidden to fit.
|
// determine the minimum number that must be hidden to fit.
|
||||||
// Finally grow scoreboard and tray to use whatever's left.
|
// 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 scoreHt = (cellSize * 3) / 2;
|
||||||
int wantHt = trayHt + scoreHt + (cellSize * nCells);
|
int wantHt = trayHt + scoreHt + (cellSize * nCells);
|
||||||
int nToScroll;
|
int nToScroll;
|
||||||
|
@ -770,6 +773,12 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
} // drawTileImpl
|
} // drawTileImpl
|
||||||
|
|
||||||
private void drawCentered( String text, Rect rect, FontDims fontDims )
|
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 descent = -1;
|
||||||
int textSize;
|
int textSize;
|
||||||
|
@ -794,9 +803,12 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
drawScaled( text, rect, descent );
|
drawScaled( text, rect, descent );
|
||||||
} else {
|
} else {
|
||||||
int bottom = rect.bottom - descent;
|
int bottom = rect.bottom - descent;
|
||||||
int center = rect.left + ( rect.width() / 2 );
|
int origin = rect.left;
|
||||||
m_fillPaint.setTextAlign( Paint.Align.CENTER );
|
if ( Paint.Align.CENTER == align ) {
|
||||||
m_canvas.drawText( text, center, bottom, m_fillPaint );
|
origin += rect.width() / 2;
|
||||||
|
}
|
||||||
|
m_fillPaint.setTextAlign( align );
|
||||||
|
m_canvas.drawText( text, origin, bottom, m_fillPaint );
|
||||||
}
|
}
|
||||||
} // drawCentered
|
} // drawCentered
|
||||||
|
|
||||||
|
@ -820,26 +832,35 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
private void positionDrawTile( final Rect rect, String text, int val )
|
private void positionDrawTile( final Rect rect, String text, int val )
|
||||||
{
|
{
|
||||||
if ( figureFontDims() ) {
|
if ( figureFontDims() ) {
|
||||||
|
int offset = m_hasSmallScreen ? 1 : 2;
|
||||||
if ( null != text ) {
|
if ( null != text ) {
|
||||||
if ( null == m_letterRect ) {
|
if ( null == m_letterRect ) {
|
||||||
m_letterRect = new Rect( 0, 0, rect.width() * 3 / 4,
|
int width = rect.width();
|
||||||
rect.height() * 3 / 4 );
|
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 );
|
width -= offset;
|
||||||
drawCentered( text, m_letterRect, m_fontDims );
|
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 ) {
|
if ( FRAME_TRAY_RECTS ) {
|
||||||
m_canvas.drawRect( m_letterRect, m_strokePaint );
|
m_canvas.drawRect( m_letterRect, m_strokePaint );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( val >= 0 ) {
|
if ( val >= 0 ) {
|
||||||
|
int divisor = m_hasSmallScreen ? 3 : 4;
|
||||||
if ( null == m_valRect ) {
|
if ( null == m_valRect ) {
|
||||||
m_valRect = new Rect( 0, 0, rect.width() / 4,
|
m_valRect = new Rect( 0, 0, rect.width() / divisor,
|
||||||
rect.height() / 4 );
|
rect.height() / divisor );
|
||||||
m_valRect.inset( 2, 2 );
|
m_valRect.inset( offset, offset );
|
||||||
}
|
}
|
||||||
m_valRect.offsetTo( rect.right - (rect.width() / 4),
|
m_valRect.offsetTo( rect.right - (rect.width() / divisor),
|
||||||
rect.bottom - (rect.height() / 4) );
|
rect.bottom - (rect.height() / divisor) );
|
||||||
text = String.format( "%d", val );
|
text = String.format( "%d", val );
|
||||||
m_fillPaint.setTextSize( m_valRect.height() );
|
m_fillPaint.setTextSize( m_valRect.height() );
|
||||||
m_fillPaint.setTextAlign( Paint.Align.RIGHT );
|
m_fillPaint.setTextAlign( Paint.Align.RIGHT );
|
||||||
|
|
Loading…
Add table
Reference in a new issue