X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=d0490625c3363d11aba9912ffff8967e537f9550;hb=cd8d4f7a65a3ef8641af1f8a40371bb574df01d4;hp=55cb8d99aea719c70e17277faca88b5026f7a086;hpb=ba19c79e683860fba8cafa5ca24b0f8191b4c1d5;p=xboard.git diff --git a/xboard.c b/xboard.c index 55cb8d9..d049062 100644 --- a/xboard.c +++ b/xboard.c @@ -369,6 +369,7 @@ void ForwardProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void ToStartProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void ToEndProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void RevertProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void AnnotateProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void TruncateGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void RetractMoveProc P((Widget w, XEvent *event, String *prms, @@ -481,6 +482,8 @@ Widget shellWidget, layoutWidget, formWidget, boardWidget, messageWidget, menuBarWidget, buttonBarWidget, editShell, errorShell, analysisShell, ICSInputShell, fileNameShell, askQuestionShell; Widget historyShell, evalGraphShell, gameListShell; +int hOffset; // [HGM] dual +XSegment secondSegments[BOARD_RANKS + BOARD_FILES + 2]; XSegment gridSegments[BOARD_RANKS + BOARD_FILES + 2]; XSegment jailGridSegments[BOARD_RANKS + BOARD_FILES + 6]; Font clockFontID, coordFontID, countFontID; @@ -657,6 +660,7 @@ MenuItem stepMenu[] = { {N_("Back to Start"), ToStartProc}, {N_("Forward to End"), ToEndProc}, {N_("Revert"), RevertProc}, + {N_("Annotate"), AnnotateProc}, {N_("Truncate Game"), TruncateGameProc}, {"----", NothingProc}, {N_("Move Now"), MoveNowProc}, @@ -914,6 +918,7 @@ XtActionsRec boardActions[] = { { "ToStartProc", ToStartProc }, { "ToEndProc", ToEndProc }, { "RevertProc", RevertProc }, + { "AnnotateProc", AnnotateProc }, { "TruncateGameProc", TruncateGameProc }, { "MoveNowProc", MoveNowProc }, { "RetractMoveProc", RetractMoveProc }, @@ -1543,6 +1548,8 @@ ConvertToLine(int argc, char **argv) //-------------------------------------------------------------------------------------------- +extern Boolean twoBoards, partnerUp; + #ifdef IDSIZES // eventually, all layout determining code should go into a subroutine, but until then IDSIZE remains undefined #else @@ -1563,7 +1570,7 @@ void InitDrawingSizes(BoardSize boardSize, int flags) shellArgs[1].value = (XtArgVal) &h; XtGetValues(shellWidget, shellArgs, 2); - shellArgs[4].value = 2*w; shellArgs[2].value = 10; + shellArgs[4].value = 3*w; shellArgs[2].value = 10; shellArgs[5].value = 2*h; shellArgs[3].value = 10; XtSetValues(shellWidget, &shellArgs[2], 4); @@ -1573,6 +1580,12 @@ void InitDrawingSizes(BoardSize boardSize, int flags) boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap); boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap); CreateGrid(); + hOffset = boardWidth + 10; + for(i=0; ixexpose.count > 0) return; /* no clipping is done */ XDrawPosition(widget, True, NULL); + if(twoBoards) { // [HGM] dual: draw other board in other orientation + flipView = !flipView; partnerUp = !partnerUp; + XDrawPosition(widget, True, NULL); + flipView = !flipView; partnerUp = !partnerUp; + } break; case MotionNotify: if(SeekGraphClick(Press, event->xbutton.x, event->xbutton.y, 1)) break; @@ -4392,7 +4421,7 @@ void DrawSeekDot(int x, int y, int colorNr) x-squareSize/8, y-squareSize/8, squareSize/4, squareSize/4, 0, 64*360); } -static int damage[BOARD_RANKS][BOARD_FILES]; +static int damage[2][BOARD_RANKS][BOARD_FILES]; /* * event handler for redrawing the board @@ -4404,18 +4433,19 @@ void XDrawPosition(w, repaint, board) { int i, j, do_flash; static int lastFlipView = 0; - static int lastBoardValid = 0; - static Board lastBoard; + static int lastBoardValid[2] = {0, 0}; + static Board lastBoard[2]; Arg args[16]; int rrow, rcol; + int nr = twoBoards*partnerUp; if(DrawSeekGraph()) return; // [HGM] seekgraph: suppress any drawing if seek graph up if (board == NULL) { if (!lastBoardValid) return; - board = lastBoard; + board = lastBoard[nr]; } - if (!lastBoardValid || lastFlipView != flipView) { + if (!lastBoardValid[nr] || (nr == 0 && lastFlipView != flipView)) { XtSetArg(args[0], XtNleftBitmap, (flipView ? xMarkPixmap : None)); XtSetValues(XtNameToWidget(menuBarWidget, "menuOptions.Flip View"), args, 1); @@ -4426,19 +4456,19 @@ void XDrawPosition(w, repaint, board) * but this causes a very distracting flicker. */ - if (!repaint && lastBoardValid && lastFlipView == flipView) { + if (!repaint && lastBoardValid[nr] && (nr == 1 || lastFlipView == flipView)) { /* If too much changes (begin observing new game, etc.), don't do flashing */ - do_flash = too_many_diffs(board, lastBoard) ? 0 : 1; + do_flash = too_many_diffs(board, lastBoard[nr]) ? 0 : 1; /* Special check for castling so we don't flash both the king and the rook (just flash the king). */ if (do_flash) { - if (check_castle_draw(board, lastBoard, &rrow, &rcol)) { + if (check_castle_draw(board, lastBoard[nr], &rrow, &rcol)) { /* Draw rook with NO flashing. King will be drawn flashing later */ DrawSquare(rrow, rcol, board[rrow][rcol], 0); - lastBoard[rrow][rcol] = board[rrow][rcol]; + lastBoard[nr][rrow][rcol] = board[rrow][rcol]; } } @@ -4447,32 +4477,34 @@ void XDrawPosition(w, repaint, board) is flashing on its new square */ for (i = 0; i < BOARD_HEIGHT; i++) for (j = 0; j < BOARD_WIDTH; j++) - if ((board[i][j] != lastBoard[i][j] && board[i][j] == EmptySquare) - || damage[i][j]) { + if ((board[i][j] != lastBoard[nr][i][j] && board[i][j] == EmptySquare) + || damage[nr][i][j]) { DrawSquare(i, j, board[i][j], 0); - damage[i][j] = False; + damage[nr][i][j] = False; } /* Second pass -- Draw piece(s) in new position and flash them */ for (i = 0; i < BOARD_HEIGHT; i++) for (j = 0; j < BOARD_WIDTH; j++) - if (board[i][j] != lastBoard[i][j]) { + if (board[i][j] != lastBoard[nr][i][j]) { DrawSquare(i, j, board[i][j], do_flash); } } else { if (lineGap > 0) XDrawSegments(xDisplay, xBoardWindow, lineGC, + twoBoards & partnerUp ? secondSegments : // [HGM] dual gridSegments, BOARD_HEIGHT + BOARD_WIDTH + 2); for (i = 0; i < BOARD_HEIGHT; i++) for (j = 0; j < BOARD_WIDTH; j++) { DrawSquare(i, j, board[i][j], 0); - damage[i][j] = False; + damage[nr][i][j] = False; } } - CopyBoard(lastBoard, board); - lastBoardValid = 1; + CopyBoard(lastBoard[nr], board); + lastBoardValid[nr] = 1; + if(nr == 0) { // [HGM] dual: no highlights on second board yet lastFlipView = flipView; /* Draw highlights */ @@ -4488,7 +4520,7 @@ void XDrawPosition(w, repaint, board) if (hi2X >= 0 && hi2Y >= 0) { drawHighlight(hi2X, hi2Y, highlineGC); } - + } /* If piece being dragged around board, must redraw that too */ DrawDragPiece(); @@ -6247,7 +6279,16 @@ void RevertProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - RevertEvent(); + RevertEvent(False); +} + +void AnnotateProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + RevertEvent(True); } void TruncateGameProc(w, event, prms, nprms) @@ -8696,7 +8737,7 @@ AnimateMove(board, fromX, fromY, toX, toY) FrameSequence(&game, piece, startColor, &start, &finish, frames, nFrames); /* Be sure end square is redrawn */ - damage[toY][toX] = True; + damage[0][toY][toX] = True; } void @@ -8736,7 +8777,7 @@ DragPieceBegin(x, y) XCopyArea(xDisplay, xBoardWindow, player.saveBuf, player.blitGC, corner.x, corner.y, squareSize, squareSize, 0, 0); // [HGM] zh: unstack in stead of grab - damage[boardY][boardX] = True; + damage[0][boardY][boardX] = True; } else { player.dragActive = False; } @@ -8790,7 +8831,7 @@ DragPieceEnd(x, y) EndAnimation(&player, &corner); /* Be sure end square is redrawn */ - damage[boardY][boardX] = True; + damage[0][boardY][boardX] = True; /* This prevents weird things happening with fast successive clicks which on my Sun at least can cause motion events @@ -8813,7 +8854,7 @@ DrawDragPiece () BlankSquare(player.startSquare.x, player.startSquare.y, player.startColor, EmptySquare, xBoardWindow); AnimationFrame(&player, &player.prevFrame, player.dragPiece); - damage[player.startBoardY][player.startBoardX] = TRUE; + damage[0][player.startBoardY][player.startBoardX] = TRUE; } #include