summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-present-organic.mkiv
blob: 657b786f229c56238466fa217dc4cb2475d3097e (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
%D \module
%D   [      file=s-present-organic, % s-pre-19,
%D        version=2000.07.31,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment Organic,
%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-organic]

%D This style is made in the process or writing the \METAFUN\ manual. It exploits a
%D few tricks, like graphics calculated using positional information. It also uses
%D the (at that moment) new menu list placement alternative. If you forget about the
%D definition of the button shapes, which is complicated in any system, this style
%D is not even that hard to follow. Watch how the left side of the buttons follow
%D the right side of the text graphic.
%D
%D While playing bit with this style, the random alternative made me think of those
%D organic building with non equal windows (we have a few in The Netherlands), so I
%D decided to label this style as \type {pre-organic}.
%D
%D At the end of this file, there is a small test file, so when you process this
%D file with \TEXEXEC\ and the options \type {--mode=demo} and \type {--pdf}, you
%D will get a demo document.
%D
%D We use one of the standard screen \quote {paper} sizes, and map it onto the same
%D size, so that we get a nicely cropped page.

\setuppapersize
  [S6][S6]

%D Like in the \METAFUN\ manual, we use the Palatino as main bodyfont. This font is
%D quite readable on even low resolution screens, although I admit that this style
%D is developed using an $1400\times1050$ pixel LCD screen, so I may be biased.

\setupbodyfont[pagella]

%D The layout specification sets up a text area and a right edge area where the
%D menus will go. Watch the rather large edge distance. By setting the header and
%D footer dimensions to zero, we automatically get rid of page body ornaments, like
%D the pagenumber.

\setuplayout
  [topspace=48pt,
   backspace=48pt,
   cutspace=12pt,
   width=400pt,
   margin=0cm,
   rightedge=88pt,
   rightedgedistance=48pt,
   header=0cm,
   footer=0cm,
   height=middle]

%D We use a moderate, about a line height, interparagraph white space.

\setupwhitespace
  [big]

%D Of course we use colors, since on computer displays they come for free.

\definecolor [red]              [r=.75]
\definecolor [yellow]           [r=.75,g=.75]
\definecolor [gray]             [s=.50]
\definecolor [white]            [s=.85]

\definecolor [PageColor]        [yellow]
\definecolor [TextColor]        [white]
\definecolor [OrnamentColor]    [red]
\definecolor [InteractionColor] [red]
\definecolor [ContrastColor]    [gray]

%D This is an interactive document, so we enable interaction. In this style, we
%D disable the viewer's \quote {highlight a hyperlink when it's clicked on} feature.
%D We will use a menu, so we enable menus. Later we will see the contract color
%D |<|hyperlinks gets that color when we are already on the location|>| in action.

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

%D The menu itself is set up as follows. Because we will calculate menubuttons based
%D on their position on the page, we have to keep track of the positions. Therefore,
%D we set the \type {position} variable to \type {yes}.

\setupinteractionmenu
  [right]
  [frame=off,
   position=yes,
   align=middle,
   topoffset=.75cm,    % watch out, these are negative in mkii
   bottomoffset=.75cm, % watch out, these are negative in mkii
   color=gray,
   contrastcolor=gray,
   style=bold,
   before=,
   after=]

%D The menu content is rather sober: a list of topics (later we will define the
%D command that generates topic entries), and a close button.

\startinteractionmenu[right]
    \placelist[Topic][alternative=right]
    \vfill
    \but [CloseDocument] close \\
\stopinteractionmenu

%D We have now arived at the more interesting part of the style definition: the
%D graphic that goes in the page background. Because this graphic will change, we
%D define a usable \METAPOST\ graphic. Page backgrounds are recalculated each page,
%D opposite to the other backgrounds that are calculated when a new background is
%D defined, or when repetitive calculation is turned on.

\setupbackgrounds
  [page]
  [background=page]

\defineoverlay
  [page]
  [\useMPgraphic{page}]

\setupMPvariables
  [page]
  [alternative=3]

\startuseMPgraphic{page}

    \includeMPgraphic{rightsuperbutton}

    StartPage ;

        path p, q ; pickup pencircle scaled 3pt ;

        p := Field[Text][Text] enlarged 36pt superellipsed .90 ;

        fill Page withcolor \MPcolor{PageColor} ;
        fill p    withcolor \MPcolor{TextColor} ;
        draw p    withcolor \MPcolor{OrnamentColor} ;

        p := Field[Text][Text] enlarged 48pt superellipsed .90 ;

        def right_menu_button (expr nn, rr, pp, xx, yy, ww, hh, dd) =
            if (pp>0) and (rr>0) :
                q := rightsuperbutton(p,xx,yy,RightEdgeWidth,hh) ;
                fill q withcolor \MPcolor{TextColor} ;
                draw q withcolor if rr=2 : \MPcolor{ContrastColor}
                                    else : \MPcolor{InteractionColor} fi ;
            fi ;
        enddef ;

        \MPmenubuttons{right}

    StopPage ;
\stopuseMPgraphic

