f7504e4db88de54c3a438f70a0acc4cddb41f148
kate
  Sat Jan 12 18:23:15 2019 -0800
Finish regeneron feature to display left labels instead of center labels in pack mode (setting centerLabelsPack off). refs #22739

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 04cc918..dad576e 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -487,31 +487,32 @@
 //wigCart->autoScale = wiggleScaleAuto;
 //wigCart->defaultHeight = track->lineHeight;
 //struct wigGraphOutput *wgo = setUpWgo(xOff, yOff, width, tg->height, numTracks, wigCart, hvg);
 //tg->wigGraphOutput = wgo;
 
 return TRUE;
 }
 
 static int trackPlusLabelHeight(struct track *track, int fontHeight)
 /* Return the sum of heights of items in this track (or subtrack as it may be)
  * and the center label(s) above the items (if any). */
 {
 if (trackShouldUseAjaxRetrieval(track))
     return REMOTE_TRACK_HEIGHT;
 
-int y = track->totalHeight(track, limitVisibility(track));
+enum trackVisibility vis = limitVisibility(track);
+int y = track->totalHeight(track, vis);
 if (isCenterLabelIncluded(track))
     y += fontHeight;
 if (tdbIsComposite(track->tdb) && !isCompositeInAggregate(track))
     {
     struct track *subtrack;
     for (subtrack = track->subtracks;  subtrack != NULL; subtrack = subtrack->next)
         {
         if (isSubtrackVisible(subtrack) &&  isCenterLabelIncluded(subtrack))
             y += fontHeight;
         }
     }
 return y;
 }
 
 void drawColoredButtonBox(struct hvGfx *hvg, int x, int y, int w, int h,
@@ -1234,30 +1235,31 @@
 
 Color maybeDarkerLabels(struct track *track, struct hvGfx *hvg, Color color)
 /* For tracks having light track display but needing a darker label */
 {
 if (trackDbSetting(track->tdb, "darkerLabels"))
     {
     struct hsvColor hsv = mgRgbToHsv(mgColorIxToRgb(NULL, color));
     // check if really pale
     if (hsv.s < 500 ||(hsv.h > 40.0 && hsv.h < 150.0))
         return somewhatDarkerColor(hvg, color);
     return slightlyDarkerColor(hvg, color);
     }
 return color;
 }
 
+
 static int doLeftLabels(struct track *track, struct hvGfx *hvg, MgFont *font,
                                 int y)
 /* Draw left labels.  Return y coord. */
 {
 struct slList *prev = NULL;
 
 /* for sample tracks */
 double minRangeCutoff, maxRangeCutoff;
 double minRange, maxRange;
 double min0, max0;
 char minRangeStr[32];
 char maxRangeStr[32];
 
 int ymin, ymax;
 int newy;
@@ -1321,35 +1323,49 @@
 else
     {
     sprintf( minRangeStr, "%d", (int)round(minRangeCutoff));
     sprintf( maxRangeStr, "%d", (int)round(maxRangeCutoff));
     }
 /* special label handling for wigMaf type tracks -- they
    display a left label in pack mode.  To use the full mode
    labeling, temporarily set visibility to full.
    Restore savedVis later */
 if (startsWith("bigMaf", track->tdb->type) || startsWith("wigMaf", track->tdb->type) || startsWith("maf", track->tdb->type))
     vis = tvFull;
 /* behave temporarily like pack for these */
 if (track->limitedVis == tvFull && isTypeBedLike(track))
     vis = tvPack;
 
+char *centerLabelsPack = NULL;
 switch (vis)
     {
     case tvHide:
         break;  /* Do nothing; */
     case tvPack:
+        centerLabelsPack = trackDbSetting(track->tdb, "centerLabelsPack");
+        if (centerLabelsPack && sameWord(centerLabelsPack, "off"))
+            // draw left labels for pack mode track with center labels off
+            {
+            if (isCenterLabelIncluded(track))
+                y += fontHeight;
+            hvGfxTextRight(hvg, leftLabelX, y, leftLabelWidth-1, track->lineHeight, labelColor, font, 
+                                track->shortLabel);
+            y += track->height;
+            }
+        else
+            y += tHeight;
+        break;
     case tvSquish:
 	y += tHeight;
         break;
     case tvFull:
         if (isCenterLabelIncluded(track))
             y += fontHeight;
 
         if( track->subType == lfSubSample && track->items == NULL )
             y += track->height;
 
         for (item = track->items; item != NULL; item = item->next)
             {
             char *rootName;
             char *name = track->itemName(track, item);
             int itemHeight = track->itemHeight(track, item);
@@ -1421,32 +1437,32 @@
 		    hvGfxTextRight(hvg, leftLabelX, y, leftLabelWidth - 1,
 			itemHeight, labelColor, font, name);
 		y += itemHeight;
 		}
             }
         break;
     case tvDense:
 
         if (isCenterLabelIncluded(track))
             y += fontHeight;
 
         /*draw y-value limits for 'sample' tracks.
          * (always puts 0-100% range)*/
         if (track->subType == lfSubSample && track->heightPer > (3 * fontHeight))
             {
-            ymax = y - (track->heightPer / 2) + (fontHeight / 2);
-            ymin = y + (track->heightPer / 2) - (fontHeight / 2);
+            int ymax = y - (track->heightPer / 2) + (fontHeight / 2);
+            int ymin = y + (track->heightPer / 2) - (fontHeight / 2);
             hvGfxTextRight(hvg, leftLabelX, ymin,
                         leftLabelWidth-1, track->lineHeight,
                         track->ixAltColor, font, minRangeStr );
             hvGfxTextRight(hvg, leftLabelX, ymax,
                         leftLabelWidth-1, track->lineHeight,
                         track->ixAltColor, font, maxRangeStr );
             }
         hvGfxTextRight(hvg, leftLabelX, y, leftLabelWidth-1,
                     track->lineHeight, labelColor, font,
                     track->shortLabel);
         y += track->height;
         break;
     }
 hvGfxUnclip(hvg);
 return y;
@@ -5495,36 +5511,31 @@
             continue;
         if (theImgBox)
             {
             // side label slice of tracks
 	    sliceHeight      = flatTrack->maxHeight;
             sliceOffsetY     = y;
             curImgTrack = imgBoxTrackFind(theImgBox,track->tdb,NULL);
             curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,stSide,theSideImg,NULL,
                                                    sliceWidth[stSide],sliceHeight,
                                                    sliceOffsetX[stSide],sliceOffsetY);
             (void) sliceMapFindOrStart(curSlice,track->tdb->track,NULL); // No common linkRoot
             }
 
         if (trackShouldUseAjaxRetrieval(track))
             y += REMOTE_TRACK_HEIGHT;
-    #ifdef IMAGEv2_NO_LEFTLABEL_ON_FULL
-        else if (track->drawLeftLabels != NULL
-             &&  (theImgBox == NULL || track->limitedVis == tvDense))
-    #else ///ndef IMAGEv2_NO_LEFTLABEL_ON_FULL
         else if (track->drawLeftLabels != NULL)
-    #endif ///ndef IMAGEv2_NO_LEFTLABEL_ON_FULL
 	    {
 	    setGlobalsFromWindow(windows);
             y = doOwnLeftLabels(track, hvgSide, font, y);
 	    setGlobalsFromWindow(windows); // first window
 	    }
         else
 	    y += flatTrack->maxHeight;
         }
     }
 
 
 
 /* Make map background. */
 
 y = yAfterRuler;