mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
Merge branch 'android_branch' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_branch
This commit is contained in:
commit
a791b0e53e
8 changed files with 81 additions and 34 deletions
|
@ -445,8 +445,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
}
|
||||
}
|
||||
|
||||
public boolean drawCell( Rect rect, String text, int tile, int owner,
|
||||
int bonus, int hintAtts, int flags )
|
||||
public boolean drawCell( final Rect rect, String text, int tile, int owner,
|
||||
int bonus, int hintAtts, final int flags )
|
||||
{
|
||||
int backColor;
|
||||
boolean empty = 0 != (flags & (CELL_DRAGSRC|CELL_ISEMPTY));
|
||||
|
@ -500,6 +500,8 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
}
|
||||
// frame the cell
|
||||
m_canvas.drawRect( rect, m_strokePaint );
|
||||
|
||||
drawCrosshairs( rect, flags );
|
||||
|
||||
return true;
|
||||
} // drawCell
|
||||
|
@ -779,6 +781,21 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
|||
}
|
||||
}
|
||||
|
||||
private void drawCrosshairs( final Rect rect, final int flags )
|
||||
{
|
||||
int color = m_otherColors[CommonPrefs.COLOR_FOCUS];
|
||||
if ( 0 != (flags & CELL_CROSSHOR) ) {
|
||||
Rect hairRect = new Rect( rect );
|
||||
hairRect.inset( 0, hairRect.height() / 3 );
|
||||
fillRect( hairRect, color );
|
||||
}
|
||||
if ( 0 != (flags & CELL_CROSSVERT) ) {
|
||||
Rect hairRect = new Rect( rect );
|
||||
hairRect.inset( hairRect.width() / 3, 0 );
|
||||
fillRect( hairRect, color );
|
||||
}
|
||||
}
|
||||
|
||||
private void fillRect( Rect rect, int color )
|
||||
{
|
||||
m_fillPaint.setColor( color );
|
||||
|
|
|
@ -31,7 +31,9 @@ public interface DrawCtx {
|
|||
static final int CELL_VALHIDDEN = 0x20; /* show letter only, not value */
|
||||
static final int CELL_DRAGSRC = 0x40; /* where drag originated */
|
||||
static final int CELL_DRAGCUR = 0x80; /* where drag is now */
|
||||
static final int CELL_ALL = 0xFF;
|
||||
static final int CELL_CROSSVERT = 0x100;
|
||||
static final int CELL_CROSSHOR = 0x200;
|
||||
static final int CELL_ALL = 0x3FF;
|
||||
|
||||
/* BoardObjectType */
|
||||
static final int OBJ_NONE = 0;
|
||||
|
|
|
@ -20,20 +20,6 @@
|
|||
package org.eehouse.android.xw4.jni;
|
||||
|
||||
public class DrawScoreInfo {
|
||||
|
||||
public static final int CELL_NONE = 0x00;
|
||||
public static final int CELL_ISBLANK = 0x01;
|
||||
public static final int CELL_HIGHLIGHT = 0x02;
|
||||
public static final int CELL_ISSTAR = 0x04;
|
||||
public static final int CELL_ISCURSOR = 0x08;
|
||||
public static final int CELL_ISEMPTY = 0x10; /* of a tray tile slot */
|
||||
public static final int CELL_VALHIDDEN = 0x20; /* show letter only, not value */
|
||||
public static final int CELL_DRAGSRC = 0x40; /* where drag originated */
|
||||
public static final int CELL_DRAGCUR = 0x80; /* where drag is now */
|
||||
public static final int CELL_ALL = 0xFF;
|
||||
|
||||
// LastScoreCallback lsc;
|
||||
// void* lscClosure;
|
||||
public String name;
|
||||
public int playerNum;
|
||||
public int totalScore;
|
||||
|
|
|
@ -231,6 +231,23 @@ makeMiniWindowForTrade( BoardCtxt* board )
|
|||
makeMiniWindowForText( board, text, MINIWINDOW_TRADING );
|
||||
} /* makeMiniWindowForTrade */
|
||||
|
||||
#ifdef XWFEATURE_CROSSHAIRS
|
||||
static CellFlags
|
||||
flagsForCrosshairs( const BoardCtxt* board, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
CellFlags flags = 0;
|
||||
XP_Bool inHor, inVert;
|
||||
dragDropInCrosshairs( board, col, row, &inHor, &inVert );
|
||||
if ( inHor ) {
|
||||
flags |= CELL_CROSSHOR;
|
||||
}
|
||||
if ( inVert ) {
|
||||
flags |= CELL_CROSSVERT;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
drawBoard( BoardCtxt* board )
|
||||
{
|
||||
|
@ -310,16 +327,14 @@ drawBoard( BoardCtxt* board )
|
|||
CellFlags flags = CELL_NONE;
|
||||
bonus = util_getSquareBonus( board->util, model, col, row );
|
||||
hintAtts = figureHintAtts( board, col, row );
|
||||
if ( 0 ) {
|
||||
#ifdef KEYBOARD_NAV
|
||||
} else if ( cellFocused( board, col, row ) ) {
|
||||
if ( cellFocused( board, col, row ) ) {
|
||||
flags |= CELL_ISCURSOR;
|
||||
}
|
||||
#endif
|
||||
#ifdef XWFEATURE_CROSSHAIRS
|
||||
} else if ( dragDropInCrosshairs( board, col, row ) ) {
|
||||
flags |= CELL_ISCURSOR;
|
||||
flags |= flagsForCrosshairs( board, col, row );
|
||||
#endif
|
||||
}
|
||||
|
||||
draw_drawBoardArrow( board->draw, &arrowRect, bonus,
|
||||
arrow->vert, hintAtts, flags );
|
||||
|
@ -433,9 +448,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
|
|||
}
|
||||
#endif
|
||||
#ifdef XWFEATURE_CROSSHAIRS
|
||||
if ( dragDropInCrosshairs( board, col, row ) ) {
|
||||
flags |= CELL_ISCURSOR;
|
||||
}
|
||||
flags |= flagsForCrosshairs( board, col, row );
|
||||
#endif
|
||||
|
||||
success = draw_drawCell( board->draw, &cellRect, textP, bptr,
|
||||
|
|
|
@ -659,16 +659,18 @@ startScrollTimerIf( BoardCtxt* board )
|
|||
} /* startScrollTimerIf */
|
||||
|
||||
#ifdef XWFEATURE_CROSSHAIRS
|
||||
XP_Bool
|
||||
dragDropInCrosshairs( const BoardCtxt* board, XP_U16 col, XP_U16 row )
|
||||
void
|
||||
dragDropInCrosshairs( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_Bool* inHor, XP_Bool* inVert )
|
||||
{
|
||||
XP_Bool result = dragDropInProgress( board );
|
||||
if ( result ) {
|
||||
|
||||
if ( dragDropInProgress( board ) ) {
|
||||
const DragState* ds = &board->dragState;
|
||||
result = ds->crosshairs.col == col
|
||||
|| ds->crosshairs.row == row;
|
||||
*inHor = ds->crosshairs.row == row;
|
||||
*inVert = ds->crosshairs.col == col;
|
||||
} else {
|
||||
*inHor = *inVert = XP_FALSE;
|
||||
}
|
||||
return result;
|
||||
} /* dragDropInCrosshairs */
|
||||
|
||||
static void
|
||||
|
|
|
@ -58,7 +58,9 @@ XP_Bool dragDropGetHintLimits( const BoardCtxt* board, BdHintLimits* limits );
|
|||
|
||||
void dragDropTileInfo( const BoardCtxt* board, Tile* tile, XP_Bool* isBlank );
|
||||
#ifdef XWFEATURE_CROSSHAIRS
|
||||
XP_Bool dragDropInCrosshairs( const BoardCtxt* board, XP_U16 col, XP_U16 row );
|
||||
void dragDropInCrosshairs( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_Bool* inHor, XP_Bool* inVert );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CPLUS
|
||||
|
|
|
@ -41,7 +41,9 @@ typedef enum {
|
|||
, CELL_VALHIDDEN = 0x20 /* show letter only, not value */
|
||||
, CELL_DRAGSRC = 0x40 /* where drag originated */
|
||||
, CELL_DRAGCUR = 0x80 /* where drag is now */
|
||||
, CELL_ALL = 0xFF
|
||||
, CELL_CROSSVERT = 0x100 /* vertical component of crosshair */
|
||||
, CELL_CROSSHOR = 0x200 /* horizontal component of crosshair */
|
||||
, CELL_ALL = 0x3FF
|
||||
} CellFlags;
|
||||
|
||||
typedef struct DrawScoreInfo {
|
||||
|
|
|
@ -420,6 +420,28 @@ drawHintBorders( GtkDrawCtx* dctx, const XP_Rect* rect, HintAtts hintAtts)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef XWFEATURE_CROSSHAIRS
|
||||
static void
|
||||
drawCrosshairs( GtkDrawCtx* dctx, const XP_Rect* rect, CellFlags flags )
|
||||
{
|
||||
XP_Rect hairRect;
|
||||
if ( 0 != (flags & CELL_CROSSHOR) ) {
|
||||
hairRect = *rect;
|
||||
hairRect.height /= 3;
|
||||
hairRect.top += hairRect.height;
|
||||
gtkFillRect( dctx, &hairRect, &dctx->cursor );
|
||||
}
|
||||
if ( 0 != (flags & CELL_CROSSVERT) ) {
|
||||
hairRect = *rect;
|
||||
hairRect.width /= 3;
|
||||
hairRect.left += hairRect.width;
|
||||
gtkFillRect( dctx, &hairRect, &dctx->cursor );
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define drawCrosshairs( a, b, c )
|
||||
#endif
|
||||
|
||||
static XP_Bool
|
||||
gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||
const XP_Bitmaps* bitmaps, Tile XP_UNUSED(tile),
|
||||
|
@ -504,6 +526,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
|||
}
|
||||
|
||||
drawHintBorders( dctx, rect, hintAtts );
|
||||
drawCrosshairs( dctx, rect, flags );
|
||||
|
||||
return XP_TRUE;
|
||||
} /* gtk_draw_drawCell */
|
||||
|
|
Loading…
Reference in a new issue