s-present-windows.mkiv /size: 10 Kb    last modification: 2021-10-28 13:51
1%D \module
2%D   [      file=s-resent-windows, % was s-pre-09
3%D        version=unknown,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Presentation Environment Windows,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\startmodule[present-windows]
15
16%D I made this style when I had to give a presentation on the \MAPS\ bibliography
17%D production for several user group meetings. This style is rather tuned for
18%D combinations of examples and explanations. The colors match the \MAPS\
19%D bibliography colors.
20
21\doifelsemode {asintended} {
22    \setupbodyfont[ludicaot,14.4pt]
23} {
24    \setupbodyfont[pagella,14.4pt]
25}
26
27%D A couple of years later, in 2001 this style was documented and made public. While
28%D documenting, I also changed box building on top of overlays into the now
29%D available layer positioning. So, this styles demonstrates quite some tricks.
30%D
31%D I'm sure that nowadays it can be done with less code but therei sno real need to
32%D rewrite history.
33
34\setuppapersize
35  [S6][S6]
36
37\setuplayout
38  [topspace=0cm,
39   backspace=0cm,
40   header=0pt,
41   footer=0pt,
42   width=middle,
43   height=middle]
44
45%D Local environments can be set by using the setups commands. For downward
46%D compatibility, we keep supporting the \type {\...Settings} hooks. Using local
47%D environments is seldom needed.
48
49\let\TextSettings  \empty
50\let\SampleSettings\empty
51
52\startsetups [text]   \TextSettings   \stopsetups
53\startsetups [sample] \SampleSettings \stopsetups
54
55%D The dimensions are kind of fixed.
56
57\def\FrameWidth  {448pt}
58\def\FrameHeight {348pt}
59\def\FrameOffset {24pt}
60\def\FrameSkip   {12pt}
61
62%D But they {\em can} and {\em will} be changed.
63
64\def\FrameWidth  {408pt}
65\def\FrameHeight {318pt}
66
67%D The funny values come from the $3:4$ display aspect ratio.
68
69\definecolor[PageColor]       [s=.40]
70\definecolor[TextColor]       [s=.90]
71\definecolor[InteractionColor][r=.40]
72\definecolor[LineColor]       [r=.60,g=.60]
73
74%D Of course we go interactive and since we will probably open other documents, we
75%D make sure that the viewer opens a new window.
76
77\setupinteraction
78  [color=InteractionColor,
79   contrastcolor=LineColor,
80   display=new,
81   state=start]
82
83\setupinteractionscreen
84  [option=max]
85
86%D Before we come to the real macros, we do a little bit of tuning.
87
88\setupitemize
89  [1][packed]
90
91\setuptyping
92  [blank=medium]
93
94%D Apart from the titlepage, the page gets a simple colored background. Later we
95%D will activate the background.
96
97\setupbackgrounds
98  [page]
99  [backgroundcolor=PageColor]
100
101%D Everything gets frames by a nice \METAPOST\ frame.
102
103\defineoverlay [background] [\uniqueMPgraphic{background}]
104
105\startuniqueMPgraphic{background}
106    pickup pencircle scaled (1.5*\FrameSkip) ;
107    draw OverlayBox withcolor "PageColor" ;
108    pickup pencircle scaled \FrameSkip ;
109    fill OverlayBox withcolor "TextColor" ;
110    draw OverlayBox withcolor "LineColor" ;
111\stopuniqueMPgraphic
112
113%D We will present samples and explanation pair||wise, so we need a hyperlink that
114%D skips a page. Contrary to \MKII\ we put the next button in the page background and
115%D the two windows get buttons that toggle between them. This is easier.
116
117\defineoverlay [nextpage]     [\overlaybutton{nextpage}]
118\defineoverlay [previouspage] [\overlaybutton{previouspage}]
119\defineoverlay [skippage]     [\overlaybutton{realpage(\number\numexpr\realpageno+2\relax)}]
120\defineoverlay [samepage]     [\overlaybutton{realpage(\number\numexpr\realpageno  \relax)}]
121
122%D Layers are normally used to position multiple content on a specific overlay. Here
123%D we will use them to position only and since the samples and text will swap place,
124%D we will use quite a few layers.
125
126\defineoverlay [text]   [\composedlayer{text}]
127\defineoverlay [sample] [\composedlayer{sample}]
128\defineoverlay [common] [\composedlayer{common}]
129
130%D There are three positions. When combined, the sample and text windows overlap,
131%D otherwise the lone window is centered. We could have used one layer and reversed
132%D the order by setting the \type {direction} parameter, but this approach is more
133%D readable.
134
135\definelayer
136  [text]
137  [x=\makeupwidth,
138   y=\makeupheight,
139   location=lt,
140   hoffset=-\FrameSkip,
141   voffset=-\FrameSkip]
142
143\definelayer
144  [sample]
145  [hoffset=\FrameSkip,
146   voffset=\FrameSkip]
147
148\definelayer
149  [common]
150  [x=.5\makeupwidth,
151   y=.5\makeupheight,
152   location=c]
153
154%D The topic is put in the lower right corner of the text window.
155
156\defineoverlay [topic] [\composedlayer{topic}]
157
158\definelayer
159  [topic]
160  [x=\FrameWidth,
161   y=\FrameHeight,
162   location=lt,
163   hoffset=-\FrameOffset,
164   voffset=-\FrameSkip]
165
166%D The topic is put in a framed box. That way we can make sure that it gets a
167%D background, which looks better when it covers something else. Otherwise we could
168%D have stuck to:
169%D
170%D \starttyping
171%D \def\Topic#1%
172%D   {\setlayer[topic]{\color[PageColor]{\bfb\setstrut#1}}}
173%D \stoptyping
174%D
175%D But, we go for the nice alternative:
176
177\unexpanded\def\Topic#1%
178  {\doifsomething{#1}
179     {\setlayer [topic]
180        {\bfb\setstrut
181         \inframed
182           [frame=off,
183            foregroundcolor=PageColor,
184            offset=0pt,
185            background=color,
186            backgroundcolor=TextColor]
187           {#1}}}}
188
189%D The sample as well as the explanation will be collected in a buffer. That way we
190%D can reuse the content. We could have used a box instead, but can we be sure that
191%D the content is not adapting itself? So, buffers we use.
192
193\resetbuffer[sample]
194\resetbuffer[text]
195
196%D Both the sample and explanation are kind of windowed.
197
198\defineframedtext
199  [SampleText]
200  [width=\FrameWidth,
201   height=\FrameHeight,
202   offset=\FrameOffset,
203   frame=off,
204   align=normal,
205   strut=no,
206   before=,
207   after=,
208   background=background]
209
210%D We safe some keying in by combining things in one macro.
211
212\unexpanded\def\DoSampleText#1#2#3% kind layer overlays
213  {\setupframedtexts[SampleText][background={background,#3}]
214   \setlayer[#2]
215     {\startSampleText[none]
216        \setups[#1]
217        \getbuffer[#1]
218      \stopSampleText}}
219
220\unexpanded\def\StartSample{\dostartbuffer[sample][StartSample][StopSample]}
221\unexpanded\def\StartText  {\dostartbuffer[text]  [StartText]  [StopText]}
222
223%D The following definitions apply at the outer level.
224
225\unexpanded\def\StopSample
226  {\startstandardmakeup
227     \DoSampleText{sample}{common}{samepage}
228   \stopstandardmakeup
229   \resetbuffer[sample]}
230
231\unexpanded\def\StopText
232  {\startstandardmakeup
233     \DoSampleText{text}{common}{topic,samepage}
234   \stopstandardmakeup
235   \resetbuffer[text]}
236
237\setupbackgrounds[page][background={color,nextpage}]
238\setupbackgrounds[text][background=common]
239
240%D When we combine sample and text, we get slightly different definitions. As you
241%D can see we generate two pages. Watch how we manipulate the order of the overlays
242%D and teh nature of the buttons. Here some abstraction really pays off.
243
244\unexpanded\def\StartIdea
245  {\bgroup
246   \let\StopSample\relax
247   \let\StopText  \relax}
248
249\unexpanded\def\StopIdea
250  {\setupbackgrounds[page][background={color,skippage}]
251   \setupbackgrounds[text][background={text,sample}]
252   \startstandardmakeup
253     \DoSampleText{sample}{sample}{nextpage}
254     \DoSampleText{text}  {text}  {topic,nextpage}
255   \stopstandardmakeup
256   \setupbackgrounds[page][background={color,nextpage}]
257   \setupbackgrounds[text][background={sample,text}]
258   \startstandardmakeup
259     \DoSampleText{sample}{sample}{previouspage}
260     \DoSampleText{text}  {text}  {topic,previouspage}
261   \stopstandardmakeup
262   \egroup}
263
264%D The rest of the definitions takes care of the title page. Please don't steal this
265%D one for your own documents.
266
267\defineoverlay[joke] [\useMPgraphic{joke}{n=0}] % not to be changed!
268
269\startuseMPgraphic{joke}{n}
270    StartPage ;
271        path p, q ; numeric w ; pair xy ;
272        set_grid(OverlayWidth,OverlayHeight,OverlayWidth/8,OverlayHeight/8) ;
273        if \MPvar{n}=1 :
274            p := fulldiamond ; fill Page withcolor \MPcolor{TextColor} ;
275        else :
276            p := fullsquare  ; fill Page withcolor \MPcolor{PageColor} ;
277        fi ;
278        forever :
279            xy := center Page randomized (OverlayWidth,OverlayHeight) ;
280            if new_on_grid(xpart xy, ypart xy) :
281                q := (p xyscaled (OverlayWidth/5,OverlayHeight/5))
282                    randomized (\FrameSkip,\FrameSkip)
283                    shifted xy ;
284                w := (\FrameSkip) randomized (\FrameSkip/2) ;
285                draw q withcolor \MPcolor{PageColor} withpen pencircle scaled (1.5w) ;
286                fill q withcolor \MPcolor{TextColor} ;
287                draw q withcolor \MPcolor{LineColor} withpen pencircle scaled (   w) ;
288            fi ;
289            exitif grid_full ;
290        endfor ;
291    StopPage ;
292\stopuseMPgraphic
293
294\defineoverlay[fuzzy][\useMPgraphic{fuzzy}]
295
296\startuseMPgraphic{fuzzy}
297    path p ; numeric w ;
298    p := (fullsquare xyscaled (OverlayWidth,OverlayHeight))
299            randomized (\FrameSkip,\FrameSkip) ;
300    w := (\FrameSkip) randomized (\FrameSkip/2) ;
301    draw p withcolor \MPcolor{PageColor} withpen pencircle scaled (1.5w) ;
302    fill p withcolor \MPcolor{TextColor} ;
303    draw p withcolor \MPcolor{LineColor} withpen pencircle scaled (   w) ;
304\stopuseMPgraphic
305
306%D This time we use a fit window, but with a slightly randomized frame, our
307%D trademark so to say.
308
309\unexpanded\def\StartTitlePage
310  {\bgroup
311   \setupbackgrounds[page][background={joke,nextpage}]
312   \startstandardmakeup
313   \switchtobodyfont[big]
314   \setupframedtexts
315     [SampleText]
316     [background=fuzzy,
317      foregroundcolor=PageColor,
318      width=fit,
319      height=fit,
320      align=middle]
321   \startSampleText[middle]
322   \bfd\setupinterlinespace
323   \enforced\protected\def\\{\bfb\setupinterlinespace\vfil\enforced\protected\def\\{\vfil}}}
324
325\unexpanded\def\StopTitlePage
326  {\stopSampleText
327   \stopstandardmakeup
328   \egroup}
329
330\unexpanded\def\TitlePage#1%
331  {\StartTitlePage#1\StopTitlePage}
332
333%D Let's nil some error prone presentation macros.
334
335\let\Subject  \Topic
336\let\Topics   \gobbleoneargument
337\let\Subjects \relax
338
339%D We will avoid \quote {overfull} messages.
340
341\dontcomplain
342
343\stopmodule
344
345\continueifinputfile{s-present-windows.mkiv}
346
347\usemodule[present-common]
348
349\inputpresentationfile{examples/present-windows-001.tex}
350
351