Using ConTeXt for typesetting and metafun to draw, I would like to create a custom colored overlay for my table of contents. I want to fill a colored rectangle for certain TOC entries that stretches from their section number (or rather my fancy number alternative) to the right edge of the page. However whatever I try, my framed metafun overlay is always centered on the framed element, I can't draw asymmetrically off to one side.
Here is a minimal working example.
\setuphead[chapter][number=yes]
\setuphead[section][number=no]
%Draw in TOC
\startuseMPgraphic{TOChighlight}
path p;
p := origin -- origin shifted (0,\overlayheight) -- origin shifted (PaperWidth,\overlayheight) -- origin shifted (PaperWidth,0) --cycle;
fill p withcolor .3red;
\stopuseMPgraphic
\defineoverlay[TOChighlight][\uniqueMPgraphic{TOChighlight}]
\define[1]\ChapterTOCNumber{
\inframed[background=TOChighlight, frame=off]{
\hbox to 3em{\sc \doifnot{\rawstructurelistuservariable{short}}{}{\[\structurelistuservariable{short}\]\crlf} }
}
}
\setuplist[chapter][width=1em, numbercommand=\ChapterTOCNumber, width=5em, alternative=c]
\setuplist[section] [margin=6em]
\starttext
\placecontent[criterium=all]
\startchapter[title=A Vision of The Future][short=What]
\input tufte
\section{What will happen?}
\section{What will cause it?}
\stopchapter
\starttext
\startchapter[title=A Causal Account][short=Why]
\input tufte
\section{Why did it happen?}
\section{Why wasn't it stopped?}
\stopchapter
\stoptext
Everything I try produces results like this:
When what I am trying to achieve is this:
For extra bonus points: I'd also like to continue drawing the color down the right hand edge only until the next chapter (i.e., not subsection) line. Can metapost know where the next chapter line is, even though when the draw command is invoked the next chapter's entry doesn't exist yet?