%D \module
%D   [      file=s-present-shaded,
%D        version=2014.04.30,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment Shaded Content,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D As usual, this style was made for a Bacho\TeX\ conference. It doesn't do anything
%D special apart from progressively changing the shaded backgrounds. You can
%D redefine the colors \type {maincolor} and \type {othercolor} to suit your taste.

\startmodule[present-shaded]

\setuppapersize[S6]

\setuplayout
  [cutspace=120pt,
   rightmargin=100pt,
   margindistance=10pt,
   rightmargin=0pt,
   margindistance=0pt,
   rightedge=100pt,
   edgedistance=12.5pt,
   backspace=10pt,
   topspace=10pt,
   bottomspace=10pt,
   header=0pt,
   footer=0pt,
   width=middle,
   height=middle]

\setupbodyfont
  [dejavu]

\setuplist
  [chapter]
  [before=,
   after=,
   inbetween=\vskip5pt,
   inbetween=\vfill,
   alternative=e,
   width=\hsize,
   height=\measure{menu-item-height},
   style=bold,
   frame=off,
   background=color,
   backgroundcolor=\structurelistuservariable{color},
   criterium=text]

\setupcolors
  [textcolor=white]

\setupinteraction
  [state=start,
   menu=on,
   color=white,
   click=off,
   contrastcolor=white]

\setupinteractionmenu
  [right]
  [topoffset=5pt,
   bottomoffset=5pt]

\startinteractionmenu[right]
    \placelist[chapter]
\stopinteractionmenu

\definecolor[maincolor] [b=.4]
\definecolor[othercolor][s=.4]

\definecolor[verydark][s=.2]
\definecolor[lessdark][1.5(verydark)]

%  we need some extra counter values: \getstructurenumber{self}

\setupmodule
  [n=\the\numexpr\lastpage-\plusone\relax]

\appendtoks
    \dorecurse {\moduleparameter{present-shaded}{n}} {
        \definecolor[shade:#1][\luaexpr{.8*#1/\moduleparameter{present-shaded}{n}}(maincolor,othercolor)]
    }
\to \everystarttext

\setupbackgrounds
  [page]
  [background=color,
   backgroundoffset=5pt,
   backgroundcolor=verydark]

\setupbackgrounds
  [text]
  [background={invoke,color},
   backgroundoffset=5pt,
   backgroundcolor=\namedstructureuservariable{chapter}{color}]

\definemeasure
  [menu-item-height]
  [(\textheight-\numexpr\moduleparameter{present-shaded}{n}-1\relax\dimexpr5pt\relax)/\moduleparameter{present-shaded}{n}]

\setupitemgroup
  [itemize]
  [packed]

\setuphead
  [chapter]
  [number=no,
   style=\bfc]

\setuphead
  [section]
  [number=no,
   style=\bf,
   before=\blank,
   after=\blank]

\setupdocument
  [title=Title,
   subtitle=Subtitle,
   location=\currentdate]

\startsetups document:start

    \setupbackgrounds
      [text]
      [backgroundcolor=lessdark]

    \startstandardmakeup

        \setupalign[middle]

        \vfil
        \dontleavehmode \scale[width=.8\textwidth] {\documentvariable{title}}
        \vfil
        \dontleavehmode \scale[width=.6\textwidth] {\documentvariable{subtitle}}
        \vfil \vfil \vfil
        \dontleavehmode \scale[width=.4\textwidth] {\documentvariable{location}}
        \vfil

    \stopstandardmakeup

    \setupbackgrounds
      [text]
      [backgroundcolor=\namedstructureuservariable{chapter}{color}]

\stopsetups

\stopmodule

\continueifinputfile{s-present-shaded.mkiv}

\usemodule[present-common]

\inputpresentationfile{examples/present-shaded-001.tex}
