41228a755bb4fc38a150e4d5e36c259850968212
max
  Fri Oct 20 06:47:16 2023 -0700
allow exonNumber on with mouseOver in trackDb, refs #32459

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index a22f088..9975164 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -2788,39 +2788,52 @@
 		{
 		exonIntronText = intronText;
 		--numExonIntrons;  // introns are one fewer than exons
 		}
 
             char strandChar;
 	    if (!revStrand) {
 		exonIntronNumber = exonIx;
                 strandChar = '+';
             }
 	    else {
 		exonIntronNumber = numExonIntrons-exonIx+1;
                 strandChar = '-';
             }
 
-            if (!isEmpty(lf->name))
-                safef(mouseOverText, sizeof(mouseOverText), "%s, strand %c, %s %d of %d", lf->name, strandChar, exonIntronText, exonIntronNumber, numExonIntrons);
+            char* existingText = lf->mouseOver;
+            if (isEmpty(existingText))
+                existingText = lf->name;
+
+            if (!isEmpty(existingText))
+                safef(mouseOverText, sizeof(mouseOverText), "%s, strand %c, %s %d of %d", 
+                        existingText, strandChar, exonIntronText, exonIntronNumber, numExonIntrons);
             else
-                safef(mouseOverText, sizeof(mouseOverText), "strand %c, %s %d of %d", strandChar, exonIntronText, exonIntronNumber, numExonIntrons);
+                safef(mouseOverText, sizeof(mouseOverText), "strand %c, %s %d of %d", 
+                        strandChar, exonIntronText, exonIntronNumber, numExonIntrons);
 
 	    if (w > 0) // draw exon or intron if width is greater than 0
 		{
+                // temporarily remove the mouseOver from the lf, since linkedFeatureMapItem will always 
+                // prefer a lf->mouseOver over the itemName
+                char *oldMouseOver = lf->mouseOver;
+                lf->mouseOver = NULL;
 		tg->mapItem(tg, hvg, item, mouseOverText, tg->mapItemName(tg, item),
 		    sItem, eItem, sx, y, w, heightPer);
+                // and restore the mouseOver
+                lf->mouseOver = oldMouseOver;
+
 		picStart = ex;  // prevent pileups. is this right? add 1? does it work?
 		}
 	    }
 	}
 
     if (isExon)
 	{
     	eLast = e;
 	ref = ref->next;
 	if (!ref)
 	    break;
 	}
     else
 	{
 	exonIx++;
@@ -5215,30 +5228,31 @@
 }
 
 
 void linkedFeaturesMapItem(struct track *tg, struct hvGfx *hvg, void *item,
 				char *itemName, char *mapItemName, int start, int end,
 				int x, int y, int width, int height)
 /* Draw the mouseOver (aka statusLine) text from the mouseOver field of lf
  * Fallback to itemName if there is no mouseOver field.
  * (derived from genericMapItem) */
 {
 // Don't bother if we are imageV2 and a dense child.
 if (theImgBox && tg->limitedVis == tvDense && tdbIsCompositeChild(tg->tdb))
     return;
 
 struct linkedFeatures *lf = item;
+
 char *newItemName   = (isEmpty(lf->mouseOver)) ? itemName: lf->mouseOver;
 
 // copied from genericMapItem
 char *directUrl = trackDbSetting(tg->tdb, "directUrl");
 boolean withHgsid = (trackDbSetting(tg->tdb, "hgsid") != NULL);
 char *trackName = tg->track;
 if (tg->originalTrack != NULL)
     trackName = tg->originalTrack;
 mapBoxHgcOrHgGene(hvg, start, end, x, y, width, height, trackName,
                   mapItemName, newItemName, directUrl, withHgsid, NULL);
 }
 
 int linkedFeaturesFixedTotalHeightNoOverflow(struct track *tg, enum trackVisibility vis)
 {
 return tgFixedTotalHeightOptionalOverflow(tg,vis, tl.fontHeight+1, tl.fontHeight, FALSE);