Index: src/hg/hgTracks/hgTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/hgTracks.c,v
retrieving revision 1.1577
retrieving revision 1.1578
diff -b -B -U 4 -r1.1577 -r1.1578
--- src/hg/hgTracks/hgTracks.c	26 Jun 2009 20:24:57 -0000	1.1577
+++ src/hg/hgTracks/hgTracks.c	27 Jun 2009 20:12:07 -0000	1.1578
@@ -1572,8 +1572,10 @@
 int sideSliceOffsetX = 0;
 int dataSliceOffsetX = 0;
 int sliceHeight  = 0;
 int sliceOffsetY = 0;
+char *rulerTtl = (dragZooming?"drag select or click to zoom":"click to zoom 3x");//"click or drag mouse in base position track to zoom in" : NULL);
+char *sideTtl  = "Drag to reorder tracks";
 #endif//def IMAGEv2_UI
 
 if (rulerMode != tvFull)
     {
@@ -1684,10 +1686,10 @@
     trashDirFile(&gifTn, "hgt", "hgt", ".gif");
     hvg = hvGfxOpenGif(pixWidth, pixHeight, gifTn.forCgi);
     #ifdef IMAGEv2_UI
     // Adds one single image for all tracks (TODO: build the track by track images)
-    theOneImg = imgBoxImageAdd(theImgBox,gifTn.forHtml,
-        (char *)(dragZooming?"click or drag mouse in base position track to zoom in" : NULL),
+    theOneImg = imgBoxImageAdd(theImgBox,gifTn.forHtml,NULL,
+       // (char *)(dragZooming?"click or drag mouse in base position track to zoom in" : NULL),
         pixWidth, pixHeight,FALSE);
     //curMap = imgMapStart(theOneImg,"theOne",NULL); // No common linkRoot (TODO: Drop image map in favor of slice maps)
     #endif//def IMAGEv2_UI
     }
@@ -1727,12 +1729,12 @@
         if (rulerCds)
             height += rulerTranslationHeight;
         #ifdef IMAGEv2_UI
             {
-            // Start Track, Add slice and start mapping the slice
+            // Mini-buttons (side label slice) for ruler
             sliceHeight      = height + 1;
             sliceOffsetY     = 0;
-            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,FALSE); // No tdb, no centerlabel, not reorderable
+            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,IMG_FIXEDPOS); // No tdb, no centerlabel, not reorderable
             curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
             curMap      = sliceMapFindOrStart(curSlice,RULER_TRACK_NAME,NULL); // No common linkRoot
             }
         #endif//def IMAGEv2_UI
@@ -1762,12 +1764,12 @@
                             h, track->hasUi);
             if (track->hasUi)
                 {
                 #ifdef IMAGEv2_UI
-                // Start Track, Add slice and start mapping the slice
+                // Mini-buttons (side label slice) for tracks
                 sliceHeight      = h;
                 sliceOffsetY     = yStart;
-                curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),TRUE);
+                curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
                 curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
                 curMap      = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
                 #endif//def IMAGEv2_UI
                 mapBoxTrackUi(hvg, trackTabX, yStart, trackTabWidth, h,
@@ -1790,12 +1792,12 @@
     if (rulerMode != tvHide)
         {
         #ifdef IMAGEv2_UI
             {
-            // Start Track, Add slice and start mapping the slice
+            // side label slice for ruler
             sliceHeight      = basePositionHeight + (rulerCds ? rulerTranslationHeight : 0) + 1;
             sliceOffsetY     = 0;
-            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,FALSE); // No tdb, no centerlabel,not reorderable
+            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,IMG_FIXEDPOS); // No tdb, no centerlabel,not reorderable
             curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
             curMap      = sliceMapFindOrStart(curSlice,RULER_TRACK_NAME,NULL); // No common linkRoot
             }
         #endif//def IMAGEv2_UI
@@ -1857,15 +1859,16 @@
         if (track->limitedVis == tvHide)
             continue;
         #ifdef IMAGEv2_UI
             {
+            // side label slice for tracks
             // FIXME: Notice I am treating all subtracks as indivisible from their composite
             // This will need to change to allow drag and drop.  Until then the subtrack center labels will drag scroll while the composte will not.
             // But as soon as subtracks are individual image tracks: problems with buttons, left labels, center labels, drag and drop, etc.
             sliceHeight      = trackPlusLabelHeight(track, fontHeight);
             sliceOffsetY     = y;
-            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),TRUE);
-            curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
+            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
+            curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,sideTtl,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
             curMap      = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
             }
         #endif//def IMAGEv2_UI
         if (trackIsCompositeWithSubtracks(track))  //TODO: Change when tracks->subtracks are always set for composite
