0257ad5ac7c22eb186b92c5c85eb21b2881f8bb8
galt
  Mon Dec 8 22:48:30 2014 -0800
Simplifying pack visibility logic for clickmaps and next/prev exon arrows.
diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index fb1a156..f290ecf 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -2921,90 +2921,71 @@
 /* This is meant to be used by genericDrawItems to set to tg->mapItem in */
 /* case tg->mapItem isn't set to anything already. */
 {
 // Don't bother if we are imageV2 and a dense child.
 if (!theImgBox || tg->limitedVis != tvDense || !tdbIsCompositeChild(tg->tdb))
     {
     char *directUrl = trackDbSetting(tg->tdb, "directUrl");
     boolean withHgsid = (trackDbSetting(tg->tdb, "hgsid") != NULL);
     mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, tg->track,
                       mapItemName, itemName, directUrl, withHgsid, NULL);
     }
 }
 
 void genericDrawNextItemStuff(struct track *tg, struct hvGfx *hvg, enum trackVisibility vis,
                               struct slList *item, int x2, int textX, int y, int heightPer,
-                              boolean snapLeft, Color color)
+                              Color color)
 /* After the item is drawn in genericDrawItems, draw next/prev item related */
 /* buttons and the corresponding mapboxes. */
 {
 int buttonW = heightPer-1 + 2*NEXT_ITEM_ARROW_BUFFER;
 int s = tg->itemStart(tg, item);
 int e = tg->itemEnd(tg, item);
 boolean rButton = FALSE;
 boolean lButton = FALSE;
 /* Draw the actual triangles.  These are always at the edge of the window. */
 if (s < winStart)
     {
     lButton = TRUE;
     hvGfxNextItemButton(hvg, insideX + NEXT_ITEM_ARROW_BUFFER, y,
                         heightPer-1, heightPer-1, color, MG_WHITE, FALSE);
     }
 if (e > winEnd)
     {
     rButton = TRUE;
     hvGfxNextItemButton(hvg, insideX + insideWidth - NEXT_ITEM_ARROW_BUFFER - heightPer,
                         y, heightPer-1, heightPer-1, color, MG_WHITE, TRUE);
     }
-/* If we're in pack, there's some crazy logic. */
 if (vis == tvPack)
     {
     int w = x2-textX;
     if (lButton)
-        {
+        { // if left-button, the label will be on far left, split out a map just for that label.
 	tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                     s, e, textX, y, insideX-textX, heightPer);
 	tg->nextPrevExon(tg, hvg, item, insideX, y, buttonW, heightPer, FALSE);
-        if (rButton)
-            {
-            tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
-                        s, e, insideX + buttonW, y, x2 - (insideX + 2*buttonW), heightPer);
-            tg->nextPrevExon(tg, hvg, item, x2-buttonW, y, buttonW, heightPer, TRUE);
-            }
-        else
-            tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
-                        s, e, insideX + buttonW, y, x2 - (insideX + buttonW), heightPer);
-        }
-    else if (snapLeft && rButton)
-        // This is a special case where there's a next-item button, NO prev-item button,
-        // AND the gene name is drawn left of the browser window.
-        {
-        tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
-                    s, e, textX, y, x2 - buttonW - textX, heightPer);
-        tg->nextPrevExon(tg, hvg, item, x2-buttonW, y, buttonW, heightPer, TRUE);
+	textX = insideX + buttonW; // continue on the right side of the left exon button
+	w = x2-textX;
 	}
-    else if (rButton)
+    if (rButton)
         {
-        tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
-                    s, e, textX, y, w - buttonW, heightPer);
 	tg->nextPrevExon(tg, hvg, item, x2-buttonW, y, buttonW, heightPer, TRUE);
+	w -= buttonW;
         }
-    else
     tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
 		s, e, textX, y, w, heightPer);
     }
