mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
differentiate betweeen PENDING and RECENT tiles
Should not show the new you-can-lookup-uncommitted-words hint for already-played words, so needed to be able to tell difference between the two. Now you can -- and on the gtk side I draw them differently because I can.
This commit is contained in:
parent
fbf810444b
commit
012ebe26f7
7 changed files with 40 additions and 27 deletions
|
@ -363,7 +363,8 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
if ( canDraw ) {
|
if ( canDraw ) {
|
||||||
int backColor;
|
int backColor;
|
||||||
boolean empty = 0 != (flags & (CELL_DRAGSRC|CELL_ISEMPTY));
|
boolean empty = 0 != (flags & (CELL_DRAGSRC|CELL_ISEMPTY));
|
||||||
boolean pending = 0 != (flags & CELL_HIGHLIGHT);
|
boolean pending = 0 != (flags & CELL_PENDING);
|
||||||
|
boolean recent = 0 != (flags & CELL_RECENT);
|
||||||
String bonusStr = null;
|
String bonusStr = null;
|
||||||
|
|
||||||
if ( m_inTrade ) {
|
if ( m_inTrade ) {
|
||||||
|
@ -384,8 +385,10 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
backColor = m_bonusColors[bonus];
|
backColor = m_bonusColors[bonus];
|
||||||
bonusStr = m_bonusSummaries[bonus];
|
bonusStr = m_bonusSummaries[bonus];
|
||||||
}
|
}
|
||||||
} else if ( pending ) {
|
} else if ( pending || recent ) {
|
||||||
++mPendingCount;
|
if ( pending ) {
|
||||||
|
++mPendingCount;
|
||||||
|
}
|
||||||
if ( darkOnLight() ) {
|
if ( darkOnLight() ) {
|
||||||
foreColor = WHITE;
|
foreColor = WHITE;
|
||||||
backColor = BLACK;
|
backColor = BLACK;
|
||||||
|
@ -484,7 +487,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
public void drawTrayDivider( Rect rect, int flags )
|
public void drawTrayDivider( Rect rect, int flags )
|
||||||
{
|
{
|
||||||
boolean isCursor = 0 != (flags & CELL_ISCURSOR);
|
boolean isCursor = 0 != (flags & CELL_ISCURSOR);
|
||||||
boolean selected = 0 != (flags & CELL_HIGHLIGHT);
|
boolean selected = 0 != (flags & (CELL_PENDING|CELL_RECENT));
|
||||||
|
|
||||||
int index = isCursor? CommonPrefs.COLOR_FOCUS : CommonPrefs.COLOR_BACKGRND;
|
int index = isCursor? CommonPrefs.COLOR_FOCUS : CommonPrefs.COLOR_BACKGRND;
|
||||||
fillRectOther( rect, index );
|
fillRectOther( rect, index );
|
||||||
|
@ -602,7 +605,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
|
||||||
|
|
||||||
Paint paint = getTileStrokePaint( rect );
|
Paint paint = getTileStrokePaint( rect );
|
||||||
drawRect( rect, paint ); // frame
|
drawRect( rect, paint ); // frame
|
||||||
if ( 0 != (flags & CELL_HIGHLIGHT) ) {
|
if ( 0 != (flags & (CELL_PENDING|CELL_RECENT)) ) {
|
||||||
int width = (int)paint.getStrokeWidth();
|
int width = (int)paint.getStrokeWidth();
|
||||||
rect.inset( width, width );
|
rect.inset( width, width );
|
||||||
drawRect( rect, paint ); // frame
|
drawRect( rect, paint ); // frame
|
||||||
|
|
|
@ -23,9 +23,10 @@ package org.eehouse.android.xw4.jni;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
|
||||||
public interface DrawCtx {
|
public interface DrawCtx {
|
||||||
|
// These must be kept in sync with the enum CellFlags in draw.h
|
||||||
static final int CELL_NONE = 0x00;
|
static final int CELL_NONE = 0x00;
|
||||||
static final int CELL_ISBLANK = 0x01;
|
static final int CELL_ISBLANK = 0x01;
|
||||||
static final int CELL_HIGHLIGHT = 0x02;
|
static final int CELL_RECENT = 0x02;
|
||||||
static final int CELL_ISSTAR = 0x04;
|
static final int CELL_ISSTAR = 0x04;
|
||||||
static final int CELL_ISCURSOR = 0x08;
|
static final int CELL_ISCURSOR = 0x08;
|
||||||
static final int CELL_ISEMPTY = 0x10; /* of a tray tile slot */
|
static final int CELL_ISEMPTY = 0x10; /* of a tray tile slot */
|
||||||
|
@ -34,7 +35,8 @@ public interface DrawCtx {
|
||||||
static final int CELL_DRAGCUR = 0x80; /* where drag is now */
|
static final int CELL_DRAGCUR = 0x80; /* where drag is now */
|
||||||
static final int CELL_CROSSVERT = 0x100;
|
static final int CELL_CROSSVERT = 0x100;
|
||||||
static final int CELL_CROSSHOR = 0x200;
|
static final int CELL_CROSSHOR = 0x200;
|
||||||
static final int CELL_ALL = 0x3FF;
|
static final int CELL_PENDING = 0x400;
|
||||||
|
static final int CELL_ALL = 0x7FF;
|
||||||
|
|
||||||
/* BoardObjectType */
|
/* BoardObjectType */
|
||||||
static final int OBJ_NONE = 0;
|
static final int OBJ_NONE = 0;
|
||||||
|
|
|
@ -397,7 +397,6 @@ drawCell( BoardCtxt* board, const XP_U16 col, const XP_U16 row, XP_Bool skipBlan
|
||||||
!rectContainsRect( &board->trayBounds, &cellRect ) ) {
|
!rectContainsRect( &board->trayBounds, &cellRect ) ) {
|
||||||
XP_UCHAR ch[4] = {'\0'};
|
XP_UCHAR ch[4] = {'\0'};
|
||||||
XP_S16 owner = -1;
|
XP_S16 owner = -1;
|
||||||
XP_Bool invert = XP_FALSE;
|
|
||||||
XP_Bitmaps bitmaps;
|
XP_Bitmaps bitmaps;
|
||||||
XP_Bitmaps* bptr = NULL;
|
XP_Bitmaps* bptr = NULL;
|
||||||
const XP_UCHAR* textP = NULL;
|
const XP_UCHAR* textP = NULL;
|
||||||
|
@ -432,8 +431,6 @@ drawCell( BoardCtxt* board, const XP_U16 col, const XP_U16 row, XP_Bool skipBlan
|
||||||
modelRow );
|
modelRow );
|
||||||
}
|
}
|
||||||
|
|
||||||
invert = showPending? pending : recent;
|
|
||||||
|
|
||||||
if ( board->showCellValues ) {
|
if ( board->showCellValues ) {
|
||||||
XP_SNPRINTF( ch, VSIZE(ch), "%d", value );
|
XP_SNPRINTF( ch, VSIZE(ch), "%d", value );
|
||||||
textP = ch;
|
textP = ch;
|
||||||
|
@ -451,8 +448,10 @@ drawCell( BoardCtxt* board, const XP_U16 col, const XP_U16 row, XP_Bool skipBlan
|
||||||
if ( (col==board->star_row) && (row==board->star_row) ) {
|
if ( (col==board->star_row) && (row==board->star_row) ) {
|
||||||
flags |= CELL_ISSTAR;
|
flags |= CELL_ISSTAR;
|
||||||
}
|
}
|
||||||
if ( invert ) {
|
if ( recent && !showPending ) {
|
||||||
flags |= CELL_HIGHLIGHT;
|
flags |= CELL_RECENT;
|
||||||
|
} else if ( pending ) {
|
||||||
|
flags |= CELL_PENDING;
|
||||||
}
|
}
|
||||||
if ( isBlank ) {
|
if ( isBlank ) {
|
||||||
flags |= CELL_ISBLANK;
|
flags |= CELL_ISBLANK;
|
||||||
|
@ -656,7 +655,8 @@ static XP_UCHAR* formatFlags( XP_UCHAR* buf, XP_U16 len, CellFlags flags )
|
||||||
if ( 0 != (flag & flags) ) {
|
if ( 0 != (flag & flags) ) {
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case CELL_ISBLANK: str = "BLNK"; break;
|
case CELL_ISBLANK: str = "BLNK"; break;
|
||||||
case CELL_HIGHLIGHT: str = "HLIT"; break;
|
case CELL_PENDING: str = "PEND"; break;
|
||||||
|
case CELL_RECENT: str = "RCNT"; break;
|
||||||
case CELL_ISEMPTY: str = "MPTY"; break;
|
case CELL_ISEMPTY: str = "MPTY"; break;
|
||||||
case CELL_ISCURSOR: str = "CURS"; break;
|
case CELL_ISCURSOR: str = "CURS"; break;
|
||||||
case CELL_VALHIDDEN: str = "HIDN"; break;
|
case CELL_VALHIDDEN: str = "HIDN"; break;
|
||||||
|
|
|
@ -34,7 +34,7 @@ typedef XP_Bool (*LastScoreCallback)( void* closure, XP_S16 player,
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CELL_NONE = 0x00
|
CELL_NONE = 0x00
|
||||||
, CELL_ISBLANK = 0x01
|
, CELL_ISBLANK = 0x01
|
||||||
, CELL_HIGHLIGHT = 0x02
|
, CELL_RECENT = 0x02
|
||||||
, CELL_ISSTAR = 0x04
|
, CELL_ISSTAR = 0x04
|
||||||
, CELL_ISCURSOR = 0x08
|
, CELL_ISCURSOR = 0x08
|
||||||
, CELL_ISEMPTY = 0x10 /* of a tray tile slot */
|
, CELL_ISEMPTY = 0x10 /* of a tray tile slot */
|
||||||
|
@ -43,7 +43,8 @@ typedef enum {
|
||||||
, CELL_DRAGCUR = 0x80 /* where drag is now */
|
, CELL_DRAGCUR = 0x80 /* where drag is now */
|
||||||
, CELL_CROSSVERT = 0x100 /* vertical component of crosshair */
|
, CELL_CROSSVERT = 0x100 /* vertical component of crosshair */
|
||||||
, CELL_CROSSHOR = 0x200 /* horizontal component of crosshair */
|
, CELL_CROSSHOR = 0x200 /* horizontal component of crosshair */
|
||||||
, CELL_ALL = 0x3FF
|
, CELL_PENDING = 0x400
|
||||||
|
, CELL_ALL = 0x7FF
|
||||||
} CellFlags;
|
} CellFlags;
|
||||||
|
|
||||||
typedef struct DrawScoreInfo {
|
typedef struct DrawScoreInfo {
|
||||||
|
|
|
@ -226,10 +226,10 @@ drawTray( BoardCtxt* board )
|
||||||
&bitmaps, &value );
|
&bitmaps, &value );
|
||||||
if ( isADrag ) {
|
if ( isADrag ) {
|
||||||
if ( ddAddedIndx == ii ) {
|
if ( ddAddedIndx == ii ) {
|
||||||
flags |= CELL_HIGHLIGHT;
|
flags |= CELL_PENDING;
|
||||||
}
|
}
|
||||||
} else if ( (traySelBits & (1<<ii)) != 0 ) {
|
} else if ( (traySelBits & (1<<ii)) != 0 ) {
|
||||||
flags |= CELL_HIGHLIGHT;
|
flags |= CELL_PENDING;
|
||||||
}
|
}
|
||||||
if ( isBlank ) {
|
if ( isBlank ) {
|
||||||
flags |= CELL_ISBLANK;
|
flags |= CELL_ISBLANK;
|
||||||
|
@ -256,7 +256,7 @@ drawTray( BoardCtxt* board )
|
||||||
figureDividerRect( board, ÷r );
|
figureDividerRect( board, ÷r );
|
||||||
if ( pti->dividerSelected
|
if ( pti->dividerSelected
|
||||||
|| dragDropIsDividerDrag(board) ) {
|
|| dragDropIsDividerDrag(board) ) {
|
||||||
flags |= CELL_HIGHLIGHT;
|
flags |= CELL_PENDING;
|
||||||
}
|
}
|
||||||
draw_drawTrayDivider( board->draw, ÷r, flags );
|
draw_drawTrayDivider( board->draw, ÷r, flags );
|
||||||
board->dividerInvalid = XP_FALSE;
|
board->dividerInvalid = XP_FALSE;
|
||||||
|
|
|
@ -352,7 +352,7 @@ curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
HintAtts XP_UNUSED(hintAtts), CellFlags flags )
|
HintAtts XP_UNUSED(hintAtts), CellFlags flags )
|
||||||
{
|
{
|
||||||
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
|
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
|
||||||
XP_Bool highlight = (flags & (CELL_HIGHLIGHT|CELL_ISCURSOR)) != 0;
|
XP_Bool highlight = (flags & (CELL_PENDING|CELL_RECENT|CELL_ISCURSOR)) != 0;
|
||||||
XP_UCHAR loc[rect->width+1];
|
XP_UCHAR loc[rect->width+1];
|
||||||
if ( !!letter ) {
|
if ( !!letter ) {
|
||||||
XP_MEMCPY( loc, letter, 1 + strlen(letter) );
|
XP_MEMCPY( loc, letter, 1 + strlen(letter) );
|
||||||
|
@ -438,7 +438,7 @@ curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
char* nump = NULL;
|
char* nump = NULL;
|
||||||
XP_UCHAR* letterp = NULL;
|
XP_UCHAR* letterp = NULL;
|
||||||
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
|
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
|
||||||
XP_Bool highlight = (flags&(CELL_HIGHLIGHT|CELL_ISCURSOR)) != 0;
|
XP_Bool highlight = (flags&(CELL_RECENT|CELL_PENDING|CELL_ISCURSOR)) != 0;
|
||||||
|
|
||||||
if ( highlight ) {
|
if ( highlight ) {
|
||||||
wstandout( dctx->boardWin );
|
wstandout( dctx->boardWin );
|
||||||
|
@ -462,7 +462,7 @@ curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
}
|
}
|
||||||
curses_stringInTile( dctx, rect, letterp, nump );
|
curses_stringInTile( dctx, rect, letterp, nump );
|
||||||
|
|
||||||
if ( (flags&CELL_HIGHLIGHT) != 0 ) {
|
if ( (flags & (CELL_RECENT|CELL_PENDING)) != 0 ) {
|
||||||
mvwaddnstr( dctx->boardWin, rect->top+rect->height-1,
|
mvwaddnstr( dctx->boardWin, rect->top+rect->height-1,
|
||||||
rect->left, "*-*", 3 );
|
rect->left, "*-*", 3 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -614,7 +614,8 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
XP_Rect rectInset = *rect;
|
XP_Rect rectInset = *rect;
|
||||||
GtkGameGlobals* globals = dctx->globals;
|
GtkGameGlobals* globals = dctx->globals;
|
||||||
XP_Bool showGrid = globals->gridOn;
|
XP_Bool showGrid = globals->gridOn;
|
||||||
XP_Bool highlight = (flags & CELL_HIGHLIGHT) != 0;
|
XP_Bool recent = (flags & CELL_RECENT) != 0;
|
||||||
|
XP_Bool pending = (flags & CELL_PENDING) != 0;
|
||||||
GdkRGBA* cursor =
|
GdkRGBA* cursor =
|
||||||
((flags & CELL_ISCURSOR) != 0) ? &dctx->cursor : NULL;
|
((flags & CELL_ISCURSOR) != 0) ? &dctx->cursor : NULL;
|
||||||
|
|
||||||
|
@ -671,7 +672,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
GdkRGBA* foreground;
|
GdkRGBA* foreground;
|
||||||
if ( cursor ) {
|
if ( cursor ) {
|
||||||
gtkSetForeground( dctx, cursor );
|
gtkSetForeground( dctx, cursor );
|
||||||
} else if ( !highlight ) {
|
} else if ( !recent && !pending ) {
|
||||||
gtkSetForeground( dctx, &dctx->tileBack );
|
gtkSetForeground( dctx, &dctx->tileBack );
|
||||||
}
|
}
|
||||||
draw_rectangle( dctx, TRUE, rectInset.left, rectInset.top,
|
draw_rectangle( dctx, TRUE, rectInset.left, rectInset.top,
|
||||||
|
@ -682,7 +683,13 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
isBlank = XP_FALSE;
|
isBlank = XP_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreground = highlight? &dctx->white : &dctx->playerColors[owner];
|
if ( pending ) {
|
||||||
|
foreground = &dctx->white;
|
||||||
|
} else if ( recent ) {
|
||||||
|
foreground = &dctx->grey;
|
||||||
|
} else {
|
||||||
|
foreground = &dctx->playerColors[owner];
|
||||||
|
}
|
||||||
draw_string_at( dctx, NULL, letter, dctx->cellHeight, &rectInset,
|
draw_string_at( dctx, NULL, letter, dctx->cellHeight, &rectInset,
|
||||||
XP_GTK_JUST_CENTER, foreground, cursor );
|
XP_GTK_JUST_CENTER, foreground, cursor );
|
||||||
|
|
||||||
|
@ -797,7 +804,7 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
||||||
insetR.left, insetR.top, insetR.width,
|
insetR.left, insetR.top, insetR.width,
|
||||||
insetR.height );
|
insetR.height );
|
||||||
|
|
||||||
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
if ( (flags & (CELL_PENDING|CELL_RECENT)) != 0 ) {
|
||||||
gtkInsetRect( &insetR, 1 );
|
gtkInsetRect( &insetR, 1 );
|
||||||
draw_rectangle( dctx, FALSE, insetR.left, insetR.top,
|
draw_rectangle( dctx, FALSE, insetR.left, insetR.top,
|
||||||
insetR.width, insetR.height);
|
insetR.width, insetR.height);
|
||||||
|
@ -821,7 +828,7 @@ gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
{
|
{
|
||||||
gtk_draw_trayBegin( p_dctx, rect, owner, 0, DFS_NONE );
|
gtk_draw_trayBegin( p_dctx, rect, owner, 0, DFS_NONE );
|
||||||
return gtkDrawTileImpl( p_dctx, rect, textP, bitmaps, val,
|
return gtkDrawTileImpl( p_dctx, rect, textP, bitmaps, val,
|
||||||
flags | CELL_HIGHLIGHT, XP_FALSE );
|
flags | (CELL_PENDING|CELL_RECENT), XP_FALSE );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -852,7 +859,7 @@ gtk_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
{
|
{
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||||
XP_Rect r = *rect;
|
XP_Rect r = *rect;
|
||||||
XP_Bool selected = 0 != (flags & CELL_HIGHLIGHT);
|
XP_Bool selected = 0 != (flags & (CELL_RECENT|CELL_PENDING));
|
||||||
XP_Bool isCursor = 0 != (flags & CELL_ISCURSOR);
|
XP_Bool isCursor = 0 != (flags & CELL_ISCURSOR);
|
||||||
|
|
||||||
gtkEraseRect( dctx, &r );
|
gtkEraseRect( dctx, &r );
|
||||||
|
|
Loading…
Reference in a new issue