From: H.G. Muller Date: Wed, 12 Mar 2014 21:08:04 +0000 (+0100) Subject: Fix initial sizing of board X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=faf7933d96193d30d052f2e75a0271c4309d965b;p=xboard.git Fix initial sizing of board Previous patches had destroyed the ability to obey the -size option. --- diff --git a/draw.c b/draw.c index badd12b..3eeff67 100644 --- a/draw.c +++ b/draw.c @@ -181,7 +181,9 @@ InitDrawingSizes (BoardSize boardSize, int flags) if(boardSize == -2 && gameInfo.variant != oldVariant && oldNrOfFiles && oldNrOfFiles != BOARD_WIDTH) { // called because variant switch changed board format - squareSize = ((squareSize + lineGap) * oldNrOfFiles + 0.5*BOARD_WIDTH) / BOARD_WIDTH - lineGap; // keep total width fixed + squareSize = ((squareSize + lineGap) * oldNrOfFiles + 0.5*BOARD_WIDTH) / BOARD_WIDTH; // keep total width fixed + if(appData.overrideLineGap < 0) lineGap = squareSize < 37 ? 1 : squareSize < 59 ? 2 : squareSize < 116 ? 3 : 4; + squareSize -= lineGap; CreatePNGPieces(); CreateGrid(); } diff --git a/gtk/xboard.c b/gtk/xboard.c index 1b3d58f..e42f090 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -1554,11 +1554,13 @@ ReSize (WindowPlacement *wp) int sqx, sqy, w, h, hc, lg = lineGap; gtk_widget_get_allocation(optList[W_WHITE].handle, &a); hc = a.height; // clock height can depend on single / double line clock text! - wp->height = BOARD_HEIGHT * (squareSize + lineGap) + lineGap + marginH + hc; + if(clockKludge && hc != clockKludge) wp->height += hc - clockKludge, clockKludge = 0; + wpMain.height = BOARD_HEIGHT * (squareSize + lineGap) + lineGap + marginH + hc; if(wp->width == wpMain.width && wp->height == wpMain.height) return; // not sized sqx = (wp->width - lg - marginW) / BOARD_WIDTH - lg; sqy = (wp->height - lg - marginH - hc) / BOARD_HEIGHT - lg; if(sqy < sqx) sqx = sqy; + if(sqx < 20) return; if(appData.overrideLineGap < 0) { // do second iteration with adjusted lineGap lg = lineGap = sqx < 37 ? 1 : sqx < 59 ? 2 : sqx < 116 ? 3 : 4; sqx = (wp->width - lg - marginW) / BOARD_WIDTH - lg; @@ -1566,7 +1568,6 @@ ReSize (WindowPlacement *wp) if(sqy < sqx) sqx = sqy; } if(sqx != squareSize) { -//printf("new sq size %d (%dx%d)\n", sqx, wp->width, wp->height); squareSize = sqx; // adopt new square size CreatePNGPieces(); // make newly scaled pieces InitDrawingSizes(0, 0); // creates grid etc.