Hide crosshairs once drag leaves the initial cell UNLESS a tile is

being dragged
This commit is contained in:
Eric House 2014-08-21 07:51:06 -07:00
parent b77d529099
commit e42dd971cb

View file

@ -41,10 +41,11 @@ static void setLimitsFrom( const BoardCtxt* board, BdHintLimits* limits );
#endif #endif
#ifdef XWFEATURE_CROSSHAIRS #ifdef XWFEATURE_CROSSHAIRS
static XP_Bool crosshairs_set( BoardCtxt* board, XP_S16 col, XP_S16 row ); static XP_Bool crosshairs_set( BoardCtxt* board, XP_S16 col, XP_S16 row,
XP_Bool clearOnMove );
static void crosshairs_clear( BoardCtxt* board ); static void crosshairs_clear( BoardCtxt* board );
#else #else
# define crosshairs_set( board, col, row ) XP_FALSE; # define crosshairs_set( board, col, row, com ) XP_FALSE;
# define crosshairs_clear( board ) # define crosshairs_clear( board )
#endif #endif
@ -96,7 +97,7 @@ ddStartBoard( BoardCtxt* board, XP_U16 xx, XP_U16 yy )
XP_ASSERT( found ); XP_ASSERT( found );
#ifdef XWFEATURE_CROSSHAIRS #ifdef XWFEATURE_CROSSHAIRS
if ( !board->hideCrosshairs ) { if ( !board->hideCrosshairs ) {
(void)crosshairs_set( board, col, row ); (void)crosshairs_set( board, col, row, XP_FALSE );
} }
#endif #endif
@ -493,7 +494,8 @@ dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
#ifdef XWFEATURE_CROSSHAIRS #ifdef XWFEATURE_CROSSHAIRS
if ( !board->hideCrosshairs ) { if ( !board->hideCrosshairs ) {
draw = crosshairs_set( board, newInfo.u.board.col, draw = crosshairs_set( board, newInfo.u.board.col,
newInfo.u.board.row ); newInfo.u.board.row,
DT_TILE != ds->dtype );
} }
#endif #endif
} }
@ -693,11 +695,19 @@ dragDropInCrosshairs( const BoardCtxt* board, XP_U16 col, XP_U16 row,
} /* dragDropInCrosshairs */ } /* dragDropInCrosshairs */
static XP_Bool static XP_Bool
crosshairs_set( BoardCtxt* board, XP_S16 col, XP_S16 row ) crosshairs_set( BoardCtxt* board, XP_S16 col, XP_S16 row, XP_Bool clearOnMove )
{ {
XP_Bool changed = XP_FALSE; XP_Bool changed;
DragState* ds = &board->dragState; DragState* ds = &board->dragState;
if ( ds->crosshairs.col != col ) {
XP_Bool colMoving = ds->crosshairs.col != col;
XP_Bool rowMoving = ds->crosshairs.row != row;
if ( clearOnMove && (colMoving || rowMoving) ) {
changed = XP_TRUE;
crosshairs_clear( board );
} else {
changed = XP_FALSE;
if ( colMoving ) {
if ( ds->crosshairs.col >= 0 ) { if ( ds->crosshairs.col >= 0 ) {
invalCol( board, ds->crosshairs.col ); invalCol( board, ds->crosshairs.col );
} }
@ -707,7 +717,7 @@ crosshairs_set( BoardCtxt* board, XP_S16 col, XP_S16 row )
ds->crosshairs.col = col; ds->crosshairs.col = col;
changed = XP_TRUE; changed = XP_TRUE;
} }
if ( ds->crosshairs.row != row ) { if ( rowMoving ) {
if ( ds->crosshairs.row >= 0 ) { if ( ds->crosshairs.row >= 0 ) {
invalRow( board, ds->crosshairs.row ); invalRow( board, ds->crosshairs.row );
} }
@ -717,13 +727,14 @@ crosshairs_set( BoardCtxt* board, XP_S16 col, XP_S16 row )
ds->crosshairs.row = row; ds->crosshairs.row = row;
changed = XP_TRUE; changed = XP_TRUE;
} }
}
return changed; return changed;
} }
static void static void
crosshairs_clear( BoardCtxt* board ) crosshairs_clear( BoardCtxt* board )
{ {
crosshairs_set( board, -1, -1 ); crosshairs_set( board, -1, -1, XP_FALSE );
} }
#endif #endif