@@ -1918,12 +1921,13 @@
 if (rulerMode != tvHide)
     {
     #ifdef IMAGEv2_UI
         {
+        // data slice for ruler
         sliceHeight      = basePositionHeight + (rulerCds ? rulerTranslationHeight : 0) + 1;
         sliceOffsetY     = 0;
-        curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,FALSE); // No tdb, no centerlabel,not reorderable
-        curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isData,theOneImg,NULL,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
+        curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,IMG_FIXEDPOS); // No tdb, no centerlabel,not reorderable
+        curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isData,theOneImg,rulerTtl,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
         curMap      = sliceMapFindOrStart(curSlice,RULER_TRACK_NAME,NULL); // No common linkRoot
         }
     #endif//def IMAGEv2_UI
     struct dnaSeq *seq = NULL;
@@ -2145,14 +2149,15 @@
             continue;
         #ifdef IMAGEv2_UI
         //if (isWithCenterLabels(track))  // NOTE: Since track may not have centerlabel but subtrack may (How?), then must always make this slice!
             {
+            // center label slice of tracks
             // FIXME: Notice I am treating all subtracks as indivisible from their composite
             // This will need to change to allow drag and drop.  Until then the subtrack center labels will drag scroll while the composte will not.
             // But as soon as subtracks are individual image tracks: problems with buttons, left labels, center labels, drag and drop, etc.
             sliceHeight      = fontHeight;
             sliceOffsetY     = y;
-            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),TRUE);
+            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
             curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isCenter,theOneImg,NULL,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
             curMap      = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
             }
         #endif//def IMAGEv2_UI
@@ -2161,8 +2166,9 @@
             if (isWithCenterLabels(track))
                 y = doCenterLabels(track, track, hvg, font, y) - track->height; /* subtrack heights tallied below: */
             #ifdef IMAGEv2_UI
                 {
+                // Special case: data slice of tracks
                 // FIXME: This special case allows the subtrack center label map items to be put into the data slice
                 // When subtracks are carved up into individual imgTracks, then this will not be necessary
                 sliceHeight      = trackPlusLabelHeight(track, fontHeight) - fontHeight;
                 sliceOffsetY     = y;
@@ -2198,17 +2204,25 @@
         if (track->limitedVis == tvHide)
                 continue;
         #ifdef IMAGEv2_UI
             {
+            // data slice of tracks
             // FIXME: Notice I am treating all subtracks as indivisible from their composite
             // This will need to change to allow drag and drop.  Until then the subtrack center labels will drag scroll while the composte will not.
             // But as soon as subtracks are individual image tracks: problems with buttons, left labels, center labels, drag and drop, etc.
             sliceHeight      = trackPlusLabelHeight(track, fontHeight) - (isWithCenterLabels(track) ? fontHeight : 0);
             sliceOffsetY     = y + (isWithCenterLabels(track) ? fontHeight : 0);
-            curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),TRUE);
+            char var[128];
+            safef(var,sizeof(var),"%s_%s",track->tdb->tableName,IMG_ORDER_VAR);
+            int order = cartUsualInt(cart, var,IMG_ANYORDER);
+            //warn("Found:%s has order:%d",var,order);
+            curImgTrack = imgBoxTrackUpdateOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),order);
+            if(sliceHeight > 0)
+                {
             curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isData,theOneImg,NULL,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
             curMap      = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
             }
+            }
         #endif//def IMAGEv2_UI
         if (trackIsCompositeWithSubtracks(track))  //TODO: Change when tracks->subtracks are always set for composite
             {
             struct track *subtrack;
@@ -2235,15 +2249,16 @@
 	if (track->limitedVis == tvHide)
             continue;
     #ifdef IMAGEv2_UI
         {
+        // side label slice of tracks
         // FIXME: Notice I am treating all subtracks as indivisible from their composite
         // This will need to change to allow drag and drop.  Until then the subtrack center labels will drag scroll while the composte will not.
         // But as soon as subtracks are individual image tracks: problems with buttons, left labels, center labels, drag and drop, etc.
         sliceHeight      = trackPlusLabelHeight(track, fontHeight);
         sliceOffsetY     = y;
-        curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),TRUE);
-        curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
+        curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
+        curSlice    = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,sideTtl,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
         curMap      = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
         }
     #endif//def IMAGEv2_UI
     if (trackIsCompositeWithSubtracks(track))  //TODO: Change when tracks->subtracks are always set for composite

