summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-present-windows.mkiv
blob: 22d6fdba15c9b816eda3bbad6c708e5d2e5c64c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
%D \module
%D   [      file=s-resent-windows, % was s-pre-09
%D        version=unknown,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment Windows,
%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.

\startmodule[present-windows]

%D I made this style when I had to give a presentation on the \MAPS\ bibliography
%D production for several user group meetings. This style is rather tuned for
%D combinations of examples and explanations. The colors match the \MAPS\
%D bibliography colors.

\doifelsemode {asintended} {
    \setupbodyfont[ludicaot,14.4pt]
} {
    \setupbodyfont[pagella,14.4pt]
}

%D A couple of years later, in 2001 this style was documented and made public. While
%D documenting, I also changed box building on top of overlays into the now
%D available layer positioning. So, this styles demonstrates quite some tricks.
%D
%D I'm sure that nowadays it can be done with less code but therei sno real need to
%D rewrite history.

\setuppapersize
  [S6][S6]

\setuplayout
  [topspace=0cm,
   backspace=0cm,
   header=0pt,
   footer=0pt,
   width=middle,
   height=middle]

%D Local environments can be set by using the setups commands. For downward
%D compatibility, we keep supporting the \type {\...Settings} hooks. Using local
%D environments is seldom needed.

\let\TextSettings  \empty
\let\SampleSettings\empty

\startsetups [text]   \TextSettings   \stopsetups
\startsetups [sample] \SampleSettings \stopsetups

%D The dimensions are kind of fixed.

\def\FrameWidth  {448pt}
\def\FrameHeight {348pt}
\def\FrameOffset {24pt}
\def\FrameSkip   {12pt}

%D But they {\em can} and {\em will} be changed.

\def\FrameWidth  {408pt}
\def\FrameHeight {318pt}

%D The funny values come from the $3:4$ display aspect ratio.

\definecolor[PageColor]       [s=.40]
\definecolor[TextColor]       [s=.90]
\definecolor[InteractionColor][r=.40]
\definecolor[LineColor]       [r=.60,g=.60]

%D Of course we go interactive and since we will probably open other documents, we
%D make sure that the viewer opens a new window.

\setupinteraction
  [color=InteractionColor,
   contrastcolor=LineColor,
   display=new,
   state=start]

\setupinteractionscreen
  [option=max]

%D Before we come to the real macros, we do a little bit of tuning.

\setupitemize
  [1][packed]

\setuptyping
  [blank=medium]

%D Apart from the titlepage, the page gets a simple colored background. Later we
%D will activate the background.

\setupbackgrounds
  [page]
  [backgroundcolor=PageColor]

%D Everything gets frames by a nice \METAPOST\ frame.

\defineoverlay [background] [\uniqueMPgraphic{background}]

\startuniqueMPgraphic{background}
    pickup pencircle scaled (1.5*\FrameSkip) ;
    draw OverlayBox withcolor "PageColor" ;
    pickup pencircle scaled \FrameSkip ;
    fill OverlayBox withcolor "TextColor" ;
    draw OverlayBox withcolor "LineColor" ;
\stopuniqueMPgraphic

%D We will present samples and explanation pair||wise, so we need a hyperlink that
%D skips a page. Contrary to \MKII\ we put the next button in the page background and
%D the two windows get buttons that toggle between them. This is easier.

\defineoverlay [nextpage]     [\overlaybutton{nextpage}]
\defineoverlay [previouspage] [\overlaybutton{previouspage}]
\defineoverlay [skippage]     [\overlaybutton{realpage(\number\numexpr\realpageno+2\relax)}]
\defineoverlay [samepage]     [\overlaybutton{realpage(\number\numexpr\realpageno  \relax)}]

%D Layers are normally used to position multiple content on a specific overlay. Here
%D we will use them to position only and since the samples and text will swap place,
%D we will use quite a few layers.

\defineoverlay [text]   [\composedlayer{text}]
\defineoverlay [sample] [\composedlayer{sample}]
\defineoverlay [common] [\composedlayer{common}]

%D There are three positions. When combined, the sample and text windows overlap,
%D otherwise the lone window is centered. We could have used one layer and reversed
%D the order by setting the \type {direction} parameter, but this approach is more
%D readable.

\definelayer
  [text]
  [x=\makeupwidth,
   y=\makeupheight,
   location=lt,
   hoffset=-\FrameSkip,
   voffset=-\FrameSkip]

\definelayer
  [sample]
  [hoffset=\FrameSkip,
   voffset=\FrameSkip]

\definelayer
  [common]
  [x=.5\makeupwidth,
   y=.5\makeupheight,
   location=c]

%D The topic is put in the lower right corner of the text window.

\defineoverlay [topic] [\composedlayer{topic}]

\definelayer
  [topic]
  [x=\FrameWidth,
   y=\FrameHeight,
   location=lt,
   hoffset=-\FrameOffset,
   voffset=-\FrameSkip]

%D The topic is put in a framed box. That way we can make sure that it gets a
%D background, which looks better when it covers something else. Otherwise we could
%D have stuck to:
%D
%D \starttyping
%D \def\Topic#1%
%D   {\setlayer[topic]{\color[PageColor]{\bfb\setstrut#1}}}
%D \stoptyping
%D
%D But, we go for the nice alternative:

\unexpanded\def\Topic#1%
  {\doifsomething{#1}
     {\setlayer [topic]
        {\bfb\setstrut
         \inframed
           [frame=off,
            foregroundcolor=PageColor,
            offset=0pt,
            background=color,
            backgroundcolor=TextColor]
           {#1}}}}

%D The sample as well as the explanation will be collected in a buffer. That way we
%D can reuse the content. We could have used a box instead, but can we be sure that
%D the content is not adapting itself? So, buffers we use.

\resetbuffer[sample]
\resetbuffer[text]

%D Both the sample and explanation are kind of windowed.

\defineframedtext
  [SampleText]
  [width=\FrameWidth,
   height=\FrameHeight,
   offset=\FrameOffset,
   frame=off,
   align=normal,
   strut=no,
   before=,
   after=,
   background=background]

%D We safe some keying in by combining things in one macro.

\unexpanded\def\DoSampleText#1#2#3% kind layer overlays
  {\setupframedtexts[SampleText][background={background,#3}]
   \setlayer[#2]
     {\startSampleText[none]
        \setups[#1]
        \getbuffer[#1]
      \stopSampleText}}

\unexpanded\def\StartSample{\dostartbuffer[sample][StartSample][StopSample]}
\unexpanded\def\StartText  {\dostartbuffer[text]  [StartText]  [StopText]}

%D The following definitions apply at the outer level.

\unexpanded\def\StopSample
  {\startstandardmakeup
     \DoSampleText{sample}{common}{samepage}
   \stopstandardmakeup
   \resetbuffer[sample]}

\unexpanded\def\StopText
  {\startstandardmakeup
     \DoSampleText{text}{common}{topic,samepage}
   \stopstandardmakeup
   \resetbuffer[text]}

\setupbackgrounds[page][background={color,nextpage}]
\setupbackgrounds[text][background=common]

%D When we combine sample and text, we get slightly different definitions. As you
%D can see we generate two pages. Watch how we manipulate the order of the overlays
%D and teh nature of the buttons. Here some abstraction really pays off.

\unexpanded\def\StartIdea
  {\bgroup
   \let\StopSample\relax
   \let\StopText  \relax}

\unexpanded\def\StopIdea
  {\setupbackgrounds[page][background={color,skippage}]
   \setupbackgrounds[text][background={text,sample}]
   \startstandardmakeup
     \DoSampleText{sample}{sample}{nextpage}
     \DoSampleText{text}  {text}  {topic,nextpage}
   \stopstandardmakeup
   \setupbackgrounds[page][background={color,nextpage}]
   \setupbackgrounds[text][background={sample,text}]
   \startstandardmakeup
     \DoSampleText{sample}{sample}{previouspage}
     \DoSampleText{text}  {text}  {topic,previouspage}
   \stopstandardmakeup
   \egroup}

%D The rest of the definitions takes care of the title page. Please don't steal this
%D one for your own documents.

\defineoverlay[joke] [\useMPgraphic{joke}{n=0}] % not to be changed!

\startuseMPgraphic{joke}{n}
    StartPage ;
        path p, q ; numeric w ; pair xy ;
        set_grid(OverlayWidth,OverlayHeight,OverlayWidth/8,OverlayHeight/8) ;
        if \MPvar{n}=1 :
            p := fulldiamond ; fill Page withcolor \MPcolor{TextColor} ;
        else :
            p := fullsquare  ; fill Page withcolor \MPcolor{PageColor} ;
        fi ;
        forever :
            xy := center Page randomized (OverlayWidth,OverlayHeight) ;
            if new_on_grid(xpart xy, ypart xy) :
                q := (p xyscaled (OverlayWidth/5,OverlayHeight/5))
                    randomized (\FrameSkip,\FrameSkip)
                    shifted xy ;
                w := (\FrameSkip) randomized (\FrameSkip/2) ;
                draw q withcolor \MPcolor{PageColor} withpen pencircle scaled (1.5w) ;
                fill q withcolor \MPcolor{TextColor} ;
                draw q withcolor \MPcolor{LineColor} withpen pencircle scaled (   w) ;
            fi ;
            exitif grid_full ;
        endfor ;
    StopPage ;
\stopuseMPgraphic

\defineoverlay[fuzzy][\useMPgraphic{fuzzy}]

\startuseMPgraphic{fuzzy}
    path p ; numeric w ;
    p := (fullsquare xyscaled (OverlayWidth,OverlayHeight))
            randomized (\FrameSkip,\FrameSkip) ;
    w := (\FrameSkip) randomized (\FrameSkip/2) ;
    draw p withcolor \MPcolor{PageColor} withpen pencircle scaled (1.5w) ;
    fill p withcolor \MPcolor{TextColor} ;
    draw p withcolor \MPcolor{LineColor} withpen pencircle scaled (   w) ;
\stopuseMPgraphic

%D This time we use a fit window, but with a slightly randomized frame, our
%D trademark so to say.

\unexpanded\def\StartTitlePage
  {\bgroup
   \setupbackgrounds[page][background={joke,nextpage}]
   \startstandardmakeup
   \switchtobodyfont[big]
   \setupframedtexts
     [SampleText]
     [background=fuzzy,
      foregroundcolor=PageColor,
      width=fit,
      height=fit,
      align=middle]
   \startSampleText[middle]
   \bfd\setupinterlinespace
   \def\\{\bfb\setupinterlinespace\vfil\def\\{\vfil}}}

\unexpanded\def\StopTitlePage
  {\stopSampleText
   \stopstandardmakeup
   \egroup}

\unexpanded\def\TitlePage#1%
  {\StartTitlePage#1\StopTitlePage}

%D Let's nil some error prone presentation macros.

\let\Subject  \Topic
\let\Topics   \gobbleoneargument
\let\Subjects \relax

%D We will avoid \quote {overfull} messages.

\dontcomplain

\stopmodule

\continueifinputfile{s-present-windows.mkiv}

\usemodule[present-common]

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