08414ac23ba7fd2d7298ad5502053cc94b0834b0 kate Mon Jan 14 16:48:37 2019 -0800 Allow very short labels to be used with labelsOnFeature setting. Needed for Regeneron (and no reason not to). refs #22739 diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c index b582b35..692cf3b 100644 --- src/hg/hgTracks/simpleTracks.c +++ src/hg/hgTracks/simpleTracks.c @@ -1581,38 +1581,38 @@ int xOff, int y, int height, Color color, MgFont *font, char *label) /* Draw a box scaled from chromosome to window coordinates and draw a label onto it. * Lots of code copied from drawScaledBox */ { int x1, x2, w; if (!scaledBoxToPixelCoords(chromStart, chromEnd, scale, xOff, &x1, &x2)) return; w = x2-x1; if (w == 0) // when zoomed out, avoid shinking to nothing w = 1; hvGfxBox(hvg, x1, y, w, height, color); char *shortLabel = cloneString(label); /* calculate how many characters we can squeeze into the box */ int charsInBox = w / mgFontCharWidth(font, 'm'); -if (charsInBox > 4) - { if (charsInBox < strlen(label)) + if (charsInBox > 4) strcpy(shortLabel+charsInBox-3, "..."); +if (charsInBox < strlen(shortLabel)) + return; Color labelColor = hvGfxContrastingColor(hvg, color); hvGfxTextCentered(hvg, x1, y, w, height, labelColor, font, shortLabel); } -} void filterItems(struct track *tg, boolean (*filter)(struct track *tg, void *item), char *filterType) /* Filter out items from track->itemList. */ { struct slList *newList = NULL, *oldList = NULL, *el, *next; boolean exclude = FALSE; boolean color = FALSE; enum trackVisibility vis = tvHide; if (sameWord(filterType, "none")) return; if (sameWord(filterType, "include")) exclude = FALSE;