summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-present-dark.mkiv
blob: a3b6f6e14af76250812926276cd32484b150c1b7 (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
351
352
353
354
355
356
357
%D \module
%D   [      file=s-present-dark, % tug-2001
%D        version=2018.09.25, % 2000.*.*
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment Dark,
%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-dark]

%D The original document dates from 2000 and was meant for a presentation at \TUG\
%D 2001. It used widgets and in particular check fields and push buttons.
%D \JAVASCRIPT\ was used to show or hide them when rolling over, and appearances
%D changed in a subtle way. It actually worked quite well at that time.
%D
%D However, over time these widgets proved to be sort of unstable. For instance we
%D used the parent|-|child model of which (inheritance and appearance) behaviour
%D changed over time. We're talking of a few decades ago when \TEX\ was one of the
%D few (maybe only) tools that could actually support everything that the manual
%D introduced: the \quote {standard} seemed to be ahead of the viewer. Anyway, we
%D adapted but it meant that old document in principle were not always future proof.
%D
%D We used in this document a push button in the background of the menu so that it
%D could become visible when rolled over. There were no layers in \PDF\ at that
%D time! Nowadays such a trick doesn't work well because of the way a viewer
%D intercepts regions. One gets kind of erratic behaviour when applying \JAVASCRIPT.
%D
%D I spent quite some time to test if we could still do the same without side
%D effects and in the process also noticed that some functionality in \JAVASCRIPT\
%D seems broken (or changed due to maybe security issues). So, in the end I decided
%D to simplify the approach and use layers to pop up the menu when the mouse goes
%D over it but no longer hide it when the mouse leaves that area. It just doesn't
%D work too well otherwise.

%D We start with the layout. We basically have three areas: edge, margin and text.
%D Each are more or less the same width.

\setuppapersize
  [S6][S6]

\setuplayout
  [backspace=380pt,
   topspace=20pt,
   leftedge=100pt,
   leftedgedistance=10pt,
   leftmargin=230pt,
   leftmargindistance=20pt,
   header=0pt,
   footer=0pt,
   width=200pt,
   backspace=360pt,
   width=220pt,
   leftmargin=210pt,
   height=middle]

%D The bodyfont is the Latin Modern Variable (of course at that time we used
%D the Computer Modern predecessors). We still apply protrusion and expansion.
%D The new \quotation {Modern Latin} look also works ok on screen.

\definefontfeature
  [default]
  [default]
  [expansion=pure,
   protrusion=pure]

\setupalign
  [verytolerant,stretch,hanging] % space

\setupbodyfont
  [modernvariable,11pt]

% \setupbodyfont
%   [modernlatin,11pt]

\setupinmargin
  [style=,
   color=]

%D We use some predefined \JAVASCRIPT\ functions. These are rather old helpers.
%D Normally only the libraries (sets of functions) that are used will be
%D embedded.

\useJSscripts[fld]
\useJSscripts[nav]

%D The remarks that will pop up. By default they are not visible. Clicking
%D on the page (or menu item) will show them step by step.

\newcounter\bofremarks
\newcounter\nofremarks

\setupfield
  [remark]
  [offset=overlay,
   option={readonly,hidden},
   color=,
   style=,
   frame=off]

\defineframed
  [remarkable]
  [frame=off,
   backgroundcolor=white,
   background=RollBackground]

\starttexdefinition unexpanded remark #1#2

    \doglobal\increment\nofremarks

    \definesymbol
        [remark:x:\nofremarks]
        [\remarkable{#1}]

    \definesymbol
        [remark:y:\nofremarks]
        [\remarkable{#2}]

    \definefield
        [remark:x:\nofremarks][check][remark]
        [remark:x:\nofremarks]
        [remark:x:\nofremarks]

    \definefield
        [remark:y:\nofremarks][check][remark]
        [remark:y:\nofremarks]
        [remark:y:\nofremarks]

    \inleft
        [scope=local]
        {
            \hpack to \hsize {
                \hss
                \linebox {
                    \fitfield[remark:y:\nofremarks]
                }
            }
        }

    \bgroup

    \setbox\scratchbox\hbox {
        #1
    }

    \hpack to \wd\scratchbox {
        \wd\scratchbox\zeropoint
        \box\scratchbox
        \hss
        \linebox {
            \fitfield[remark:x:\nofremarks]
        }
        \hss
    }

    \egroup

\stoptexdefinition

%D We use lots of backgrounds. The \METAPOST\ graphics are a bit overkill
%D but we keep them.

\setupbackgrounds
  [text]
  [background=StepFields]

\defineoverlay
  [StepFields]
  [\directsetup{syncrefs}\overlaybutton{ShowRemark}]

\setupbackgrounds
  [page]
  [background=PageBackground]

%D Just look in \type {java-imp-fld.mkiv} how \type {HideFields} and
%D alike are defined. They are defined references to \JAVASCRIPT\ calls.

\setupinteraction
  [state=start,
   click=no,
   menu=on,
   style=,
   color=,
   frame=off,
   contrastcolor=]

\setupinteractionscreen
  [option=max]

\setupbackgrounds
  [paper]
  [background=color,
   backgroundcolor=black]

\defineoverlay
  [PageBackground]
  [\useMPgraphic{PageBackground}]

\startuseMPgraphic{PageBackground}
    StartPage ;
        numeric w ; w := 1.25 * PaperWidth ;
        numeric n ; n := 2.50 * PageNumber ;
        numeric d ; d := (1 + (PageNumber-1)/5) * 5pt ;
        fill Page
            withcolor black ;
        for i=1 upto 500 :
            draw
                center Page
                    randomized w
                    rotatedaround(center Page,n)
                withpen pencircle
                    scaled (uniformdeviate d)
                withcolor
                    (yellow randomized (.3,.8))
            ;
        endfor ;
    StopPage ;
\stopuseMPgraphic

\defineoverlay
  [TextBackground]
  [\uniqueMPgraphic{TextBackground}]

\startuniqueMPgraphic{TextBackground}
    fill
        OverlayBox
        withcolor black ;
    draw
        OverlayBox
        withpen pencircle scaled 1pt
        withcolor OverlayColor ;
\stopuniqueMPgraphic

\defineoverlay
  [RollBackground]
  [\uniqueMPgraphic{RollBackground}]

\startuniqueMPgraphic{RollBackground}
    fill
        OverlayBox
        withcolor black ;
    draw
        OverlayBox
        withpen pencircle scaled 1pt
        withcolor OverlayColor ;
\stopuniqueMPgraphic

\setupinteractionmenu
  [left]
  [state=start,
   width=\leftedgewidth,
   frame=on,
   framecolor=white,
   rulethickness=1pt,
   foregroundcolor=white,
   background=RollBackground]

\startsetups syncrefs
    \normalexpanded {
        \definereference
           [ShowRemark]
           [StepFields{remark:x,\bofremarks,\nofremarks},
            StepFields{remark:y,\bofremarks,\nofremarks}]
    }
\stopsetups

%D The menu buttons used to be rollover buttons but are now normal simple
%D ones (more predictable).

\defineviewerlayer
  [buttons]

\startinteractionmenu[left]
    \vfill
    \directsetup{syncrefs}
    \startviewerlayer[buttons]
        \startbut [previouspage,HideFields]  Previous \stopbut
        \startbut [nextpage,HideFields]      Next     \stopbut
        \startbut [ShowRemark]               Remark   \stopbut
        \startbut [HideFields]               Reset    \stopbut
        \startbut [CloseDocument,HideFields] Quit     \stopbut
    \stopviewerlayer
\stopinteractionmenu

\setupinteraction
  [closeaction=ForgetChanges,
   openpageaction={HideFields,HideLayer{buttons}},
   closepageaction={HideFields,HideLayer{buttons}}]

\defineoverlay
  [ShowMenu]
  [\overlayrollbutton{VideLayer{buttons}}{}]

\setupbackgrounds
  [text][leftedge]
  [backgroundoffset=10pt,
   background=ShowMenu]

%D The environment has been adapted a bit. Instead of taking two
%D arguments we now use a key|-|value approach. The remark is shown
%D when one rolls over the title (author).

\defineframedtext
  [MainText]
  [frame=off,
   offset=10pt,
   width=\textwidth,
   before=,
   after=,
   color=,
   foregroundcolor=white,
   background=TextBackground,
   backgroundcolor=white]

\starttexdefinition unexpanded StartIdea
    \dosingleempty{\texdefinition{StartIdeaIndeed}}
\stoptexdefinition

\starttexdefinition StartIdeaIndeed [#1]
    \let\bofremarks\nofremarks
    \increment\bofremarks
    \startstandardmakeup
    \setvariables[Idea][#1]
    \startMainText
    \setupalign[verytolerant,stretch,hanging]
\stoptexdefinition

\starttexdefinition unexpanded StopIdea
    \doifvariable {Idea} {text} {
        \blank
        \rightaligned {
            \doifelsevariable {Idea} {remark} {
                \tooltip
                    [left]
                    {\getvariable{Idea}{title}}
                    {\getvariable{Idea}{remark}}
            } {
                \getvariable{Idea}{title}
            }
        }
    }
    \stopMainText
    \vfill
    \stopstandardmakeup
\stoptexdefinition

\stopmodule

\continueifinputfile{s-present-dark.mkiv}

\usemodule[present-common]

\inputpresentationfile{tug/2001/tug-2001-ideas.tex}