\startuseMPgraphic{page}

    \includeMPgraphic{rightsuperbutton}

    StartPage ;

        numeric alternative, seed, superness, squeezeness, randomness ;
        path p, q ; transform t ;

        alternative := \MPvar{alternative} ;
        seed        := uniformdeviate 100 ;

        if alternative > 10 :
            superness   := .85  + ((\realfolio-1)/max(\lastpage,1)) * .15 ;
            squeezeness := 12pt - ((\realfolio-1)/max(\lastpage,1)) * 10pt ;
        else :
            superness   := .90 ;
            squeezeness := 12pt ;
        fi ;

        randomness := squeezeness ;

        alternative := alternative mod 10 ;

        t := identity if alternative=3: shifted (9pt,-9pt) fi ;

        % first we draw the shape that surrounds the text

        randomseed := seed ;

        p := Field[Text][Text] enlarged if
            alternative = 1 : 36pt superellipsed superness   elseif
            alternative = 2 : 36pt squeezed      squeezeness elseif
            alternative = 3 : 36pt randomized    randomness  else
                            : 36pt                           fi ;

        pickup pencircle scaled 3pt ;

        fill Page withcolor \MPcolor{PageColor} ;
        fill p    withcolor \MPcolor{TextColor} ;
        draw p    withcolor \MPcolor{OrnamentColor} ;

        % we set p to the wider shape from which we will chip off pieces

        randomseed := seed ;

        p := ( Field[Text][Text] enlarged if
            alternative = 1 : 48pt superellipsed superness   elseif
            alternative = 2 : 48pt squeezed      squeezeness elseif
            alternative = 3 : 36pt randomized    randomness  else
                            : 48pt                           fi ) transformed t ;

        % calls to *_menu_button are generated automatically ...

        vardef right_menu_button (expr nn, rr, pp, xx, yy, ww, hh, dd) =
            save q ; path q ;
            if (pp>0) and (rr>0) :
                q := rightsuperbutton(p,xx,yy,RightEdgeWidth,hh) ; % \MPw{menu:right:\realfolio}
                fill q withcolor \MPcolor{TextColor} ;
                draw q withcolor if rr=2 : \MPcolor{ContrastColor}
                                    else : \MPcolor{InteractionColor} fi ;
            fi ;
        enddef ;

        % ... and inserted when the graphic data is flushed here ...

        \MPmenubuttons{right}

  StopPage ;
\stopuseMPgraphic

\startuseMPgraphic{rightsuperbutton}

    vardef rightsuperbutton (expr pat, xpos, ypos, wid, hei) =

        save p, ptop, pbot, t, b, edge, shift, width, height ;
        path p, ptop, pbot ; pair t, b ; numeric edge, shift, width, height ;

        edge  := xpos + wid ; shift := ypos + hei ;

        p := rightpath pat ;

        ptop := ((-infinity,shift)--(edge,shift)) ;
        pbot := ((-infinity,shift-hei)--(edge,shift-hei)) ;

        t := p intersection_point ptop ;
        b := p intersection_point pbot ;

        p := subpath(0,xpart (p intersectiontimes ptop)) of p ;
        p := subpath(xpart (p intersectiontimes pbot),length(p)) of p ;

        (p --               t -- point 1 of ptop &
              point 1 of ptop -- point 1 of pbot &
              point 1 of pbot -- b
           -- cycle)

    enddef ;

\stopuseMPgraphic

%D Topics are identified with \type {\Topic}, which is an instance of chapter
%D headings. The number is made invisible. Since it still is a numbered section
%D header, \CONTEXT\ will write the header to the table of contents.

\definehead
  [Topic]
  [chapter]

\setuphead
  [Topic]
  [number=no]

%D We will use a bold font in the table of contents. We also force a complete
%D list.

\setuplist
  [Topic]
  [criterium=all,
   style=bold,
   before=,
   after=]

%D The \type {\TitlePage} macro looks horrible, because we want to keep the
%D interface simple: a list of small sentences, separated by \type {\\}.

\unexpanded\def\StartTitlePage
  {\startstandardmakeup
     \switchtobodyfont[big]
     \def\\{\vfill\bfb\let\\=\par}
     \bfd\setupinterlinespace\gray
     \vskip.5cm\relax}

\unexpanded\def\StopTitlePage
  {\\ % the \\ is really needed
   \vskip.5cm\relax
   \stopstandardmakeup}

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

%D A couple of goodies:

\unexpanded\def\Subject   {\Topic}
\unexpanded\def\Topics  #1{}
\unexpanded\def\Subjects  {}

\startsetups document:start
    \StartTitlePage
        \documentvariable{title}
        \doifsomething {\documentvariable{subtitle}} {
            \\
            \documentvariable{subtitle}
        }
        \doifsomething {\documentvariable{location}} {
            \\
            \documentvariable{location}
        }
    \StopTitlePage
\stopsetups

\startsetups document:stop
    %
\stopsetups

\stopmodule

\continueifinputfile{s-present-organic.mkiv}

\usemodule[present-common]

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