X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=9c8be9b330075a859e568076c54fc14c01b61bbf;hb=87f92ae18b9ce2ad0f230609d7d90f2fbf0a1c7b;hp=a33b765a5223043843a611b560885ec37611c289;hpb=b558b8211337aa5ae00d05553ea509b6db209306;p=xboard.git diff --git a/xboard.c b/xboard.c index a33b765..9c8be9b 100644 --- a/xboard.c +++ b/xboard.c @@ -340,8 +340,8 @@ WindowPlacement wpTags; #define SOLID 0 #define OUTLINE 1 -Boolean cairoAnimate = True; -static cairo_surface_t *csBoardWindow, *csBoardBackup; +Boolean cairoAnimate; +static cairo_surface_t *csBoardWindow, *csBoardBackup, *csDualBoard; static cairo_surface_t *pngPieceBitmaps[2][(int)BlackPawn]; // scaled pieces as used static cairo_surface_t *pngPieceBitmaps2[2][(int)BlackPawn+4]; // scaled pieces in store static cairo_surface_t *pngBoardBitmap[2]; @@ -894,9 +894,16 @@ SwitchWindow () extern Option dualOptions[]; static Window dual; Window tmp = xBoardWindow; + cairo_surface_t *cstmp = csBoardWindow; if(!dual) dual = XtWindow(dualOptions[3].handle); // must be first call xBoardWindow = dual; // swap them dual = tmp; + csBoardWindow = csDualBoard; + if(!csDualBoard && cstmp) { + int boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap); + int boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap); + csBoardWindow = cairo_xlib_surface_create(xDisplay, xBoardWindow, DefaultVisual(xDisplay, 0), boardWidth, boardHeight); + } } void @@ -933,7 +940,8 @@ NewSurfaces () // delete surfaces after size becomes invalid, so they will be recreated if(csBoardWindow) cairo_surface_destroy(csBoardWindow); if(csBoardBackup) cairo_surface_destroy(csBoardBackup); - csBoardWindow = csBoardBackup = NULL; + if(csDualBoard) cairo_surface_destroy(csDualBoard); + csBoardWindow = csBoardBackup = csDualBoard = NULL; } #define BoardSize int @@ -1047,9 +1055,22 @@ InitDrawingSizes (BoardSize boardSize, int flags) } for(i=0; i<2; i++) { int p; -printf("Copy pieces\n"); for(p=0; p<=(int)WhiteKing; p++) pngPieceBitmaps[i][p] = pngPieceBitmaps2[i][p]; // defaults + if(gameInfo.variant == VariantShogi) { + pngPieceBitmaps[i][(int)WhiteCannon] = pngPieceBitmaps2[i][(int)WhiteKing+1]; + pngPieceBitmaps[i][(int)WhiteNightrider] = pngPieceBitmaps2[i][(int)WhiteKing+2]; + pngPieceBitmaps[i][(int)WhiteSilver] = pngPieceBitmaps2[i][(int)WhiteKing+3]; + pngPieceBitmaps[i][(int)WhiteGrasshopper] = pngPieceBitmaps2[i][(int)WhiteKing+4]; + pngPieceBitmaps[i][(int)WhiteQueen] = pngPieceBitmaps2[i][(int)WhiteLance]; + } + if(gameInfo.variant == VariantGothic) { + pngPieceBitmaps[i][(int)WhiteMarshall] = pngPieceBitmaps2[i][(int)WhiteSilver]; + } + if(gameInfo.variant == VariantSChess) { + pngPieceBitmaps[i][(int)WhiteAngel] = pngPieceBitmaps2[i][(int)WhiteFalcon]; + pngPieceBitmaps[i][(int)WhiteMarshall] = pngPieceBitmaps2[i][(int)WhiteAlfil]; + } } oldMono = -10; // kludge to force recreation of animation masks oldVariant = gameInfo.variant; @@ -1533,6 +1554,11 @@ XBoard square size (hint): %d\n\ /* * Inhibit shell resizing. */ + + CreateAnyPieces(); + cairoAnimate = *appData.pngDirectory && useTexture == 3 + && strstr(appData.liteBackTextureFile, ".png") && strstr(appData.darkBackTextureFile, ".png"); + shellArgs[0].value = (XtArgVal) &w; shellArgs[1].value = (XtArgVal) &h; XtGetValues(shellWidget, shellArgs, 2); @@ -1546,7 +1572,6 @@ XBoard square size (hint): %d\n\ CreateGCs(False); CreateGrid(); - CreateAnyPieces(); if(appData.logoSize) { // locate and read user logo @@ -2509,11 +2534,17 @@ DoDrawBorder (cairo_surface_t *cs, int x, int y, int type) { cairo_t *cr; DrawSeekOpen(); + char *col; + switch(type) { + case 0: col = "#000000"; break; + case 1: col = appData.highlightSquareColor; break; + case 2: col = appData.premoveHighlightColor; break; + } cr = cairo_create(cs); cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); cairo_rectangle(cr, x, y, squareSize+lineGap, squareSize+lineGap); - SetPen(cr, lineGap, type == 1 ? appData.highlightSquareColor : appData.premoveHighlightColor, 0); + SetPen(cr, lineGap, col, 0); cairo_stroke(cr); } @@ -2590,6 +2621,24 @@ BlankSquare (int x, int y, int color, ChessSquare piece, Drawable dest, int fac) XCopyArea(xDisplay, xpmBoardBitmap[color], dest, wlPieceGC, x0, y0, squareSize, squareSize, x*fac, y*fac); } else + if(csBoardWindow) { + cairo_t *cr = cairo_create (csBoardWindow); + char *col; + switch (color) { + case 0: col = appData.darkSquareColor; break; + case 1: col = appData.lightSquareColor; break; + case 2: col = "#000000"; break; + } + SetPen(cr, 2.0, col, 0); + cairo_rectangle (cr, x, y, squareSize, squareSize); + cairo_fill (cr); + cairo_destroy (cr); + cr = cairo_create (csBoardBackup); + SetPen(cr, 2.0, col, 0); + cairo_rectangle (cr, x, y, squareSize, squareSize); + cairo_fill (cr); + cairo_destroy (cr); + } else if (useImages && useImageSqs) { Pixmap pm; switch (color) { @@ -2846,6 +2895,32 @@ DrawOneSquare (int x, int y, ChessSquare piece, int square_color, int marker, ch if (appData.monoMode) { XDrawImageString(xDisplay, xBoardWindow, hGC, xx, yy, string, 1); } else { + if(*appData.pngDirectory) { + cairo_t *cr = cairo_create (csBoardWindow); + cairo_select_font_face (cr, "Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); + + cairo_set_font_size (cr, squareSize/4); + + cairo_move_to (cr, xx-1, yy); + if(align < 3) cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + else cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_show_text (cr, string); + cairo_destroy (cr); + cr = cairo_create (csBoardBackup); + cairo_select_font_face (cr, "Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); + + cairo_set_font_size (cr, squareSize/4); + + cairo_move_to (cr, xx-1, yy); + if(align < 3) cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + else cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + cairo_show_text (cr, string); + cairo_destroy (cr); + } else XDrawString(xDisplay, xBoardWindow, hGC, xx, yy, string, 1); } } @@ -3026,10 +3101,8 @@ void DrawSeekText(char *buf, int x, int y) cairo_set_font_size (cr, 12.0); cairo_move_to (cr, x, y+4); - cairo_show_text( cr, buf); - cairo_set_source_rgba(cr, 0, 0, 0,1.0); - cairo_stroke(cr); + cairo_show_text( cr, buf); /* free memory */ cairo_destroy (cr); @@ -4078,13 +4151,18 @@ CairoOverlayPiece (ChessSquare piece, cairo_surface_t *dest) static ChessSquare oldPiece = -1; static int oldSize; static cairo_t *pieceSource; - if(piece != oldPiece || squareSize != oldSize) { // try make it faster by only changing cr if we need other piece - if(pieceSource) cairo_destroy (pieceSource); - pieceSource = cairo_create (dest); - cairo_set_source_surface (pieceSource, pngPieceBitmaps[!White(piece)][piece % BlackPawn], 0, 0); - oldPiece = piece; oldSize = squareSize; - } - cairo_paint(pieceSource); + extern int doubleClick; // in backend.c +// if(piece != oldPiece || squareSize != oldSize) { // try make it faster by only changing cr if we need other piece +// if(pieceSource) cairo_destroy (pieceSource); +// pieceSource = cairo_create (dest); +// cairo_set_source_surface (pieceSource, pngPieceBitmaps[!White(piece)][piece % BlackPawn], 0, 0); +// oldPiece = piece; oldSize = squareSize; +// } + pieceSource = cairo_create (dest); + cairo_set_source_surface (pieceSource, pngPieceBitmaps[!White(piece)][piece % BlackPawn], 0, 0); + if(doubleClick) cairo_paint_with_alpha (pieceSource, 0.6); + else cairo_paint(pieceSource); + cairo_destroy (pieceSource); } void