mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
Add feature lost when five-way drag of divider became possible: don't
allow focus rect to stop on any empty tray slot but the leftmost.
This commit is contained in:
parent
ac0a9f4ac5
commit
0c751cc4d1
1 changed files with 56 additions and 111 deletions
|
@ -555,7 +555,6 @@ adjustForDivider( const BoardCtxt* board, XP_S16* index )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly,
|
tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly,
|
||||||
XP_Bool* pUp )
|
XP_Bool* pUp )
|
||||||
|
@ -570,130 +569,76 @@ tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly,
|
||||||
XP_S16 delta = cursorKey == XP_CURSOR_KEY_RIGHT ? 1 : -1;
|
XP_S16 delta = cursorKey == XP_CURSOR_KEY_RIGHT ? 1 : -1;
|
||||||
const XP_U16 selPlayer = board->selPlayer;
|
const XP_U16 selPlayer = board->selPlayer;
|
||||||
PerTurnInfo* pti = board->selInfo;
|
PerTurnInfo* pti = board->selInfo;
|
||||||
XP_S16 trayCursorLoc = pti->trayCursorLoc;
|
XP_S16 trayCursorLoc;
|
||||||
XP_S16 newLoc = trayCursorLoc + delta;
|
XP_S16 newLoc;
|
||||||
if ( newLoc < 0 || newLoc > MAX_TRAY_TILES ) {
|
for ( ; ; ) {
|
||||||
XP_LOGF( "moving up: newLoc: %d", newLoc );
|
trayCursorLoc = pti->trayCursorLoc;
|
||||||
up = XP_TRUE;
|
newLoc = trayCursorLoc + delta;
|
||||||
} else if ( !preflightOnly ) {
|
if ( newLoc < 0 || newLoc > MAX_TRAY_TILES ) {
|
||||||
XP_S16 tileLoc = trayCursorLoc;
|
up = XP_TRUE;
|
||||||
XP_U16 nTiles = model_getNumTilesInTray( board->model, selPlayer );
|
} else if ( !preflightOnly ) {
|
||||||
XP_Bool cursorOnDivider = trayCursorLoc == pti->dividerLoc;
|
XP_S16 tileLoc = trayCursorLoc;
|
||||||
XP_Bool cursorObjSelected;
|
XP_U16 nTiles = model_getNumTilesInTray( board->model, selPlayer );
|
||||||
|
XP_Bool cursorOnDivider = trayCursorLoc == pti->dividerLoc;
|
||||||
adjustForDivider( board, &tileLoc );
|
XP_Bool cursorObjSelected;
|
||||||
cursorObjSelected = cursorOnDivider?
|
|
||||||
pti->dividerSelected : pti->traySelBits == (1 << tileLoc);
|
|
||||||
|
|
||||||
if ( !cursorObjSelected ) {
|
|
||||||
/* nothing to do */
|
|
||||||
} else if ( cursorOnDivider ) {
|
|
||||||
/* just drag the divider */
|
|
||||||
pti->dividerLoc = newLoc;
|
|
||||||
} else if ( pti->tradeInProgress ) {
|
|
||||||
/* nothing to do */
|
|
||||||
} else {
|
|
||||||
XP_S16 newTileLoc;
|
XP_S16 newTileLoc;
|
||||||
|
|
||||||
/* drag the tile, skipping over the divider if needed */
|
adjustForDivider( board, &tileLoc );
|
||||||
if ( (newLoc == pti->dividerLoc) && (newLoc > 0) ) {
|
cursorObjSelected = cursorOnDivider?
|
||||||
newLoc += delta;
|
pti->dividerSelected : pti->traySelBits == (1 << tileLoc);
|
||||||
|
|
||||||
|
if ( !cursorObjSelected ) {
|
||||||
|
/* nothing to do */
|
||||||
|
} else if ( cursorOnDivider ) {
|
||||||
|
/* just drag the divider */
|
||||||
|
pti->dividerLoc = newLoc;
|
||||||
|
} else if ( pti->tradeInProgress ) {
|
||||||
|
/* nothing to do */
|
||||||
|
} else {
|
||||||
|
/* drag the tile, skipping over the divider if needed */
|
||||||
|
if ( (newLoc == pti->dividerLoc) && (newLoc > 0) ) {
|
||||||
|
newLoc += delta;
|
||||||
|
}
|
||||||
|
newTileLoc = newLoc;
|
||||||
|
adjustForDivider( board, &newTileLoc );
|
||||||
|
|
||||||
|
if ( newTileLoc >= 0 ) {
|
||||||
|
XP_ASSERT( tileLoc < nTiles );
|
||||||
|
if ( newTileLoc < nTiles ) {
|
||||||
|
model_moveTileOnTray( board->model, selPlayer,
|
||||||
|
tileLoc, newTileLoc );
|
||||||
|
pti->traySelBits = (1 << newTileLoc);
|
||||||
|
} else {
|
||||||
|
pti->traySelBits = 0; /* clear selection */
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
pti->trayCursorLoc = newLoc;
|
||||||
|
|
||||||
|
/* Check if we're settling on an empty tile location other
|
||||||
|
than the rightmost one. If so, loop back and move
|
||||||
|
further. */
|
||||||
newTileLoc = newLoc;
|
newTileLoc = newLoc;
|
||||||
adjustForDivider( board, &newTileLoc );
|
adjustForDivider( board, &newTileLoc );
|
||||||
|
|
||||||
if ( newTileLoc >= 0 ) {
|
if ( (newTileLoc > nTiles)
|
||||||
XP_ASSERT( tileLoc < nTiles );
|
&& (newLoc != pti->dividerLoc)
|
||||||
if ( newTileLoc < nTiles ) {
|
&& (newTileLoc < MAX_TRAY_TILES-1) ) {
|
||||||
model_moveTileOnTray( board->model, selPlayer,
|
continue;
|
||||||
tileLoc, newTileLoc );
|
|
||||||
pti->traySelBits = (1 << newTileLoc);
|
|
||||||
} else {
|
|
||||||
pti->traySelBits = 0; /* clear selection */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pti->trayCursorLoc = newLoc;
|
break; /* always exit loop if we get here */
|
||||||
|
|
||||||
/* fix this!!! */
|
|
||||||
board->dividerInvalid = XP_TRUE;
|
|
||||||
board_invalTrayTiles( board, ALLTILES );
|
|
||||||
}
|
}
|
||||||
draw = XP_TRUE;
|
|
||||||
|
/* fix this!!! */
|
||||||
|
board->dividerInvalid = XP_TRUE;
|
||||||
|
board_invalTrayTiles( board, ALLTILES );
|
||||||
}
|
}
|
||||||
|
draw = XP_TRUE;
|
||||||
|
|
||||||
*pUp = up;
|
*pUp = up;
|
||||||
return draw;
|
return draw;
|
||||||
} /* tray_moveCursor */
|
} /* tray_moveCursor */
|
||||||
#else
|
|
||||||
XP_Bool
|
|
||||||
tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly,
|
|
||||||
XP_Bool* pUp )
|
|
||||||
{
|
|
||||||
XP_Bool draw = XP_FALSE;
|
|
||||||
XP_Bool up = XP_FALSE;
|
|
||||||
const XP_U16 selPlayer = board->selPlayer;
|
|
||||||
PerTurnInfo* pti = board->selInfo;
|
|
||||||
XP_S16 pos;
|
|
||||||
TileBit what = 0;
|
|
||||||
|
|
||||||
switch ( cursorKey ) {
|
|
||||||
case XP_CURSOR_KEY_UP:
|
|
||||||
case XP_CURSOR_KEY_DOWN:
|
|
||||||
up = XP_TRUE;
|
|
||||||
break;
|
|
||||||
/* moving the divider needs to be hard to do accidentally since it
|
|
||||||
confuses users when juggle and hint stop working. But all things
|
|
||||||
must be possible via keyboard on devices that don't have
|
|
||||||
touchscreens. Probably need a new keytype XP_CURSOR_KEY_ALTDOWN
|
|
||||||
etc. */
|
|
||||||
case XP_CURSOR_KEY_ALTRIGHT:
|
|
||||||
case XP_CURSOR_KEY_ALTLEFT:
|
|
||||||
draw = preflightOnly
|
|
||||||
|| board_moveDivider( board, cursorKey == XP_CURSOR_KEY_ALTRIGHT );
|
|
||||||
break;
|
|
||||||
case XP_CURSOR_KEY_RIGHT:
|
|
||||||
case XP_CURSOR_KEY_LEFT:
|
|
||||||
what = what | (1 << pti->trayCursorLoc);
|
|
||||||
pos = pti->trayCursorLoc;
|
|
||||||
/* Loop in order to skip all empty tile slots but one */
|
|
||||||
for ( ; ; ) {
|
|
||||||
pos += (cursorKey == XP_CURSOR_KEY_RIGHT ? 1 : -1);
|
|
||||||
if ( pos < 0 || pos >= MAX_TRAY_TILES ) {
|
|
||||||
up = XP_TRUE;
|
|
||||||
} else {
|
|
||||||
/* Revisit this when able to never draw the cursor in a place
|
|
||||||
this won't allow it, e.g. when the tiles move after a
|
|
||||||
hint */
|
|
||||||
if ( board->trayVisState == TRAY_REVEALED ) {
|
|
||||||
XP_U16 count = model_getNumTilesInTray( board->model,
|
|
||||||
selPlayer );
|
|
||||||
if ( (pos > count) && (pos < MAX_TRAY_TILES-1) ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !preflightOnly ) {
|
|
||||||
pti->trayCursorLoc = pos;
|
|
||||||
what = what | (1 << pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ( !preflightOnly ) {
|
|
||||||
what = what | (1 << pti->trayCursorLoc);
|
|
||||||
board_invalTrayTiles( board, what );
|
|
||||||
}
|
|
||||||
draw = XP_TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
draw = XP_FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pUp = up;
|
|
||||||
return draw;
|
|
||||||
} /* tray_moveCursor */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
getFocussedTileCenter( BoardCtxt* board, XP_U16* xp, XP_U16* yp )
|
getFocussedTileCenter( BoardCtxt* board, XP_U16* xp, XP_U16* yp )
|
||||||
|
|
Loading…
Reference in a new issue