%D \module
%D   [      file=simpleslides-s-Framed,
%D        version=2022.07.13,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module --- Framed Style,
%D         author=Aditya Mahajan and Thomas A. Schmitz,
%D           date=\currentdate,
%D      copyright={Aditya Mahajan and Thomas A. Schmitz}]
%C
%C Copyright 2007 Aditya Mahajan and Thomas A. Schmitz
%C This file may be distributed under the GNU General Public License v. 2.0.

%D This file provides the \quotation{Framed} style for the presentation
%D module. It is loaded at runtime.

\writestatus{simpleslides}{loading style Framed}

\startmodule[simpleslides-s-Framed]

\unprotect

%D The page layout:

\setuplayout [width=fit,
              margin=0.6cm,
              height=fit,
              header=2.1cm,
              footer=1.35cm,
	      footerdistance=0.5cm,
              topspace=0.5cm,
              backspace=1cm,
              location=singlesided]

\setuplayout [simpleslides:layout:horizontal][header=2.1cm,backspace=1cm]
\setuplayout [simpleslides:layout:vertical]  [header=0cm,backspace=1cm]
\setuplayout [simpleslides:layout:title]     [header=0cm,backspace=0.5cm]

%D We also specify the position of the slidetitle.

\setuplayer[simpleslides:layer:slidetitle]
    [x=10mm,y=3mm]

%D These macros are used for placing figures/pictures:

\define\NormalHeight        {.975\textheight}
\define\NormalWidth         {.485\textwidth}
\define\PictureFrameHeight  {.975\textheight}
\define\PictureFrameWidth   {.485\textwidth}


%D We define our colors:

\definecolor [simpleslides:backgroundcolor]   [r=.85, g=.85, b=.85]
\definecolor [simpleslides:framecolor]        [r=.42, g=.42, b=.7]
\definecolor [simpleslides:contrastcolor]     [r=0, g=0, b=.5]
\definecolor [simpleslides:variantcolor]      [r=0, g=0, b=1]
\definecolor [simpleslides:itemize:color]     [simpleslides:contrastcolor]

%D We let \METAPOST\ calculate the background. This style have two options for
%D ornaments, square or stripes. We define both, and then choose one depending
%D on the user's choice.

\startuseMPgraphic{simpleslides:MP:ornament:square}
StartPage;

save a,b,c,p;
numeric a; a = 0.955cm ;
numeric b; b = 0.52cm ;
numeric c; c = 0.8cm ;
path p[] ;

for i=1 upto 11:
	p[i] = unitsquare xyscaled (a,a) shifted (b+2*(i-1)*a, c) ;
    fill p[i] withcolor ((i-1)/10)[\MPcolor{simpleslides:contrastcolor},
                                   \MPcolor{simpleslides:variantcolor}] ;
endfor ;

if NOfPages >= 12:
  save n ; numeric n ;
  n := (10*(RealPageNumber - 1) div (NOfPages - 1)) + 1;

  draw llcorner p[n] -- urcorner p[n]
         withpen pencircle scaled 2pt
         withcolor \MPcolor{simpleslides:backgroundcolor} ;
fi ;

StopPage;
\stopuseMPgraphic

\startuseMPgraphic{simpleslides:MP:ornament:stripe}
StartPage;

save p ;
path p[] ;

p[1] := unitsquare xyscaled(0.95*OverlayWidth,1cm) shifted (0.52cm,0.8cm) ;

linear_shade(p[1],0,
            \MPcolor{simpleslides:backgroundcolor},
            \MPcolor{simpleslides:contrastcolor}) ;

save i ;
numeric i;
if NOfPages = 0 :
  i = RealPageNumber ;
else :
  i = RealPageNumber/NOfPages ;
fi ;

p[2] = ulcorner p[1] -- urcorner p[1] ;
p[3] = llcorner p[1] -- lrcorner p[1] ;

save o;
pair o[] ;

o[1] := point i along p[2] ;
o[2] := point i along p[3] ;

p[4] = ulcorner p[1] -- o[1] -- o[2] -- llcorner p[1] -- cycle ;

clip currentpicture to p[4] ;

StopPage;
\stopuseMPgraphic

\startuniqueMPgraphic{simpleslides:MP:vertical}
StartPage ;

fill Page withcolor \MPcolor{simpleslides:backgroundcolor} ;

draw Page enlarged (-.2cm)
          withpen pencircle scaled 4pt
          withcolor \MPcolor{simpleslides:framecolor} ;

draw unitsquare
     xyscaled(0.448*PaperWidth,0.815*PaperHeight)
     shifted (0.528*PaperWidth, 0.15*PaperHeight)
     withpen pencircle scaled 2pt
     withcolor \MPcolor{simpleslides:framecolor} ;

StopPage ;
\stopuniqueMPgraphic

\startuniqueMPgraphic{simpleslides:MP:horizontal}
StartPage ;

fill Page withcolor \MPcolor{simpleslides:backgroundcolor} ;

draw Page enlarged (-.2cm)
          withpen pencircle scaled 4pt
          withcolor \MPcolor{simpleslides:framecolor} ;

draw unitsquare
     xyscaled(0.95*PaperWidth,0.7*PaperHeight)
     shifted (0.025*PaperWidth, 0.15*PaperHeight)
     withpen pencircle scaled 2pt
     withcolor \MPcolor{simpleslides:framecolor} ;

StopPage;
\stopuniqueMPgraphic

%D We define these backgrounds as overlays:


\defineoverlay
  [simpleslides:background:horizontal]
  [\useMPgraphic{simpleslides:MP:horizontal}]

\defineoverlay
  [simpleslides:background:vertical]
  [\useMPgraphic{simpleslides:MP:vertical}]

\defineoverlay
  [simpleslides:background:title]
  [\useMPgraphic{simpleslides:MP:horizontal}]

%D We define the ornament according to user's choice.

\startsetups simpleslides:alternative:square
\defineoverlay
  [simpleslides:background:ornament]
  [\uniqueMPgraphic{simpleslides:MP:ornament:square}]
\stopsetups

\startsetups simpleslides:alternative:stripe
\defineoverlay
  [simpleslides:background:ornament]
  [\uniqueMPgraphic{simpleslides:MP:ornament:stripe}]
\stopsetups

\startsetups simpleslides:alternative:empty
  \setups{simpleslides:alternative:square}
\stopsetups

%D Now we activate the user's choice

\setups{simpleslides:alternative:\moduleparameter{simpleslides}{alternative}}

%D The title is typed in a slightly larger font.

\setupTitle
  [\c!title\c!color={simpleslides:contrastcolor},
   \c!title\c!style=\tfc,
   \c!author\c!color={simpleslides:contrastcolor},
   \c!author\c!style=\tfa,
   \c!date\c!color={simpleslides:contrastcolor},
   \c!date\c!style=\tfa]

%D The slide title is typeset in a layer

\setupSlideTitle
  [\c!color={simpleslides:contrastcolor},
   \c!alternative=layer,
   \c!align=\v!center,
   \c!width=\textwidth,
   \c!height=2.1cm,
   \c!after=]

%D The symbol for the first level of itemizations.

\definesymbol[1][\useMPgraphic{simpleslides:itemize:square}]
\setupitemize[1][color={simpleslides:itemize:color}]

\protect
\stopmodule

\endinput
