Get rid of draw_eraseMiniWindow: just inval what's under it; make use

of CELL_ISCURSOR consistent: when focus not dived all elements have it
set (or only perimeter for board, settable at compile time); get rid
of draw_drawCursor since CELL_ISCURSOR is all that's needed;
This commit is contained in:
ehouse 2007-01-19 08:20:11 +00:00
parent 3a0b5af472
commit c5fe2a7589
4 changed files with 87 additions and 98 deletions

View file

@ -76,7 +76,7 @@ static XP_Bool getCellRect( BoardCtxt* board, XP_U16 col, XP_U16 row,
static XP_Bool coordToCell( BoardCtxt* board, XP_U16 x, XP_U16 y,
XP_U16* colP, XP_U16* rowP );
static XP_Bool drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row,
XP_Bool skipBlanks, XP_Bool cellFocused );
XP_Bool skipBlanks );
static void figureBoardRect( BoardCtxt* board );
static void drawBoard( BoardCtxt* board );
@ -501,14 +501,9 @@ invalSelTradeWindow( BoardCtxt* board )
static void
hideMiniWindow( BoardCtxt* board, XP_Bool destroy, MiniWindowType winType )
{
XP_Bool invalCovers;
MiniWindowStuff* stuff = &board->miniWindowStuff[winType];
draw_eraseMiniWindow( board->draw, &stuff->rect,
destroy, &stuff->closure, &invalCovers );
if ( invalCovers ) {
board_invalRect( board, &stuff->rect );
}
board_invalRect( board, &stuff->rect );
if ( destroy ) {
stuff->text = (XP_UCHAR*)NULL;
@ -884,6 +879,25 @@ board_invalAllTiles( BoardCtxt* board )
board->needsDrawing = XP_TRUE;
} /* board_invalAllTiles */
#ifdef KEYBOARD_NAV
#ifdef PERIMETER_FOCUS
static void
board_invalPerimeter( BoardCtxt* board )
{
XP_U16 lastRow = model_numRows( board->model ) - 1;
XP_U16 firstAndLast = (1 << lastRow) | 1;
/* top and bottom rows */
board->redrawFlags[lastRow] = ~0;
board->redrawFlags[0] = ~0;
while ( --lastRow > 0 ) {
board->redrawFlags[lastRow] |= firstAndLast;
}
}
#endif
#endif
void
board_invalAll( BoardCtxt* board )
{
@ -1049,6 +1063,34 @@ board_draw( BoardCtxt* board )
return !board->needsDrawing;
} /* board_draw */
#ifdef KEYBOARD_NAV
static XP_Bool
cellFocused( const BoardCtxt* board, XP_U16 col, XP_U16 row )
{
XP_Bool focussed = XP_FALSE;
if ( board->focussed == OBJ_BOARD ) {
if ( board->focusHasDived ) {
if ( (col == board->bdCursor[board->selPlayer].col)
&& (row == board->bdCursor[board->selPlayer].row) ) {
focussed = XP_TRUE;
}
} else {
#ifdef PERIMETER_FOCUS
focussed = (col == 0) || (row == 0);
if ( !focussed ) {
XP_U16 lastRow = model_numRows( board->model ) - 1;
focussed = (col == lastRow) || (row == lastRow);
}
#else
focussed = XP_TRUE;
#endif
}
}
return focussed;
} /* cellFocused */
#endif
static void
drawBoard( BoardCtxt* board )
{
@ -1064,17 +1106,6 @@ drawBoard( BoardCtxt* board )
ModelCtxt* model = board->model;
BlankQueue bq;
XP_Rect arrowRect;
#ifdef KEYBOARD_NAV
XP_Bool someCellFocused =
(board->focussed == OBJ_BOARD) && board->focusHasDived;
BdCursorLoc cursorLoc;
if ( someCellFocused ) {
cursorLoc = board->bdCursor[board->selPlayer];
}
#else
# define someCellFocused XP_FALSE
#endif
scrollIfCan( board ); /* this must happen before we count blanks
since it invalidates squares */
@ -1094,8 +1125,7 @@ drawBoard( BoardCtxt* board )
lastCol = model_numCols( model );
for ( colMask = 1<<(lastCol-1); lastCol--; colMask >>= 1 ) {
if ( (rowFlags & colMask) != 0 ) {
if ( !drawCell( board, lastCol, row, XP_TRUE,
someCellFocused )) {
if ( !drawCell( board, lastCol, row, XP_TRUE )) {
failedBits |= colMask;
allDrawn = XP_FALSE;
}
@ -1107,8 +1137,7 @@ drawBoard( BoardCtxt* board )
/* draw the blanks we skipped before */
for ( i = 0; i < bq.nBlanks; ++i ) {
if ( !drawCell( board, bq.col[i], bq.row[i], XP_FALSE,
someCellFocused ) ) {
if ( !drawCell( board, bq.col[i], bq.row[i], XP_FALSE ) ) {
allDrawn = XP_FALSE;
}
}
@ -1129,10 +1158,8 @@ drawBoard( BoardCtxt* board )
col, row );
hintAtts = figureHintAtts( board, col, row );
#ifdef KEYBOARD_NAV
if ( someCellFocused ) {
if ( cursorLoc.col == col && cursorLoc.row == row ) {
flags |= CELL_ISCURSOR;
}
if ( cellFocused( board, col, row ) ) {
flags |= CELL_ISCURSOR;
}
#endif
draw_drawBoardArrow( board->draw, &arrowRect, bonus,
@ -1141,15 +1168,6 @@ drawBoard( BoardCtxt* board )
}
}
#ifdef KEYBOARD_NAV
if ( someCellFocused ) {
XP_Rect crect;
if ( getCellRect( board, cursorLoc.col, cursorLoc.row, &crect ) ){
draw_drawCursor( board->draw, OBJ_BOARD, &crect );
}
}
#endif
drawTradeWindowIf( board );
draw_objFinished( board->draw, OBJ_BOARD, &board->boardBounds,
@ -1582,8 +1600,7 @@ board_requestHint( BoardCtxt* board,
} /* board_requestHint */
static XP_Bool
drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks,
XP_Bool XP_UNUSED_KEYBOARD_NAV(cellFocused) )
drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
{
XP_Rect cellRect;
Tile tile;
@ -1656,9 +1673,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks,
flags |= CELL_ISBLANK;
}
#ifdef KEYBOARD_NAV
if ( cellFocused
&& (col == board->bdCursor[selPlayer].col)
&& (row == board->bdCursor[selPlayer].row) ) {
if ( cellFocused( board, col, row ) ) {
flags |= CELL_ISCURSOR;
}
#endif
@ -2624,30 +2639,6 @@ handleFocusKeyUp( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly,
return redraw;
} /* handleFocusKeyUp */
XP_Bool
board_handleKeyDown( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
{
XP_Bool draw = XP_FALSE;
XP_U16 x, y;
*pHandled = XP_FALSE;
if ( key == XP_RETURN_KEY ) {
if ( focusToCoords( board, &x, &y ) ) {
draw = handleLikeDown( board, board->focussed, x, y );
*pHandled = draw;
}
} else if ( board->focussed != OBJ_NONE ) {
if ( board->focusHasDived && (key == XP_RAISEFOCUS_KEY) ) {
*pHandled = XP_TRUE;
} else {
draw = handleFocusKeyUp( board, key, XP_TRUE, pHandled ) || draw;
}
}
return draw;
}
XP_Bool
board_handleKeyRepeat( BoardCtxt* board, XP_Key key, XP_Bool* handled )
{
@ -2666,6 +2657,31 @@ board_handleKeyRepeat( BoardCtxt* board, XP_Key key, XP_Bool* handled )
#endif /* KEYBOARD_NAV */
#ifdef KEY_SUPPORT
XP_Bool
board_handleKeyDown( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
{
XP_Bool draw = XP_FALSE;
#ifdef KEYBOARD_NAV
XP_U16 x, y;
*pHandled = XP_FALSE;
if ( key == XP_RETURN_KEY ) {
if ( focusToCoords( board, &x, &y ) ) {
draw = handleLikeDown( board, board->focussed, x, y );
*pHandled = draw;
}
} else if ( board->focussed != OBJ_NONE ) {
if ( board->focusHasDived && (key == XP_RAISEFOCUS_KEY) ) {
*pHandled = XP_TRUE;
} else {
draw = handleFocusKeyUp( board, key, XP_TRUE, pHandled ) || draw;
}
}
#endif
return draw;
} /* board_handleKeyDown */
XP_Bool
board_handleKeyUp( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
{
@ -2746,11 +2762,9 @@ board_handleKey( BoardCtxt* board, XP_Key key, XP_Bool* handled )
*handled = handled1 || handled2;
return draw;
}
#endif
#endif /* KEY_SUPPORT */
#ifdef KEYBOARD_NAV
static XP_Bool
invalFocusOwner( BoardCtxt* board )
{
@ -2765,7 +2779,11 @@ invalFocusOwner( BoardCtxt* board )
BdCursorLoc loc = board->bdCursor[selPlayer];
invalCell( board, loc.col, loc.row );
} else {
#ifdef PERIMETER_FOCUS
board_invalPerimeter( board );
#else
board_invalAllTiles( board );
#endif
}
break;
case OBJ_TRAY:

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 1997 - 2002 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 1997 - 2007 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
@ -175,20 +175,12 @@ typedef struct DrawCtxVTable {
XWBonusType bonus, XP_Bool vert,
HintAtts hintAtts,
CellFlags flags);
#ifdef KEY_SUPPORT
void DRAW_VTABLE_NAME(drawCursor) ( DrawCtx* dctx, BoardObjectType typ,
const XP_Rect* rect );
#endif
XP_UCHAR* DRAW_VTABLE_NAME(getMiniWText) ( DrawCtx* dctx,
XWMiniTextType textHint );
void DRAW_VTABLE_NAME(measureMiniWText) ( DrawCtx* dctx, const XP_UCHAR* textP,
XP_U16* width, XP_U16* height );
void DRAW_VTABLE_NAME(drawMiniWindow)( DrawCtx* dctx, const XP_UCHAR* text,
const XP_Rect* rect, void** closure );
void DRAW_VTABLE_NAME(eraseMiniWindow)( DrawCtx* dctx, const XP_Rect* rect,
XP_Bool lastTime, void** closure,
XP_Bool* invalUnder );
#ifndef DRAW_LINK_DIRECT
} DrawCtxVTable; /* */
#endif
@ -266,19 +258,12 @@ struct DrawCtx {
#define draw_clearRect( dc, rect ) CALL_DRAW_NAME1(clearRect,(dc),(rect))
#define draw_drawBoardArrow( dc, r, b, v, h, f ) \
CALL_DRAW_NAME5(drawBoardArrow,(dc),(r),(b), (v), (h), (f))
#ifdef KEY_SUPPORT
# define draw_drawCursor( dc, t, r ) CALL_DRAW_NAME2(drawCursor,(dc),(t),(r))
#else
# define draw_drawCursor( dc, t, r )
#endif
#define draw_getMiniWText( dc, b ) CALL_DRAW_NAME1(getMiniWText, (dc),(b) )
#define draw_measureMiniWText( dc, t, wp, hp) \
CALL_DRAW_NAME3(measureMiniWText, (dc),(t), (wp), (hp) )
#define draw_drawMiniWindow( dc, t, r, c ) \
CALL_DRAW_NAME3(drawMiniWindow, (dc), (t), (r), (c) )
#define draw_eraseMiniWindow(dc, r, l, c, b) \
CALL_DRAW_NAME4(eraseMiniWindow, (dc), (r), (l), (c), (b) )
#ifdef DRAW_WITH_PRIMITIVES
# define draw_setClip( dc, rn, ro ) CALL_DRAW_NAME2(setClip, (dc), (rn), (ro))

View file

@ -182,12 +182,6 @@ drawScoreBoard( BoardCtxt* board )
*adjustPt += *adjustDim;
}
#ifdef KEYBOARD_NAV
if ( !!cursorRectP ) {
draw_drawCursor( board->draw, OBJ_SCORE, cursorRectP );
}
#endif
draw_objFinished( board->draw, OBJ_SCORE, &board->scoreBdBounds,
dfsFor( board, OBJ_SCORE ) );
}

View file

@ -203,15 +203,7 @@ drawTray( BoardCtxt* board )
}
drawPendingScore( board,
(cursorBits & (1<<(MAX_TRAY_TILES-1))) != 0 );
#ifdef KEYBOARD_NAV
if ( (cursorBits != 0) && (cursorBits != ALLTILES) ) {
figureTrayTileRect( board, indexForBits(cursorBits),
&tileRect );
draw_drawCursor( board->draw, OBJ_TRAY, &tileRect );
}
#endif
(cursorBits & (1<<(MAX_TRAY_TILES-1))) != 0);
}
draw_objFinished( board->draw, OBJ_TRAY, &board->trayBounds,