3bdd753973190ec7e64d85a90ab912b9a7c37489
angie
  Fri Sep 4 13:45:27 2020 -0700
Move leftLabelWidth parameters out of hgTracks global variables into trackLayout lib (for use by hgPhyloPlace).  refs #25943

diff --git src/hg/lib/trackLayout.c src/hg/lib/trackLayout.c
index 019d218..cb7e331 100644
--- src/hg/lib/trackLayout.c
+++ src/hg/lib/trackLayout.c
@@ -62,16 +62,28 @@
 boolean fontExtras = trackLayoutInclFontExtras();
 if (fontExtras)
     fontType = cartUsualString(cart, "fontType", fontType);
 
 tl->textFont = cartUsualString(cart, textFontVar, cfgOptionDefault("freeTypeFont","Helvetica"));
 tl->textSize = mgFontSizeBackwardsCompatible(cartUsualString(cart, textSizeVar, cfgOptionDefault(textSizeVar,"small")));
 MgFont *font = mgFontForSizeAndStyle(tl->textSize, fontType);
 tl->font = font;
 tl->mWidth = mgFontStringWidth(font, "M");
 tl->nWidth = mgFontStringWidth(font, "n");
 tl->fontHeight = mgFontLineHeight(font);
 tl->barbHeight = tl->fontHeight/4;
 tl->barbSpacing = (tl->fontHeight+1)/2;
 tl->picWidth = hgDefaultPixWidth;
 trackLayoutSetPicWidth(tl, cartOptionalString(cart, "pix"));
+// label width, but don't exceed 1/2 of image
+tl->leftLabelWidthChars = cartUsualInt(cart, leftLabelWidthVar, leftLabelWidthDefaultChars);
+if (tl->leftLabelWidthChars < 2)
+    tl->leftLabelWidthChars = leftLabelWidthDefaultChars;
+tl->leftLabelWidth = tl->leftLabelWidthChars*tl->nWidth + trackTabWidth + 3;
+int maxLabelWidth = 0.5*tl->picWidth;
+if (tl->leftLabelWidth  > maxLabelWidth)
+    {
+    // overflow, force to 1/2 width
+    tl->leftLabelWidthChars = maxLabelWidth/tl->nWidth;
+    tl->leftLabelWidth = tl->leftLabelWidthChars * tl->nWidth;
+    }
 }