When moving focus through tray, skip empty space; when through board,

skip cells with tiles permanently played.  Space char raises focus but does
not move it laterally.
This commit is contained in:
ehouse 2006-11-09 06:05:40 +00:00
parent 80adc9fb6b
commit c91847f56f
6 changed files with 35 additions and 28 deletions

View file

@ -2735,9 +2735,11 @@ board_handleKey( BoardCtxt* board, XP_Key key )
break;
#ifdef KEYBOARD_NAV
case XP_FOCUSCHANGE_KEY:
if ( board->focussed != OBJ_NONE ) {
shiftFocusUp( board, XP_CURSOR_KEY_RIGHT );
case XP_RAISEFOCUS_KEY:
if ( board->focussed != OBJ_NONE && board->focusHasDived ) {
invalFocusOwner( board );
board->focusHasDived = XP_FALSE;
invalFocusOwner( board );
result = XP_TRUE;
}
break;
@ -2939,7 +2941,7 @@ advanceArrow( BoardCtxt* board )
static XP_Bool
figureNextLoc( BoardCtxt* board, XP_Key cursorKey, XP_Bool canShiftFocus,
XP_Bool avoidOccupied, XP_U16* colP, XP_U16* rowP )
XP_Bool inclPending, XP_U16* colP, XP_U16* rowP )
{
XP_S16 max;
XP_S16* useWhat;
@ -2997,8 +2999,7 @@ figureNextLoc( BoardCtxt* board, XP_Key cursorKey, XP_Bool canShiftFocus,
}
result = XP_TRUE;
*useWhat += incr;
if ( !avoidOccupied
|| !cellOccupied( board, *colP, *rowP, XP_TRUE ) ) {
if ( !cellOccupied( board, *colP, *rowP, inclPending ) ) {
break;
}
}

View file

@ -42,7 +42,7 @@ typedef enum {
XP_CURSOR_KEY_UP,
XP_CURSOR_KEY_LEFT,
XP_CURSOR_KEY_DEL,
XP_FOCUSCHANGE_KEY,
XP_RAISEFOCUS_KEY,
XP_RETURN_KEY,
XP_KEY_LAST

View file

@ -35,7 +35,7 @@ XP_Key_2str( XP_Key key )
CASESTR(XP_CURSOR_KEY_UP);
CASESTR(XP_CURSOR_KEY_LEFT);
CASESTR(XP_CURSOR_KEY_DEL);
CASESTR(XP_FOCUSCHANGE_KEY);
CASESTR(XP_RAISEFOCUS_KEY);
CASESTR(XP_RETURN_KEY);
CASESTR(XP_KEY_LAST );
default: return FUNC(__FUNCTION__) " unknown";

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 1997 - 2000 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 1997 - 2006 by Eric House (xwords@eehouse.org). All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -628,14 +628,24 @@ tray_moveCursor( BoardCtxt* board, XP_Key cursorKey )
board_invalTrayTiles( board, 1 << board->trayCursorLoc[selPlayer] );
pos = board->trayCursorLoc[selPlayer];
pos += cursorKey == XP_CURSOR_KEY_RIGHT ? 1 : -1;
if ( pos < 0 || pos >= MAX_TRAY_TILES ) {
shiftFocusUp( board, cursorKey );
} else {
board->trayCursorLoc[selPlayer] = pos;
board_invalTrayTiles( board, 1 << pos );
/* 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 ) {
shiftFocusUp( board, cursorKey );
} else {
if ( board->trayVisState == TRAY_REVEALED ) {
XP_U16 count = model_getNumTilesInTray( board->model,
selPlayer );
if ( (pos > count) && (pos < MAX_TRAY_TILES-1) ) {
continue;
}
}
board->trayCursorLoc[selPlayer] = pos;
board_invalTrayTiles( board, 1 << pos );
}
break;
}
board_invalTrayTiles( board, 1 << board->trayCursorLoc[selPlayer] );
result = XP_TRUE;
}

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; compile-command: "make MEMDEBUG=TRUE"; -*- */
/*
* Copyright 2000 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 2000-2006 by Eric House (xwords@eehouse.org). All rights
* reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -357,14 +358,14 @@ checkAssignFocus( BoardCtxt* board )
}
static XP_Bool
handleTab( CursesAppGlobals* globals )
handleSpace( CursesAppGlobals* globals )
{
checkAssignFocus( globals->cGlobals.game.board );
globals->doDraw = board_handleKey( globals->cGlobals.game.board,
XP_FOCUSCHANGE_KEY );
XP_RAISEFOCUS_KEY );
return XP_TRUE;
} /* handleTab */
} /* handleSpace */
static XP_Bool
handleRet( CursesAppGlobals* globals )
@ -453,7 +454,8 @@ handleReplace( CursesAppGlobals* globals )
MenuList sharedMenuList[] = {
{ handleQuit, "Quit", "Q", 'Q' },
{ handleTab, "Change focus", "<tab>", '\t' },
{ handleRight, "Tab right", "<tab>", '\t' },
{ handleSpace, "Raise focus", "<spc>", ' ' },
{ handleRet, "Click/tap", "<ret>", '\r' },
{ handleHint, "Hint", "?", '?' },

View file

@ -2559,7 +2559,7 @@ mainViewHandleEvent( EventPtr event )
xpkey = XP_CURSOR_KEY_DOWN;
break;
case chrSpace:
xpkey = XP_FOCUSCHANGE_KEY;
xpkey = XP_RAISEFOCUS_KEY;
break;
#endif
default:
@ -2578,12 +2578,6 @@ mainViewHandleEvent( EventPtr event )
}
if ( xpkey != XP_KEY_NONE ) {
draw = board_handleKey( globals->game.board, xpkey );
#ifdef XWFEATURE_FIVEWAY
if ( xpkey == XP_FOCUSCHANGE_KEY ) {
checkSetFocus( globals,
board_getFocusOwner( globals->game.board ) );
}
#endif
}
handled = draw;
}