mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
add dragDropSetAdd which causes mid-drag tiles to be treated as if
they're 2/3 their height higher. Meant to work better on touchscreens where finger would otherwise prevent user from seeing where the drop will land. Still not tested or tuned on device.
This commit is contained in:
parent
59aa9f6e15
commit
1073a98f9f
4 changed files with 62 additions and 17 deletions
|
@ -755,22 +755,27 @@ positionMiniWRect( BoardCtxt* board, XP_Rect* rect, XP_Bool center )
|
|||
forceRectToBoard( board, rect );
|
||||
} /*positionMiniWRect */
|
||||
|
||||
static void
|
||||
static XP_Bool
|
||||
timerFiredForPen( BoardCtxt* board )
|
||||
{
|
||||
XP_Bool draw = XP_FALSE;
|
||||
const XP_UCHAR* text = (XP_UCHAR*)NULL;
|
||||
XP_UCHAR buf[80];
|
||||
|
||||
if ( board->penDownObject == OBJ_BOARD ) {
|
||||
if ( !dragDropInProgress( board ) || !dragDropHasMoved( board ) ) {
|
||||
XP_U16 col, row;
|
||||
XWBonusType bonus;
|
||||
coordToCell( board, board->penDownX, board->penDownY, &col, &row );
|
||||
|
||||
coordToCell( board, board->penDownX, board->penDownY, &col,
|
||||
&row );
|
||||
bonus = util_getSquareBonus(board->util, board->model, col, row);
|
||||
if ( bonus != BONUS_NONE ) {
|
||||
text = draw_getMiniWText( board->draw, (XWMiniTextType)bonus );
|
||||
if ( dragDropIsBeingDragged( board, col, row, NULL ) ) {
|
||||
draw = dragDropSetAdd( board );
|
||||
} else {
|
||||
XWBonusType bonus;
|
||||
bonus = util_getSquareBonus( board->util, board->model,
|
||||
col, row );
|
||||
if ( bonus != BONUS_NONE ) {
|
||||
text = draw_getMiniWText( board->draw, (XWMiniTextType)bonus );
|
||||
}
|
||||
}
|
||||
board->penTimerFired = XP_TRUE;
|
||||
}
|
||||
|
@ -813,6 +818,7 @@ timerFiredForPen( BoardCtxt* board )
|
|||
draw_drawMiniWindow(board->draw, text, &stuff->rect,
|
||||
&stuff->closure);
|
||||
}
|
||||
return draw;
|
||||
} /* timerFiredForPen */
|
||||
|
||||
static void
|
||||
|
@ -848,16 +854,28 @@ timerFiredForTimer( BoardCtxt* board )
|
|||
static XP_Bool
|
||||
p_board_timerFired( void* closure, XWTimerReason why )
|
||||
{
|
||||
XP_Bool draw = XP_FALSE;
|
||||
BoardCtxt* board = (BoardCtxt*)closure;
|
||||
if ( why == TIMER_PENDOWN ) {
|
||||
timerFiredForPen( board );
|
||||
draw = timerFiredForPen( board );
|
||||
} else {
|
||||
XP_ASSERT( why == TIMER_TIMERTICK );
|
||||
timerFiredForTimer( board );
|
||||
}
|
||||
return XP_FALSE;
|
||||
return draw;
|
||||
} /* board_timerFired */
|
||||
|
||||
static XP_Bool
|
||||
p_tray_timerFired( void* closure, XWTimerReason why )
|
||||
{
|
||||
XP_Bool draw = XP_FALSE;
|
||||
BoardCtxt* board = (BoardCtxt*)closure;
|
||||
if ( why == TIMER_PENDOWN ) {
|
||||
draw = dragDropSetAdd( board );
|
||||
}
|
||||
return draw;
|
||||
}
|
||||
|
||||
void
|
||||
board_pushTimerSave( BoardCtxt* board )
|
||||
{
|
||||
|
@ -1661,6 +1679,7 @@ pointOnSomething( BoardCtxt* board, XP_U16 xx, XP_U16 yy, BoardObjectType* wp )
|
|||
} else if ( rectContainsPt( &board->scoreBdBounds, xx, yy ) ) {
|
||||
*wp = OBJ_SCORE;
|
||||
} else {
|
||||
*wp = OBJ_NONE;
|
||||
result = XP_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1894,7 +1913,11 @@ handleLikeDown( BoardCtxt* board, BoardObjectType onWhich, XP_U16 x, XP_U16 y )
|
|||
case OBJ_TRAY:
|
||||
if ( (board->trayVisState == TRAY_REVEALED)
|
||||
&& !board->selInfo->tradeInProgress ) {
|
||||
result = dragDropStart( board, OBJ_TRAY, x, y ) || result;
|
||||
|
||||
util_setTimer( board->util, TIMER_PENDOWN, 0,
|
||||
p_tray_timerFired, board );
|
||||
|
||||
result = dragDropStart( board, OBJ_TRAY, x, y ) || result;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ typedef struct _DragState {
|
|||
Tile tile; /* cache rather than lookup in model */
|
||||
DragObjInfo start;
|
||||
DragObjInfo cur;
|
||||
|
||||
XP_U16 yyAdd;
|
||||
} DragState;
|
||||
|
||||
typedef struct _BoardArrow { /* gets flipped along with board */
|
||||
|
|
|
@ -191,10 +191,9 @@ dragDropStart( BoardCtxt* board, BoardObjectType obj, XP_U16 x, XP_U16 y )
|
|||
XP_Bool
|
||||
dragDropContinue( BoardCtxt* board, XP_U16 xx, XP_U16 yy )
|
||||
{
|
||||
BoardObjectType ignore;
|
||||
XP_ASSERT( dragDropInProgress(board) );
|
||||
|
||||
return dragDropContinueImpl( board, xx, yy, &ignore );
|
||||
return dragDropContinueImpl( board, xx, yy, NULL );
|
||||
}
|
||||
|
||||
XP_Bool
|
||||
|
@ -284,6 +283,23 @@ dragDropEnd( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool* dragged )
|
|||
return XP_TRUE;
|
||||
} /* dragDropEnd */
|
||||
|
||||
XP_Bool
|
||||
dragDropSetAdd( BoardCtxt* board )
|
||||
{
|
||||
DragState* ds = &board->dragState;
|
||||
XP_Bool draw;
|
||||
draw = dragDropInProgress(board) && !dragDropHasMoved( board );
|
||||
if ( draw ) {
|
||||
XP_U16 xx = board->penDownX;
|
||||
XP_U16 yy = board->penDownY;
|
||||
if ( draw ) {
|
||||
ds->yyAdd = (board->trayBounds.height * 2) / 3;
|
||||
draw = dragDropContinueImpl( board, xx, yy, NULL );
|
||||
}
|
||||
}
|
||||
return draw;
|
||||
}
|
||||
|
||||
XP_Bool
|
||||
dragDropGetBoardTile( const BoardCtxt* board, XP_U16* col, XP_U16* row )
|
||||
{
|
||||
|
@ -302,7 +318,7 @@ dragDropIsBeingDragged( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
|||
{
|
||||
const DragState* ds = &board->dragState;
|
||||
XP_Bool result = ds->dtype == DT_TILE && ds->cur.obj == OBJ_BOARD;
|
||||
if ( result ) {
|
||||
if ( result && !!isOrigin ) {
|
||||
const DragState* ds = &board->dragState;
|
||||
if ( (ds->cur.obj == OBJ_BOARD) && (ds->cur.u.board.col == col)
|
||||
&& (ds->cur.u.board.row == row) ) {
|
||||
|
@ -406,10 +422,12 @@ dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
|||
DragObjInfo newInfo;
|
||||
DragState* ds = &board->dragState;
|
||||
|
||||
if ( !pointOnSomething( board, xx, yy, &newInfo.obj ) ) {
|
||||
newInfo.obj = OBJ_NONE;
|
||||
yy -= ds->yyAdd;
|
||||
|
||||
(void)pointOnSomething( board, xx, yy, &newInfo.obj );
|
||||
if ( !!onWhichP ) {
|
||||
*onWhichP = newInfo.obj;
|
||||
}
|
||||
*onWhichP = newInfo.obj;
|
||||
|
||||
if ( newInfo.obj == OBJ_BOARD ) {
|
||||
(void)coordToCell( board, xx, yy, &newInfo.u.board.col,
|
||||
|
@ -487,8 +505,8 @@ dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
|||
if ( valHintMiniWindowActive( board ) ) {
|
||||
hideMiniWindow( board, XP_TRUE, MINIWINDOW_VALHINT );
|
||||
}
|
||||
ds->didMove = XP_TRUE;
|
||||
}
|
||||
ds->didMove = XP_TRUE;
|
||||
}
|
||||
|
||||
return moving;
|
||||
|
|
|
@ -36,6 +36,8 @@ XP_Bool dragDropStart( BoardCtxt* board, BoardObjectType obj,
|
|||
XP_Bool dragDropContinue( BoardCtxt* board, XP_U16 xx, XP_U16 yy );
|
||||
XP_Bool dragDropEnd( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool* dragged );
|
||||
|
||||
XP_Bool dragDropSetAdd( BoardCtxt* board );
|
||||
|
||||
XP_Bool dragDropGetBoardTile( const BoardCtxt* board, XP_U16* col, XP_U16* row );
|
||||
XP_Bool dragDropIsBeingDragged( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_Bool* isOrigin );
|
||||
|
|
Loading…
Add table
Reference in a new issue