src/hg/hgTracks/makeItemsTrack.c 1.9
1.9 2010/04/13 07:02:05 kent
Some work getting makeItems tracks to display better in dense and full mode.
Index: src/hg/hgTracks/makeItemsTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/makeItemsTrack.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -b -B -U 4 -r1.8 -r1.9
--- src/hg/hgTracks/makeItemsTrack.c 10 Apr 2010 19:05:24 -0000 1.8
+++ src/hg/hgTracks/makeItemsTrack.c 13 Apr 2010 07:02:05 -0000 1.9
@@ -53,9 +53,9 @@
freez(&dupeCommand);
}
-static int makeItemsExtraHeight(struct track *tg)
+static int makeItemsExtraHeight(struct track *track)
/* Return extra height of track. */
{
return tl.fontHeight+2;
}
@@ -116,17 +116,17 @@
updateTextField(trackName, conn, tableName, "description", id);
}
}
-void makeItemsLoadItems(struct track *tg)
+void makeItemsLoadItems(struct track *track)
/* Load up items in track already. Also make up a pseudo-item that is
* where you drag to create an item. */
{
struct bed *bedList = NULL;
-struct customTrack *ct = tg->customPt;
+struct customTrack *ct = track->customPt;
char *tableName = ct->dbTableName;
struct sqlConnection *conn = hAllocConn(CUSTOM_TRASH);
-makeItemsEditOrDelete(tg->mapName, conn, tableName);
+makeItemsEditOrDelete(track->mapName, conn, tableName);
int rowOffset;
struct sqlResult *sr = hRangeQuery(conn, tableName, chromName, winStart, winEnd, NULL, &rowOffset);
char **row;
while ((row = sqlNextRow(sr)) != NULL)
@@ -142,12 +142,12 @@
}
sqlFreeResult(&sr);
hFreeConn(&conn);
slReverse(&bedList);
-tg->items = bedList;
+track->items = bedList;
}
-char *makeItemsItemName(struct track *tg, void *item)
+char *makeItemsItemName(struct track *track, void *item)
/* Return name of one of an item to display on left side. */
{
struct bed *bed = item;
char *name = bed->name;
@@ -155,31 +155,56 @@
name = skipLeadingSpaces(name);
return name;
}
-void makeItemsDrawItems(struct track *tg, int seqStart, int seqEnd,
+void makeItemsDrawItems(struct track *track, int seqStart, int seqEnd,
struct hvGfx *hvg, int xOff, int yOff, int width,
MgFont *font, Color color, enum trackVisibility vis)
/* Draw simple Bed items. */
{
-int dragBarHeight = makeItemsExtraHeight(tg);
-#ifdef DEBUG
-struct customTrack *ct = tg->customPt;
-char *tableName = ct->dbTableName;
-hvGfxText(hvg, xOff, yOff, color, font, tableName);
-#endif /* DEBUG */
+int dragBarHeight = makeItemsExtraHeight(track);
hvGfxTextCentered(hvg, xOff, yOff, width, dragBarHeight, color, font,
"--- Drag here or in between items to create a new item. ---");
-bedDrawSimple(tg, seqStart, seqEnd, hvg, xOff, yOff + dragBarHeight, width,
+bedDrawSimple(track, seqStart, seqEnd, hvg, xOff, yOff + dragBarHeight, width,
font, color, vis);
}
-int makeItemsTotalHeight(struct track *tg, enum trackVisibility vis)
+
+void makeItemsDrawLeftLabels(struct track *track, int seqStart, int seqEnd,
+ struct hvGfx *hvg, int xOff, int yOff, int width, int height,
+ boolean withCenterLabels, MgFont *font,
+ Color color, enum trackVisibility vis)
+/* Draw left label - just in dense or full mode. Needed to cope with empty space at top of track. */
+{
+int y = yOff + makeItemsExtraHeight(track);
+int fontHeight = mgFontLineHeight(font);
+if (withCenterLabels)
+ y += mgFontLineHeight(font);
+if (vis == tvDense)
+ hvGfxTextRight(hvg, xOff, y, width-1, fontHeight, color, font, track->shortLabel);
+else
+ {
+ struct bed *bed, *bedList = track->items;
+ for (bed = bedList; bed != NULL; bed = bed->next)
+ {
+ if (track->itemLabelColor != NULL)
+ color = track->itemLabelColor(track, bed, hvg);
+ int itemHeight = track->itemHeight(track, bed);
+ hvGfxTextRight(hvg, xOff, y, width - 1,
+ itemHeight, color, font, track->itemName(track, bed));
+ y += itemHeight;
+ }
+ }
+}
+
+
+int makeItemsTotalHeight(struct track *track, enum trackVisibility vis)
/* Most fixed height track groups will use this to figure out the height
* they use. */
{
-return tgFixedTotalHeightOptionalOverflow(tg,vis, tl.fontHeight+1, tl.fontHeight, FALSE) +
- makeItemsExtraHeight(tg);
+track->height = tgFixedTotalHeightOptionalOverflow(track, vis, tl.fontHeight+1, tl.fontHeight, FALSE) +
+ makeItemsExtraHeight(track);
+return track->height;
}
void makeItemsMethods(struct track *track)
@@ -187,9 +212,9 @@
{
bedMethods(track);
track->totalHeight = makeItemsTotalHeight;
track->drawItems = makeItemsDrawItems;
+track->drawLeftLabels = makeItemsDrawLeftLabels;
track->loadItems = makeItemsLoadItems;
track->itemName = makeItemsItemName;
-track->canPack = TRUE;
}