src/hg/hgTracks/imageV2.c 1.23

1.23 2010/02/12 21:10:03 tdreszer
Removed ifdef IMAGE_V2. Work to move style to common classes. Work for dragScroll.
Index: src/hg/hgTracks/imageV2.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/imageV2.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -b -B -U 4 -r1.22 -r1.23
--- src/hg/hgTracks/imageV2.c	10 Feb 2010 00:37:56 -0000	1.22
+++ src/hg/hgTracks/imageV2.c	12 Feb 2010 21:10:03 -0000	1.23
@@ -71,9 +71,8 @@
     }
 }
 #endif//def FLAT_TRACK_LIST
 
-#ifdef IMAGEv2_UI
 /////////////////////////
 // IMAGEv2
 // The new way to do images: PLEASE REFER TO imageV2.h FOR A DETAILED DESCRIPTION
 /////////////////////////
@@ -1416,28 +1415,32 @@
 /* writes an image as HTML */
 {
 if(slice->parentImg && slice->parentImg->file != NULL)
     {
-    hPrintf("  <IMG id='img_%s' src='%s' style='position:relative; left:-%dpx; top: -%dpx; border:0;'",
+    hPrintf("  <IMG id='img_%s' src='%s' style='left:-%dpx; top: -%dpx;'",
             name,slice->parentImg->file,offsetX,offsetY);
+    // Problem: dragScroll beyond left shows ugly leftLabel!
+    // Tried clip:rect() but this only works with position:absolute!
+    // May need to split image betweeen side label and data!!! That is a big change.
 
     if(useMap)
         hPrintf(" usemap='#map_%s'",name);
-    if(slice->type==stSide)
-        hPrintf(" class='sideLab'");
-    else if(slice->type==stCenter)
-        hPrintf(" class='centerLab'");
-    else if(slice->type==stButton)
-        hPrintf(" class='button'");
-    #ifdef IMAGEv2_DRAG_SCROLL
-    else if(slice->type==stData && imgBox->showPortal)
-        hPrintf(" class='panImg' ondrag='{return false;}'");
-    #endif //def IMAGEv2_DRAG_SCROLL
+    hPrintf(" class='sliceImg ");
+    switch (slice->type)
+        {
+        case stSide:   hPrintf("sideLab"); break;
+        case stCenter: hPrintf("cntrLab"); break;
+        case stButton: hPrintf("button");  break;
+        case stData:   hPrintf("dataImg"); break;
+        default: warn("unknown slice = %d !",slice->type); break;
+        }
+    if(slice->type==stData && imgBox->showPortal)
+        hPrintf(" panImg' ondrag='{return false;}");
     if(slice->title != NULL)
-        hPrintf(" title='%s'",slice->title);           // Adds slice wide title
+        hPrintf("' title='%s",slice->title);           // Adds slice wide title
     else if(slice->parentImg->title != NULL)
-        hPrintf(" title='%s'",slice->parentImg->title);// Adds image wide title
-    hPrintf(">");
+        hPrintf("' title='%s",slice->parentImg->title);// Adds image wide title
+    hPrintf("'>");
     }
 else
     {
     hPrintf("  <p id='p_%s' style='height:%dpx;",name,slice->height);
@@ -1478,14 +1481,14 @@
         {
         offsetX += (imgBox->portalStart - imgBox->chromStart) / imgBox->basesPerPixel;
         width=imgBox->portalWidth;
         }
-        hPrintf("  <div style='width:%dpx; height:%dpx; overflow:hidden;'",width,slice->height);
+        hPrintf("  <div style='width:%dpx; height:%dpx;' class='sliceDiv",width,slice->height);
     #ifdef IMAGEv2_DRAG_SCROLL
     if(imgBox->showPortal && sliceType==stData)
-        hPrintf(" class='panDiv%s'",(scrollHandle?" scroller":""));
+        hPrintf(" panDiv%s",(scrollHandle?" scroller":""));
     #endif //def IMAGEv2_DRAG_SCROLL
-    hPrintf(">\n");
+    hPrintf("'>\n");
     }
 struct mapSet *map = sliceGetMap(slice,FALSE); // Could be the image map or slice specific
 if(map)
     useMap = imageMapDraw(map,name);
@@ -1514,9 +1517,8 @@
 boolean verbose = (hIsPrivateHost());   // Warnings for hgwdev only
 if(!imgBoxIsComplete(imgBox,verbose)) // dorps empties as okay
     return;
 char name[256];
-int bgOffset = NO_VALUE;
 
 imgBoxTracksNormalizeOrder(imgBox);
 //if(verbose)
 //    imgBoxShow(NULL,imgBox,0);
@@ -1539,8 +1541,27 @@
 hPrintf(".btnL {border-width:0px 1px 0px 1px; margin:0px 1px 0px 1px;}\n"); // connect linear
 hPrintf(".btnBlue {background-color:#91B3E6; border-color:#91B3E6;}\n");
 #endif//def FLAT_TRACK_LIST
 hPrintf("div.dragZoom {cursor: text;}\n");
+//#ifndef FLAT_TRACK_LIST
+hPrintf("img.button {position:relative; border:0;}\n");
+//#endif//ndef FLAT_TRACK_LIST
+hPrintf("img.sliceImg {position:relative; border:0;}\n");
+hPrintf("div.sliceDiv {overflow:hidden;}\n");
+if(imgBox->bgImg)
+    {
+    int offset = 0;
+    if(imgBox->showSideLabel && imgBox->plusStrand)
+        {
+        struct imgSlice *slice = imgTrackSliceGetByType(imgBox->imgTracks,stData);
+        if(slice)
+            offset = (slice->offsetX * -1);  // This works because the ruler has a slice
+         }
+    if(offset != 0)
+        hPrintf("td.tdData {background-image:url(\"%s\");background-repeat:repeat-y;background-position:%dpx;}\n",imgBox->bgImg->file,offset);
+    else
+        hPrintf("td.tdData {background-image:url(\"%s\");background-repeat:repeat-y;}\n",imgBox->bgImg->file);
+    }
 hPrintf("</style>\n");
 
 #ifdef IMAGEv2_DRAG_SCROLL
 if(imgBox->showPortal)
@@ -1560,10 +1581,9 @@
 hPrintf(" width=%d",imgBox->showPortal?(imgBox->portalWidth+imgBox->sideLabelWidth):imgBox->width);
 #ifdef IMAGEv2_DRAG_REORDER
 hPrintf(" class='tableWithDragAndDrop'");
 #endif//def IMAGEv2_DRAG_REORDER
-hPrintf(" style='border:1px solid blue;border-collapse:separate;");
-hPrintf("'>\n");
+hPrintf(" style='border:1px solid blue;border-collapse:separate;'>\n");
 
 struct imgTrack *imgTrack = imgBox->imgTracks;
 for(;imgTrack!=NULL;imgTrack=imgTrack->next)
     {
@@ -1588,25 +1608,9 @@
         hPrintf("</TD>\n");
         }
 
     // Main/Data image region
-    hPrintf(" <TD id='td_data_%s' width=%d class='tdData'", trackName, imgBox->width);
-    if(imgBox->bgImg)
-        {
-        if(imgBox->showSideLabel && imgBox->plusStrand)
-            {
-            if(bgOffset == NO_VALUE)
-                {
-                struct imgSlice *slice = imgTrackSliceGetByType(imgTrack,stData);
-                if(slice)
-                    bgOffset = (slice->offsetX * -1);  // This works because the ruler has a slice
-                }
-            hPrintf(" style='background-image:url(\"%s\");background-position:%dpx;'",imgBox->bgImg->file,bgOffset);
-            }
-        else
-            hPrintf(" style='background-image:url(\"%s\");'",imgBox->bgImg->file);
-        }
-    hPrintf(">\n");
+    hPrintf(" <TD id='td_data_%s' width=%d class='tdData'>\n", trackName, imgBox->width);
     hPrintf("  <input TYPE=HIDDEN name='%s_%s' value='%d'>\n",trackName,IMG_ORDER_VAR,imgTrack->order);
     // centerLabel
     if(imgTrack->showCenterLabel)
         {
@@ -1637,9 +1641,4 @@
     }
 hPrintf("</TABLE>\n");
 hPrintf("<!---------------^^^ IMAGEv2 ^^^---------------->\n");
 }
-
-// Nice to do:
-// 1) For composites in dense (those without a title), replace map items with toggle!  Sould we?
-
-#endif//def IMAGEv2_UI