mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
When moving cursor within board, scroll board if it's possible to do
so, and only if it is not move the cursor (or if needed to keep it visible after scroll.) This makes it easier for users to scroll -- but may not be needed if focussing scrolbar works.
This commit is contained in:
parent
949a67b15f
commit
42ad517e52
2 changed files with 52 additions and 15 deletions
|
@ -1965,7 +1965,8 @@ moveSelTileToBoardXY( BoardCtxt* board, XP_U16 col, XP_U16 row )
|
|||
} /* moveSelTileToBoardXY */
|
||||
|
||||
XP_Bool
|
||||
cellOccupied( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool inclPending )
|
||||
cellOccupied( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_Bool inclPending )
|
||||
{
|
||||
Tile tile;
|
||||
XP_Bool ignr;
|
||||
|
@ -2487,7 +2488,7 @@ advanceArrow( BoardCtxt* board )
|
|||
} /* advanceArrow */
|
||||
|
||||
static XP_Bool
|
||||
figureNextLoc( BoardCtxt* board, XP_Key cursorKey,
|
||||
figureNextLoc( const BoardCtxt* board, XP_Key cursorKey,
|
||||
XP_Bool inclPending, XP_Bool forceFirst,
|
||||
XP_U16* colP, XP_U16* rowP,
|
||||
XP_Bool* XP_UNUSED_KEYBOARD_NAV(pUp) )
|
||||
|
@ -2597,28 +2598,64 @@ stripAlt( XP_Key key, XP_Bool* wasAlt )
|
|||
return key;
|
||||
} /* stripAlt */
|
||||
|
||||
static XP_Bool
|
||||
scrollTrumpsMove( const BoardCtxt* board, XP_Key cursorKey, XP_S16* moveBy )
|
||||
{
|
||||
XP_Bool scroll = XP_FALSE;
|
||||
if ( XP_CURSOR_KEY_DOWN == cursorKey ) {
|
||||
scroll = (board->lastVisibleRow+1) < model_numRows( board->model );
|
||||
if ( scroll ) {
|
||||
*moveBy = -1;
|
||||
}
|
||||
} else if ( XP_CURSOR_KEY_UP == cursorKey ) {
|
||||
scroll = board->yOffset > 0;
|
||||
if ( scroll ) {
|
||||
*moveBy = 1;
|
||||
}
|
||||
}
|
||||
return scroll;
|
||||
}
|
||||
|
||||
static XP_Bool
|
||||
board_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly,
|
||||
XP_Bool* up )
|
||||
{
|
||||
PerTurnInfo* pti = board->selInfo;
|
||||
BdCursorLoc loc = pti->bdCursor;
|
||||
XP_U16 col = loc.col;
|
||||
XP_U16 row = loc.row;
|
||||
BdCursorLoc loc;
|
||||
XP_S16 moveBy;
|
||||
XP_Bool changed;
|
||||
XP_Bool needMove = XP_FALSE;
|
||||
|
||||
XP_Bool altSet;
|
||||
cursorKey = stripAlt( cursorKey, &altSet );
|
||||
|
||||
changed = figureNextLoc( board, cursorKey, XP_FALSE, altSet,
|
||||
&col, &row, up );
|
||||
if ( changed && !preflightOnly ) {
|
||||
invalCell( board, loc.col, loc.row );
|
||||
invalCell( board, col, row );
|
||||
loc.col = col;
|
||||
loc.row = row;
|
||||
pti->bdCursor = loc;
|
||||
checkScrollCell( board, col, row );
|
||||
changed = !preflightOnly
|
||||
&& scrollTrumpsMove( board, cursorKey, &moveBy );
|
||||
if ( changed ) {
|
||||
if ( adjustYOffset( board, moveBy ) ) {
|
||||
/* need to move the cursor too? */
|
||||
XP_Rect ignore;
|
||||
loc = pti->bdCursor;
|
||||
needMove = !getCellRect( board, loc.col, loc.row, &ignore );
|
||||
}
|
||||
}
|
||||
|
||||
/* PENDING: Is it a problem that needMove will only get set if
|
||||
preflightOnly is false? */
|
||||
if ( !changed || needMove ) {
|
||||
XP_U16 col, row;
|
||||
loc = pti->bdCursor;
|
||||
col = loc.col;
|
||||
row = loc.row;
|
||||
changed = figureNextLoc( board, cursorKey, XP_FALSE, altSet,
|
||||
&col, &row, up );
|
||||
if ( changed && !preflightOnly ) {
|
||||
invalCell( board, loc.col, loc.row );
|
||||
invalCell( board, col, row );
|
||||
loc.col = col;
|
||||
loc.row = row;
|
||||
pti->bdCursor = loc;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
} /* board_moveCursor */
|
||||
|
|
|
@ -230,7 +230,7 @@ XP_Bool pointOnSomething( BoardCtxt* board, XP_U16 x, XP_U16 y,
|
|||
BoardObjectType* wp );
|
||||
XP_Bool coordToCell( BoardCtxt* board, XP_U16 x, XP_U16 y, XP_U16* colP,
|
||||
XP_U16* rowP );
|
||||
XP_Bool cellOccupied( BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_Bool cellOccupied( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||
XP_Bool inclPending );
|
||||
XP_Bool holdsPendingTile( BoardCtxt* board, XP_U16 pencol, XP_U16 penrow );
|
||||
|
||||
|
|
Loading…
Reference in a new issue