1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\writestatus{loading}{ConTeXt Screen Macros Pages}
17
18\registerctxluafile{scrnpag}{}
19
20\unprotect
21
22\installcorenamespace{interactionscreen}
23
24\installparameterhandler \??interactionscreen {interactionscreen}
25\installsetuphandler \??interactionscreen {interactionscreen}
26
27\newdimen\canvaswidth
28\newdimen\canvasheight
29\newdimen\canvasbackoffset
30\newdimen\canvastopoffset
31\newdimen\canvasmaxwidth
32\newdimen\canvasmaxheight
33\newdimen\canvascropoffset
34\newdimen\canvastrimoffset
35\newdimen\canvasbleedoffset
36\newdimen\canvasartoffset
37
38\newconditional\c_scrn_canvas_tight_page
39
40\def\scrn_canvas_calculate
41 {\begingroup
42 \edef\currentinteractionscreenwidth {\interactionscreenparameter\c!width }
43 \edef\currentinteractionscreenheight{\interactionscreenparameter\c!height}
44 \canvasbackoffset\backspace
45 \canvastopoffset\topspace
46 \donetrue
47 \ifx\currentinteractionscreenwidth\v!max
48 \global\canvaswidth\printpaperwidth
49 \else\ifx\currentinteractionscreenwidth\v!fit
50 \donefalse
51 \global\canvaswidth\dimexpr
52 \leftcombitotal
53 \makeupwidth
54 \rightcombitotal
55 2\dimexpr
56 \interactionscreenparameter\c!backspace
57 \interactionscreenparameter\c!horoffset
58 \relax
59 \relax
60 \else\ifx\currentinteractionscreenwidth\v!tight
61 \donefalse
62 \ifdim\backspace>\canvaswidth
63 \ifdim\backspace>\zeropoint\relax
64 \global\advance\canvasbackoffset \canvaswidth
65 \fi
66 \fi
67 \global\advance\canvaswidth\dimexpr
68 \makeupwidth
69 \rightcombitotal
70 2\dimexpr
71 \interactionscreenparameter\c!backspace
72 \interactionscreenparameter\c!horoffset
73 \relax
74 \relax
75 \else
76 \donefalse
77 \global\canvaswidth\currentinteractionscreenwidth
78 \fi\fi\fi
79 \ifx\currentinteractionscreenheight\v!max
80 \global\canvasheight\printpaperheight
81 \else\ifx\currentinteractionscreenheight\v!fit
82 \donefalse
83 \global\canvasheight\dimexpr
84 \topheight
85 \topdistance
86 \makeupheight
87 \bottomdistance
88 \bottomheight
89 2\dimexpr
90 \interactionscreenparameter\c!topspace
91 \interactionscreenparameter\c!veroffset
92 \relax
93 \relax
94 \else\ifx\currentinteractionscreenheight\v!tight
95 \donefalse
96 \global\canvasheight\dimexpr\topheight\topdistance\relax
97 \ifdim\topspace>\canvasheight
98 \ifdim\topspace>\zeropoint\relax
99 \global\advance\canvastopoffset \canvasheight
100 \fi
101 \fi
102 \global\advance\canvasheight\dimexpr
103 \makeupheight
104 \bottomdistance
105 \bottomheight
106 2\dimexpr
107 \interactionscreenparameter\c!topspace
108 \interactionscreenparameter\c!veroffset
109 \relax
110 \relax
111 \else
112 \donefalse
113 \global\canvasheight\currentinteractionscreenheight
114 \fi\fi\fi
115 \ifconditional\c_page_layouts_location_is_set
116 \global\setfalse\c_scrn_canvas_tight_page
117 \fi
118 \ifconditional\c_scrn_canvas_tight_page
119 \global\canvasmaxwidth \paperwidth
120 \global\canvasmaxheight\paperheight
121 \else
122 \global\canvasmaxwidth \printpaperwidth
123 \global\canvasmaxheight\printpaperheight
124 \fi
125
126 \ifdone
127 \global\canvascropoffset \layoutcropoffset
128 \global\canvastrimoffset \layouttrimoffset
129 \global\canvasbleedoffset\layoutbleedoffset
130 \global\canvasartoffset \layoutartoffset
131 \else
132 \global\canvascropoffset \zeropoint
133 \global\canvastrimoffset \zeropoint
134 \global\canvasbleedoffset\zeropoint
135 \global\canvasartoffset \zeropoint
136 \fi
137 \endgroup}
138
139\newdimen\layoutcropoffset
140\newdimen\layouttrimoffset
141\newdimen\layoutbleedoffset
142\newdimen\layoutartoffset
143
144\appendtoks
145 \edef\p_cropoffset{\layoutparameter\c!cropoffset}
146 \ifx\p_cropoffset\v!auto
147 \ifconditional\c_page_layouts_location_is_middle
148 \scratchheight\dimexpr(\printpaperheight\paperheight)2\relax
149 \scratchwidth \dimexpr(\printpaperwidth \paperwidth )2\relax
150 \layoutcropoffset\ifdim\scratchheight>\scratchwidth\scratchheight\else\scratchwidth\fi
151 \layouttrimoffset \layoutparameter\c!trimoffset
152 \layoutbleedoffset\layoutparameter\c!bleedoffset
153 \layoutartoffset \layoutparameter\c!artoffset
154 \else
155 \writestatus\m!system{auto crop etc only supported when location=middle}
156 \layoutcropoffset \zeropoint
157 \layouttrimoffset \zeropoint
158 \layoutbleedoffset\zeropoint
159 \layoutartoffset \zeropoint
160 \fi
161 \else
162 \layoutcropoffset \layoutparameter\c!cropoffset
163 \layouttrimoffset \layoutparameter\c!trimoffset
164 \layoutbleedoffset\layoutparameter\c!bleedoffset
165 \layoutartoffset \layoutparameter\c!artoffset
166 \fi
167 \relax
168\to \everysetuplayout
169
170\setuplayout
171 [\c!cropoffset=\zeropoint,
172 \c!trimoffset=\zeropoint,
173 \c!bleedoffset=\zeropoint,
174 \c!artoffset=\zeropoint]
175
176
177
178
179
180
181
182
183
184
185
186
187\let\scrn_canvas_synchronize_simple \relax
188\let\scrn_canvas_synchronize_complex\relax
189
190\appendtoks
191 \glet\scrn_canvas_synchronize_simple \scrn_canvas_synchronize_simple_indeed
192 \glet\scrn_canvas_synchronize_complex\scrn_canvas_synchronize_complex_indeed
193\to \everysetuplayout
194
195\appendtoks
196 \glet\scrn_canvas_synchronize_simple \scrn_canvas_synchronize_simple_indeed
197 \glet\scrn_canvas_synchronize_complex\scrn_canvas_synchronize_complex_indeed
198\to \everysetuplayouttarget
199
200\def\scrn_canvas_synchronize_only
201 {\clf_setupcanvas
202 paperwidth \printpaperwidth
203 paperheight \printpaperheight
204 \relax}
205
206\def\scrn_canvas_synchronize_set#1#2
207 {\clf_setupcanvas
208 paperwidth \dimexpr#1\relax
209 paperheight \dimexpr#2\relax
210 \relax}
211
212\let\scrn_canvas_synchronize_reset\scrn_canvas_synchronize_only
213
214\def\scrn_canvas_synchronize_simple_indeed
215 {\scrn_canvas_synchronize_only
216
217 \glet\scrn_canvas_synchronize_complex\relax}
218
219\def\scrn_canvas_synchronize_complex_indeed
220 {\scrn_canvas_calculate
221 \clf_setupcanvas
222 mode {\interactionscreenparameter\c!option}
223 singlesided \ifsinglesided true\else false\fi\space
224 doublesided \ifdoublesided true\else false\fi\space
225 leftoffset \canvasbackoffset
226 topoffset \canvastopoffset
227 width \canvaswidth
228 height \canvasheight
229 paperwidth \canvasmaxwidth
230 paperheight \canvasmaxheight
231 cropoffset \canvascropoffset
232 trimoffset \canvastrimoffset
233 bleedoffset \canvasbleedoffset
234 artoffset \canvasartoffset
235 copies \numexpr\interactionscreenparameter\c!copies\relax
236 print {\interactionscreenparameter\c!print}
237 \relax
238
239 \glet\scrn_canvas_synchronize_complex\relax}
240
241\appendtoks
242 \begingroup
243 \edef\p_option{\interactionscreenparameter\c!option}
244 \ifx\p_option\v!max
245 \global\settrue \c_scrn_canvas_tight_page
246 \else\ifx\p_option\v!fit
247 \global\settrue \c_scrn_canvas_tight_page
248 \else
249 \global\setfalse\c_scrn_canvas_tight_page
250 \fi\fi
251 \endgroup
252\to \everysetupinteractionscreen
253
254\setupinteractionscreen
255 [\c!width=\printpaperwidth,
256 \c!height=\printpaperheight,
257 \c!horoffset=\zeropoint,
258 \c!veroffset=\zeropoint,
259 \c!backspace=\backspace,
260 \c!topspace=\topspace,
261 \c!copies=\plusone,
262 \c!option=\v!auto]
263
264\appendtoks
265 \glet\scrn_canvas_synchronize_simple \scrn_canvas_synchronize_simple_indeed
266 \glet\scrn_canvas_synchronize_complex\scrn_canvas_synchronize_complex_indeed
267\to \everysetupinteractionscreen
268
269
270
271\unexpanded\def\screen
272 {\dosingleempty\scrn_screen}
273
274\def\scrn_screen[#list]
275 {\iflocation
276 \page[#list]
277 \fi}
278
279
280
281\let\scrn_transitions_list\empty
282
283\unexpanded\def\setuppagetransitions
284 {\dosingleempty\scrn_transitions_setup}
285
286\def\scrn_transitions_setup[#list]
287 {\edef\scrn_transitions_list{#list}
288 \ifx\scrn_transitions_list\v!reset
289 \let\scrn_transitions_list\empty
290 \fi}
291
292\def\scrn_transitions_set
293 {\iflocation \ifx\scrn_transitions_list\empty \else
294 \scrn_transitions_set_indeed
295 \fi \fi}
296
297\def\scrn_transitions_set_indeed
298 {\begingroup
299 \edef\currentinteractionscreendelay{\interactionscreenparameter\c!delay}
300 \clf_setpagetransition
301 n {\scrn_transitions_list}
302 delay \ifx\currentinteractionscreendelay\v!none \zerocount\else\currentinteractionscreendelay\fi
303 \relax
304 \endgroup}
305
306\prependtoks
307 \scrn_transitions_set
308\to \everyshipout
309
310\setupinteractionscreen
311 [\c!delay=\v!none]
312
313\setuppagetransitions
314 [\v!reset]
315
316\protect \endinput
317 |