From: H.G.Muller Date: Wed, 6 Apr 2016 11:03:38 +0000 (+0200) Subject: Lock board size when clock changes to two lines X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=b4f97ed2dd6c9d8e9d780211d8ebc54803d46403;p=xboard.git Lock board size when clock changes to two lines First writing in the clock widget will usually increase its height because the clock font is bigger than default. And for two-line clocks as used with logos this will even be more pronounced. This did cause the extra size to be taken from the board, ending up with a smaller square size than originally requested. Which again would cause any font changes to be saved as belonging to that smaller board size. So starting next time with the originally requested size (as opposed to the saved board size) would then not use those fonts! The board size is now locked during the first write to the clocks, or writes that change the number of lines. --- diff --git a/gtk/xboard.c b/gtk/xboard.c index c6579d8..7ea8382 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -2092,10 +2092,10 @@ LockBoardSize (int after) static char *oldClockFont, *oldMessgFont; int w, h; if(oldMessgFont && !strcmp(oldMessgFont, appData.font) && - oldClockFont && !strcmp(oldClockFont, appData.clockFont) ) return; // only do something when font changed + oldClockFont && !strcmp(oldClockFont, appData.clockFont) && after < 2) return; // only do something when font changed w = BOARD_WIDTH*(squareSize + lineGap) + lineGap; h = BOARD_HEIGHT*(squareSize + lineGap) + lineGap; - if(after) { + if(after & 1) { ASSIGN(oldClockFont, appData.clockFont); ASSIGN(oldMessgFont, appData.font); gtk_window_resize(GTK_WINDOW(shellWidget), w, h); @@ -2109,9 +2109,10 @@ LockBoardSize (int after) void DisplayTimerLabel (Option *opt, char *color, long timer, int highlight) { + static int twoLines = -1; GtkWidget *w = (GtkWidget *) opt->handle; GdkColor col; - char *markup; + char *markup, two = (appData.logoSize != 0); char bgcolor[10]; char fgcolor[10]; @@ -2128,12 +2129,14 @@ DisplayTimerLabel (Option *opt, char *color, long timer, int highlight) strcpy(fgcolor, appData.lowTimeWarningColor); } + if(! partnerUp && two != twoLines) LockBoardSize(2); // lock board size if clock height changes + gdk_color_parse( bgcolor, &col ); gtk_widget_modify_bg(gtk_widget_get_parent(opt->handle), GTK_STATE_NORMAL, &col); if (appData.clockMode) { markup = g_markup_printf_escaped("%s:%s%s", appData.clockFont, - bgcolor, fgcolor, color, appData.logoSize && !partnerUp ? "\n" : " ", TimeString(timer)); + bgcolor, fgcolor, color, two ? "\n" : " ", TimeString(timer)); // markup = g_markup_printf_escaped("%s:%s%s", // bgcolor, fgcolor, color, appData.logoSize && !partnerUp ? "\n" : " ", TimeString(timer)); } else { @@ -2144,6 +2147,8 @@ DisplayTimerLabel (Option *opt, char *color, long timer, int highlight) } gtk_label_set_markup(GTK_LABEL(w), markup); g_free(markup); + + if(!partnerUp && two != twoLines) LockBoardSize(3), twoLines = two; } static GdkPixbuf **clockIcons[] = { &WhiteIcon, &BlackIcon };