-/* Full mode is a little easier to deal with. */
 else if (vis == tvFull)
     {
     int geneMapBoxX = insideX;
     int geneMapBoxW = insideWidth;
     /* Draw the first gene mapbox, in the left margin. */
 #ifndef IMAGEv2_NO_LEFTLABEL_ON_FULL
     int trackPastTabX = (withLeftLabels ? trackTabWidth : 0);
 #ifdef IMAGEv2_SHORT_MAPITEMS
     char *name = tg->itemName(tg, item);
     if (*name != '\0')
         tg->mapItem(tg, hvg, item, name, tg->mapItemName(tg, item),
                     s, e, trackPastTabX, y, insideX - trackPastTabX, heightPer);
 #else///ndef IMAGEv2_SHORT_MAPITEMS
     tg->mapItem(tg, hvg, item, tg->itemName(tg, item), tg->mapItemName(tg, item),
                 s, e, trackPastTabX, y, insideX - trackPastTabX, heightPer);
@@ -3159,32 +3140,31 @@
             {
             hvGfxBox(hvg, textX - 1, y, nameWidth+1, tg->heightPer-1, color);
             hvGfxTextRight(hvg, textX, y, nameWidth, tg->heightPer, MG_WHITE, font, name);
             }
         else
             hvGfxTextRight(hvg, textX, y, nameWidth, tg->heightPer, labelColor, font, name);
         }
     }
 if (!tg->mapsSelf)
     {
     int w = x2-textX;
     /* Arrows? */
     if (w > 0)
         {
         if (nextItemCompatible(tg))
-            genericDrawNextItemStuff(tg, hvg, vis, item, x2, textX, y, tg->heightPer, FALSE,
-                                     color);
+            genericDrawNextItemStuff(tg, hvg, vis, item, x2, textX, y, tg->heightPer, color);
         else
             {
             tg->mapItem(tg, hvg, item, tg->itemName(tg, item),
                         tg->mapItemName(tg, item), s, e, textX, y, w, tg->heightPer);
             }
         }
     }
     withIndividualLabels = TRUE; /* reset in case done with pgSnp */
 }
 
 static int normalizeCount(struct preDrawElement *el, double countFactor, 
     double minVal, double maxVal, double sumData, double sumSquares)
 /* normalize statistics to be based on an integer number of valid bases 
  * Integer value is the smallest integer not less than countFactor */
 {
@@ -3406,35 +3386,34 @@
         #ifdef IMAGEv2_NO_LEFTLABEL_ON_FULL
             if (theImgBox != NULL && vis == tvFull)  // dragScroll >1x has no bed full leftlabels,
                 {                                    // but in image labels like pack.
                 char *name = tg->itemName(tg, item);
                 int nameWidth = mgFontStringWidth(font, name);
                 int textX = round((s - winStart)*scale) + xOff;
                 textX -= (nameWidth + 2);
                 if (textX >= insideX && nameWidth > 0)
                     {
                     x1 = textX; // extends the map item to cover this label
                     Color itemNameColor = tg->itemNameColor(tg, item, hvg);
                     hvGfxTextRight(hvg,textX,y,nameWidth,tg->heightPer,itemNameColor,font,name);
                     }
                 }
         #endif ///def IMAGEv2_NO_LEFTLABEL_ON_FULL
-            genericDrawNextItemStuff(tg, hvg, vis, item, x2, x1, y, tg->heightPer, FALSE,color);
+            genericDrawNextItemStuff(tg, hvg, vis, item, x2, x1, y, tg->heightPer, color);
             }
 #else//ifndef IMAGEv2_SHORT_MAPITEMS
-            genericDrawNextItemStuff(tg, hvg, vis, item, -1, -1, y, tg->heightPer, FALSE,
-                                     color);
+            genericDrawNextItemStuff(tg, hvg, vis, item, -1, -1, y, tg->heightPer, color);
 #endif//ndef IMAGEv2_SHORT_MAPITEMS
         y += tg->lineHeight;
         }
     }
 }
 
 void genericDrawItems(struct track *tg, int seqStart, int seqEnd,
                       struct hvGfx *hvg, int xOff, int yOff, int width,
                       MgFont *font, Color color, enum trackVisibility vis)
 /* Draw generic item list.  Features must be fixed height
  * and tg->drawItemAt has to be filled in. */
 {
 if (tg->mapItem == NULL)
     tg->mapItem = genericMapItem;
 if (vis != tvDense && (! bedItemRgb(tg->tdb)) && baseColorCanDraw(tg))