e8f9b1f36a863296a6310a76f5535dcb16a91d07
braney
  Wed Dec 17 11:40:03 2014 -0800
tweak to get labelOnFeature to work correctly in pack mode (don't addspace for label)

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index 2ffc952..fddc25b 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -331,31 +331,31 @@
 int extraWidth = tl.mWidth * 2;
 long long start, end;
 double scale = (double)insideWidth/(winEnd - winStart);
 spaceSaverFree(&tg->ss);
 ss = tg->ss = spaceSaverNew(0, insideWidth, maxCount);
 for (item = tg->items; item != NULL; item = item->next)
     {
     int baseStart = tg->itemStart(tg, item);
     int baseEnd = tg->itemEnd(tg, item);
     if (baseStart < winEnd && baseEnd > winStart)
         {
 	if (baseStart <= winStart)
 	    start = 0;
 	else
 	    start = round((double)(baseStart - winStart)*scale);
-	if (!tg->drawName && withLabels)
+	if (!tg->drawLabelInBox && !tg->drawName && withLabels)
 	    start -= mgFontStringWidth(font,
 				       tg->itemName(tg, item)) + extraWidth;
 	if (baseEnd >= winEnd)
 	    end = insideWidth;
 	else
 	    end = round((baseEnd - winStart)*scale);
 	if (tg->itemRightPixels && withLabels)
 	    {
 	    end += tg->itemRightPixels(tg, item);
 	    if (end > insideWidth)
 	        end = insideWidth;
 	    }
 	if (start < 0) start = 0;
 	if (spaceSaverAddOverflow(ss, start, end, item, allowOverflow) == NULL)
 	    break;
@@ -3515,33 +3515,30 @@
 {
 clearColorBin();
 if (vis == tvDense && tg->colorShades)
     slSort(&tg->items, cmpLfsWhiteToBlack);
 genericDrawItems(tg, seqStart, seqEnd, hvg, xOff, yOff, width,
 	font, color, vis);
 }
 
 void linkedFeaturesDraw(struct track *tg, int seqStart, int seqEnd,
                         struct hvGfx *hvg, int xOff, int yOff, int width,
                         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw linked features items. */
 {
 clearColorBin();
 
-// optional setting to draw labels onto the feature boxes, not next to them
-tg->drawLabelInBox = cartOrTdbBoolean(cart, tg->tdb, "labelOnFeature" , FALSE);
-
 if (tg->items == NULL && vis == tvDense && canDrawBigBedDense(tg))
     {
     bigBedDrawDense(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color);
     }
 else
     {
     if (vis == tvDense && tg->colorShades)
 	slSort(&tg->items, cmpLfWhiteToBlack);
     genericDrawItems(tg, seqStart, seqEnd, hvg, xOff, yOff, width,
 	    font, color, vis);
     }
 }
 
 void incRange(UBYTE *start, int size)
 /* Add one to range of bytes, taking care to not overflow. */
@@ -9331,30 +9328,33 @@
 int ct = 0;
 for (subtrack = trackList; subtrack; subtrack = subtrack->next)
     if (isSubtrackVisible(subtrack))
         ct++;
 return ct;
 }
 
 enum trackVisibility limitVisibility(struct track *tg)
 /* Return default visibility limited by number of items and
  * by parent visibility if part of a coposite track.
  * This also sets tg->height. */
 {
 if (!tg->limitedVisSet)
     {
     tg->limitedVisSet = TRUE;  // Prevents recursive loop!
+    
+    // optional setting to draw labels onto the feature boxes, not next to them
+    tg->drawLabelInBox = cartOrTdbBoolean(cart, tg->tdb, "labelOnFeature" , FALSE);
     if (trackShouldUseAjaxRetrieval(tg))
         {
         tg->limitedVis = tg->visibility;
         tg->height = REMOTE_TRACK_HEIGHT;
         }
     else
         {
         enum trackVisibility vis = tg->visibility;
         int h;
         int maxHeight = maximumTrackHeight(tg);
 
         if (vis == tvHide)
             {
             tg->height = 0;
             tg->limitedVis = tvHide;