106895cbff17848866e9b5cfeefb0ce1985203a1
tdreszer
  Wed Oct 5 16:52:11 2011 -0700
More tightening of screws.  Several special cases solved. Altererd which right-click menu items for cfg appear and regularized this with subCfg availability.
diff --git src/hg/hgTracks/imageV2.c src/hg/hgTracks/imageV2.c
index 6400df8..41b959c 100644
--- src/hg/hgTracks/imageV2.c
+++ src/hg/hgTracks/imageV2.c
@@ -55,30 +55,32 @@
     if (track->customTrack)
         flatTrack->order = ++topOrder; // Custom tracks go to top
     else
 #endif///def IMGORD_CUSTOM_ONTOP
         flatTrack->order = ++lastOrder;
     }
 
 slAddHead(flatTracks,flatTrack);
 }
 
 int flatTracksCmp(const void *va, const void *vb)
 // Compare to sort on flatTrack->order
 {
 const struct flatTracks *a = *((struct flatTracks **)va);
 const struct flatTracks *b = *((struct flatTracks **)vb);
+if (a->order == b->order)
+    return tgCmpPriority(a->track,b->track);
 return (a->order - b->order);
 }
 
 #ifdef IMGORD_CUSTOM_ONTOP
 void flatTracksSort(struct flatTracks **flatTracks)
 // This routine sorts the imgTracks then forces tight ordering, so new tracks wil go to the end
 {
 // flatTracks list has 2 sets of "order": those already dragReordered (below IMG_ORDERTOP)
 // and those not yet reordered (above).  Within those not yet dragReordered are 2 sets:
 // Those that begin numbering at IMG_ORDERTOP and those that begin at IMG_ORDEREND.
 // This routine must determine if there are any already dragOrdered, and if so, position the
 // newcomers in place.  Newly appearing customTracks will appear at top, while newly appearing
 // standard tracks appear at the end of the image.
 int haveBeenOrderd = 0, imgOrdHighest=0; // Keep track of reordered count and position
 int notYetOrdered = 0, toBeTopHighest=0; // Keep track of those to be reordered, and top ordered
@@ -279,34 +281,34 @@
     struct trackDb *parentTdb = (kindOfChild == kocFolderContent ? track->tdb->parent :tdbGetContainer(track->tdb));
 
     jsonHashAddString(ele, "parentTrack", parentTdb->track);
     jsonHashAddString(ele, "parentLabel", parentTdb->shortLabel);
     if (kindOfChild != kocFolderContent && !track->canPack)
         {
         jsonHashAddNumber(ele, "shouldPack", 0); // default vis is full, but pack is an option
         track->canPack = parentTdb->canPack;
         }
     }
 
 // XXXX really s/d be numChildren
 jsonHashAddNumber(ele, "hasChildren", slCount(track->tdb->subtracks));
 
 // Configuring?
-if (!configurable || track->hasUi == FALSE)
+int cfgByPopup = configurableByPopup(track->tdb,0);
+if (!configurable || track->hasUi == FALSE || cfgByPopup == 0)
     jsonHashAddString(ele, "configureBy", "none");
-else if (sameString(trackDbSettingClosestToHomeOrDefault(track->tdb, "configureByPopup",
-    regexMatch(track->track, "^snp[0-9]+") || regexMatch(track->track, "^cons[0-9]+way") || regexMatch(track->track, "^multiz") ? "off" : "on"), "off"))
+else if (cfgByPopup < 0)
     jsonHashAddString(ele, "configureBy", "clickThrough");
 else
     jsonHashAddString(ele, "configureBy", "popup");
 
 // Remote access by URL?
 if (sameWord(track->tdb->type, "remote") && trackDbSetting(track->tdb, "url") != NULL)
     jsonHashAddString(ele, "url", trackDbSetting(track->tdb, "url"));
 
 // Close with some standard vars
 jsonHashAddString(ele, "shortLabel", track->shortLabel);
 jsonHashAddString(ele, "longLabel", track->longLabel);
 jsonHashAddNumber(ele, "canPack", track->canPack);
 
 if(track->limitedVis != track->visibility)
     jsonHashAddNumber(ele, "limitedVis", track->limitedVis);