f30e46e4d2ee9f48ef87cc87b95159c37dffeb6a galt Wed Feb 17 12:59:44 2016 -0800 Fixes #16818. Gets better cross-all-windows error handling working for bigDataUrl/network tracks. Squashed commit of the following: commit cdf9db633c9018538aabf9c8346eabee63b5a3cf Author: Galt Barber Date: Wed Feb 17 12:55:47 2016 -0800 Fixed width in bigWarn.c and background in multiWig.c commit 3620dcd0912660fabbd993df4af119cc03676545 Author: Galt Barber Date: Tue Feb 16 11:53:32 2016 -0800 Initial checking for multi-region all-windows warn. This is an attempt to handle timeout high-level errors better, when a track is taking too long to finish loading; and to handle the network errors across all of the windows together, i.e. using the entire screen width to display the errors, only diplaying the first error, and only drawing for the first window. diff --git src/hg/hgTracks/bigWarn.c src/hg/hgTracks/bigWarn.c index 8549c9e..7eeb4ef 100644 --- src/hg/hgTracks/bigWarn.c +++ src/hg/hgTracks/bigWarn.c @@ -1,111 +1,124 @@ /* bigWarn -- shared handlers for displaying big/udc warn/error messages */ /* Copyright (C) 2011 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "hgTracks.h" #include "container.h" #include "bigWarn.h" static int bigWarnNumLines(char *errMsg) /* Count number of lines in err msg */ { int n = countChars(errMsg, '\n'); int sl = strlen(errMsg); if ((sl > 0) && (errMsg[sl-1]!='\n')) ++n; return n; } char *bigWarnReformat(char *errMsg) /* Return a copy of the re-formatted error message, * such as breaking longer lines */ { /* convert ". " to ".\n" to break long lines. */ char *result = cloneString(errMsg); char *nl = result; while ((nl = strchr(nl,'.'))) { ++nl; if (nl[0] == ' ') { nl[0] = '\n'; ++nl; } } return result; } void bigDrawWarning(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis) -/* Draw the network error message */ +/* Draw the network error message, for the first window only. + * Use the entire screen space across all windows. */ { +if (currentWindow != windows) + return; +int clipXBak, clipYBak, clipWidthBak, clipHeightBak; +hvGfxGetClip(hvg, &clipXBak, &clipYBak, &clipWidthBak, &clipHeightBak); +hvGfxUnclip(hvg); +hvGfxSetClip(hvg, fullInsideX, yOff, fullInsideWidth, tg->height); +xOff = fullInsideX; +width = fullInsideWidth; + char message[1024]; Color yellow = hvGfxFindRgb(hvg, &undefinedYellowColor); char *errMsg = bigWarnReformat(tg->networkErrMsg); char *nl = errMsg; int sl = strlen(errMsg); // in some cases, cannot use tg-> values, so recalc local equivalents. int heightPer = tl.fontHeight; /* Height per item line minus border. */ int lineHeight = heightPer+4; /* Height per item line including border. */ if (lineHeight > tg->height) lineHeight = tg->height; int n = bigWarnNumLines(errMsg); /* Lines of warning text */ int m = tg->height / lineHeight; /* Lines of text space available */ if (m < 1) m = 1; // make yellow background to draw user's attention to the err msg -if (!sameOk(parentContainerType(tg), "multiWig")) // unless multiwig has already done it. + +if (!sameOk(parentContainerType(tg), "multiWig")) // multiWig knows full parent height hvGfxBox(hvg, xOff, yOff, width, tg->height, yellow); // leading blank lines if any int bl = (m-n)/2; int i; for(i=0;i 0) && (errMsg[sl-1]!='\n'))) { safef(message, sizeof(message), "%s", msg); hvGfxTextCentered(hvg, xOff, yOff, width, lineHeight, MG_BLACK, font, message); yOff += lineHeight; ++l; if (l > n) break; if (l > m) break; } if (!nl) break; ++nl; } freeMem(errMsg); +hvGfxUnclip(hvg); +hvGfxSetClip(hvg, clipXBak, clipYBak, clipWidthBak, clipHeightBak); } int bigWarnTotalHeight(struct track *tg, enum trackVisibility vis) /* Return total height. Called before and after drawItems. * Must set the following variables: height, lineHeight, heightPer. */ { if (tg->height == 0) // since this gets called more that once, but we should calculate the same thing each time, don't re-do it. { tg->heightPer = tl.fontHeight; /* Height per item line minus border. */ tg->lineHeight = tg->heightPer+4; /* Height per item line including border. */ /* count lines in reformated warning msg */ char *errMsg = bigWarnReformat(tg->networkErrMsg); int n = bigWarnNumLines(errMsg); freeMem(errMsg); tg->height = tg->lineHeight * n; /* Total height - must be set. */ } return tg->height; }