447513356fcfa684846bdd1b63476e68d9c17ce9 chmalee Thu Apr 6 09:04:41 2023 -0700 Add code to create tooltips under our control. Convert title attributes on hgTracks into these tooltips diff --git src/hg/hgTracks/imageV2.c src/hg/hgTracks/imageV2.c index be3b5b0..d885cd2 100644 --- src/hg/hgTracks/imageV2.c +++ src/hg/hgTracks/imageV2.c @@ -1885,31 +1885,31 @@ hPrintf(" width:9px; display:none;' class='%s %sbtn btnN'>

", trackName,(slice->link == NULL ? "inset " : "")); } else hPrintf("width:%dpx;'>

",slice->width); } } // FF does not support newline code and '...' looks bad without newlines #define NEWLINE_ENCODED " " #define NEWLINE_NOT_SUPPORTED " - " #define NEWLINE_TO_USE(browser) ((browser) == btFF ? NEWLINE_NOT_SUPPORTED : NEWLINE_ENCODED) #define ELLIPSIS_TO_USE(browser) ((browser) == btFF ? "" : "...") static void sliceAndMapDraw(struct imgBox *imgBox,struct imgTrack *imgTrack, - enum sliceType sliceType,char *name,boolean scrollHandle) + enum sliceType sliceType,char *name,boolean scrollHandle, struct jsonElement *ele) // writes a slice of an image and any assocated image map as HTML { if (imgBox==NULL || imgTrack==NULL) return; struct imgSlice *slice = imgTrackSliceGetByType(imgTrack,sliceType); if (slice==NULL || slice->height == 0) return; boolean useMap=FALSE; int offsetX=slice->offsetX; int offsetY=slice->offsetY; int height = slice->height; int width=slice->width; if (slice->parentImg) { @@ -1967,30 +1967,33 @@ char *ellipsis = ELLIPSIS_TO_USE(browser); if (imgTrack->reorderable) hPrintf(" TITLE='%s%sclick or right click to configure%s%sdrag to reorder%s'", attributeEncode(slice->title), newLine, ellipsis, newLine, (tdbIsCompositeChild(imgTrack->tdb) ? " highlighted subtracks" : "") ); else hPrintf(" TITLE='%s%sclick or right click to configure%s'", attributeEncode(slice->title), newLine, ellipsis); } else hPrintf(" TITLE='Click for: %s'", attributeEncode(slice->title) ); } hPrintf(">\n" ); } +char *trackName = (imgTrack->name != NULL ? imgTrack->name : imgTrack->tdb->track ); +struct jsonElement *trackHash = jsonFindNamedField(ele, "trackDb", trackName); +jsonObjectAdd(trackHash, "imgOffsetY", newJsonNumber(offsetY)); imageDraw(imgBox,imgTrack,slice,name,offsetX,offsetY,useMap); if (slice->link != NULL) hPrintf(""); if (slice->parentImg) hPrintf(""); } struct imgTrack *smashSquish(struct imgTrack *imgTrackList) /* Javascript doesn't know about our trick to do squishyPack so we need to pass it a single div instead of two. * We assume that the linked track immediately follows the original track in the sorted list. */ { struct imgTrack *nextImg, *imgTrack; for (imgTrack = imgTrackList; imgTrack!=NULL;imgTrack = nextImg) @@ -2094,66 +2097,66 @@ { char *trackName = (imgTrack->name != NULL ? imgTrack->name : imgTrack->tdb->track ); struct track *track = hashFindVal(trackHash, trackName); if (track) jsonTdbSettingsBuild(jsonTdbVars, track, TRUE); hPrintf("\n",trackName,imgTrack->order, (imgTrack->reorderable ? " trDraggable" : " nodrop nodrag"), (imgTrack->centerLabelSeen != clAlways ? " clOpt" : ""), (imgTrack->ajaxRetrieval ? " mustRetrieve" : "")); if (imgBox->showSideLabel && imgBox->plusStrand) { // button safef(name, sizeof(name), "btn_%s", trackName); hPrintf(" \n",name,(imgTrack->reorderable ? " class='dragHandle'" : "")); - sliceAndMapDraw(imgBox,imgTrack,stButton,name,FALSE); + sliceAndMapDraw(imgBox,imgTrack,stButton,name,FALSE, jsonTdbVars); hPrintf("\n"); // leftLabel safef(name,sizeof(name),"side_%s",trackName); if (imgTrack->reorderable) hPrintf(" \n", name,attributeEncode(imgTrack->tdb->longLabel),newLine); else hPrintf(" \n",name); - sliceAndMapDraw(imgBox,imgTrack,stSide,name,FALSE); + sliceAndMapDraw(imgBox,imgTrack,stSide,name,FALSE, jsonTdbVars); hPrintf("\n"); } // Main/Data image region hPrintf(" \n", trackName, imgBox->width); // centerLabel if (imgTrack->hasCenterLabel) { safef(name, sizeof(name), "center_%s", trackName); - sliceAndMapDraw(imgBox,imgTrack,stCenter,name,TRUE); + sliceAndMapDraw(imgBox,imgTrack,stCenter,name,TRUE, jsonTdbVars); hPrintf("\n"); } // data image safef(name, sizeof(name), "data_%s", trackName); - sliceAndMapDraw(imgBox,imgTrack,stData,name,(imgTrack->order>0)); + sliceAndMapDraw(imgBox,imgTrack,stData,name,(imgTrack->order>0), jsonTdbVars); hPrintf("\n"); if (imgBox->showSideLabel && !imgTrack->plusStrand) { // rightLabel safef(name, sizeof(name), "side_%s", trackName); if (imgTrack->reorderable) hPrintf(" \n", name,attributeEncode(imgTrack->tdb->longLabel),newLine); else hPrintf(" \n",name); - sliceAndMapDraw(imgBox,imgTrack,stSide,name,FALSE); + sliceAndMapDraw(imgBox,imgTrack,stSide,name,FALSE, jsonTdbVars); hPrintf("\n"); // button safef(name, sizeof(name), "btn_%s", trackName); hPrintf(" \n",name,(imgTrack->reorderable ? " class='dragHandle'" : "")); - sliceAndMapDraw(imgBox,imgTrack,stButton, name,FALSE); + sliceAndMapDraw(imgBox,imgTrack,stButton, name,FALSE, jsonTdbVars); hPrintf("\n"); } hPrintf("\n"); } hPrintf("\n"); hPrintf("\n"); jsonTdbSettingsUse(jsonTdbVars); }