Debian Codegraph @

texmf-dist/tex/generic/tikz-ext/tikzlibraryext.beamer.code.tex

raw
1 % Copyright 2024 by Qrrbrbirlbel
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Free Documentation License.
7 %
8
9 \unless\ifcsname tikzextset\endcsname
10 \input tikzext-util.tex
11 \fi
12
13 \unless\ifcsname ifmemoizing\endcsname
14 \expandafter\newif\csname ifmemoizing\endcsname
15 \fi
16
17 \let\tikzext@maxbb@list\pgfutil@gobble
18 \def\tikzext@maxbb@write{%
19 \unless\ifx\tikzext@maxbb@list\pgfutil@gobble
20 \pgfutil@for\tikzext@temp:=\tikzext@maxbb@list\do{%
21 % if next is not existing (because of memoize)
22 % we just write the prev again
23 \immediate\write\pgfutil@auxout{%
24 \noexpand\expandafter\gdef\noexpand\csname tikzext@maxbb@\tikzext@temp @prev\endcsname{%
25 \csname tikzext@maxbb@\tikzext@temp @%
26 \ifcsname tikzext@maxbb@\tikzext@temp @next\endcsname next\else prev\fi
27 \endcsname
28 }%
29 }%
30 }%
31 \fi
32 }
33 \def\tikzext@maxbb@addtolist#1{%
34 \edef\pgf@marshal{\noexpand\pgfutil@in@{,#1,}{,\tikzext@maxbb@list,}}%
35 \pgf@marshal
36 \unless\ifpgfutil@in@
37 \xdef\tikzext@maxbb@list{\tikzext@maxbb@list,#1}%
38 \fi
39 }
40 \def\tikzext@maxbb@if#1#2#3{%
41 \ifcsname tikzext@maxbb@#1\endcsname#2\else#3\fi
42 }
43 \tikzextset{
44 ignore line width/.value forbidden,
45 ignore line width/.style={
46 /pgf/local bounding box=tikzext@ilw,
47 /tikz/execute at end scope/.expanded={%
48 \global\pgf@picminx=\the\pgf@picminx\relax
49 \global\pgf@picmaxx=\the\pgf@picmaxx\relax
50 \global\pgf@picminy=\the\pgf@picminy\relax
51 \global\pgf@picmaxy=\the\pgf@picmaxy\relax
52 },
53 /tikz/execute at end scope={%
54 \pgf@protocolsizes\pgf@lbb@minx@tikzext@ilw\pgf@lbb@miny@tikzext@ilw
55 \pgf@protocolsizes\pgf@lbb@maxx@tikzext@ilw\pgf@lbb@maxy@tikzext@ilw
56 }%
57 },
58 max bounding box/.value required,
59 max bounding box/.code={%
60 \tikzext@maxbb@if{#1@prev}{% not the first run
61 \pgfkeys@expanded{\noexpand\tikzext@maxbb@setbb\csname tikzext@maxbb@#1@prev\endcsname}%
62 }{% first run
63 \ifmemoizing
64 \mmzAbort
65 \fi
66 }%
67 \tikzext@maxbb@if{#1@next}{% not the first picture
68 \pgfkeys@expanded{\noexpand\tikzext@maxbb@setbb\csname tikzext@maxbb@#1@next\endcsname}%
69 }{% first picture
70 \tikzext@maxbb@addtolist{#1}%
71 }%
72 \ifmemoizing
73 \mmzset{context=\csname tikzext@maxbb@#1@prev\endcsname}%
74 \gtoksapp\mmzCCMemo{%
75 \csname tikzext@maxbb@addtolist\endcsname{#1}%
76 }%
77 \fi
78 \tikzset{
79 execute at end picture={%
80 \tikzext@maxbb@setnext{#1}%
81 \tikzext@maxbb@if{#1@prev}{% not the first run
82 % if memoizing, check whether picture is bigger/different then prev
83 \ifmemoizing
84 \expandafter\ifx\csname tikzext@maxbb@#1@next\expandafter\endcsname\csname tikzext@maxbb@#1@prev\endcsname
85 % it's the same
86 \else
87 % it is not the same
88 \mmzAbort
89 \fi
90 \fi
91 }{% first run
92 }%
93 }%
94 }%
95 }
96 }
97 \def\tikzext@maxbb@setbb#1#2#3#4{%
98 \ifdim#1pt<\pgf@picminx\global\pgf@picminx#1pt\fi
99 \ifdim#3pt>\pgf@picmaxx\global\pgf@picmaxx#3pt\fi
100 \ifdim#2pt<\pgf@picminy\global\pgf@picminy#2pt\fi
101 \ifdim#4pt>\pgf@picmaxy\global\pgf@picmaxy#4pt\fi}
102 \def\tikzext@maxbb@setnext#1{%
103 \expandafter\xdef\csname tikzext@maxbb@#1@next\endcsname
104 {{\pgf@sys@tonumber\pgf@picminx}{\pgf@sys@tonumber\pgf@picminy}%
105 {\pgf@sys@tonumber\pgf@picmaxx}{\pgf@sys@tonumber\pgf@picmaxy}}%
106 }%
107
108 \ifcsname @ifclassloaded\endcsname % latex?
109 \AtEndDocument{\tikzext@maxbb@write}%
110 \@ifclassloaded{beamer}{% beamer?
111 }{%
112 \expandafter\endinput
113 }%
114 \else
115 \pgfutil@everybye\expandafter{\the\pgfutil@everybye\tikzext@maxbb@write}%
116 \expandafter\endinput
117 \fi
118
119 \newcounter{tikzextbb}
120 \resetcounteronoverlays{tikzextbb}
121 \tikzextset{
122 sync bounding box/.value forbidden,
123 sync bounding box/.code={%
124 \stepcounter{tikzextbb}%
125 \tikzextset{max bounding box={beamer-\the\value{tikzextbb}}}%
126 }
127 }
128
129 \long\def\tikzext@beamerfunction@alt #1#2{\alt <#1>{\tikz@@command@path#2;}{\tikz@path@do@at@end}}
130 \long\def\tikzext@beamerfunction@uncover #1#2{\uncover <#1>{\tikz@@command@path#2;}\tikz@path@do@at@end}
131 \long\def\tikzext@beamerfunction@visible #1#2{\visible <#1>{\tikz@@command@path#2;}\tikz@path@do@at@end}
132 \long\def\tikzext@beamerfunction@invisible#1#2{\invisible<#1>{\tikz@@command@path#2;}\tikz@path@do@at@end}
133 \let\tikzext@beamerfunction\tikzext@beamerfunction@alt
134
135 % Overwriting original dispatchers
136 \long\def\tikz@eargnormalsemicolon<#1>#2;{\tikzext@beamerfunction{#1}{#2}}%
137 \begingroup
138 \catcode`\;=\active
139 \long\global\def\tikz@eargactivesemicolon<#1>#2;{\tikzext@beamerfunction{#1}{#2}}%
140 \endgroup
141
142 \let\tikzext@beameroption\relax
143 \def\tikzext@setbeameroption#1{%
144 \tikz@addoption{\tikzext@beameroption}%
145 \def\tikzext@beameroption{%
146 #1%
147 \let\tikzext@beameroption\relax
148 }%
149 }
150 \tikzextset{
151 /utils/ext/only/.code 2 args={\only<#1>{\pgfkeysalso{#2}}},
152 /utils/ext/alt/.code args={#1#2#3}{\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}},
153 /utils/ext/temporal/.code n args={4}{\temporal<#1>{\pgfkeysalso{#2}{\pgfkeysalso{#3}{\pgfkeysalso{#4}}}}},
154 beamer function/.is choice,
155 beamer function/original/.code =\let\tikzext@beamerfunction\tikzext@beamerfunction@alt,
156 beamer function/alt/.code =\let\tikzext@beamerfunction\tikzext@beamerfunction@alt,
157 beamer function/only/.code =\let\tikzext@beamerfunction\tikzext@beamerfunction@alt,
158 beamer function/uncover/.code =\let\tikzext@beamerfunction\tikzext@beamerfunction@uncover,
159 beamer function/visible/.code =\let\tikzext@beamerfunction\tikzext@beamerfunction@visible,
160 beamer function/invisible/.code=\let\tikzext@beamerfunction\tikzext@beamerfunction@invisible,
161 uncover/.default=all,
162 uncover/.code={%
163 \tikzext@setbeameroption{%
164 \beamer@noargsonslide<#1>%
165 \aftergroup\beamer@noargsonslide
166 }%
167 },
168 cover/.default=all,
169 cover/.code=%
170 \tikzext@setbeameroption{%
171 \beamer@endpause
172 \beamer@alt<#1>{\beamer@startcovered\gdef\beamer@endpause{\beamer@endcovered}}%
173 {\beamer@spacingcover\gdef\beamer@endpause{\beamer@spacingcover}}%
174 \aftergroup\beamer@noargsonslide
175 },
176 aobs visible/.style={/utils/ext/alt={#1}{}{/tikz/opacity=0,/tikz/text opacity=0}},
177 aobs invisible/.style={/utils/ext/only={#1}{/tikz/opacity=0,/tikz/text opacity=0}},
178 visible/.default=all,
179 visible/.code=%
180 \tikzext@setbeameroption{%
181 \beamer@noargsvisibleonslide<#1>%
182 \aftergroup\beamer@noargsonslide
183 },
184 invisible/.default=all,
185 invisible/.code=%
186 \tikzext@setbeameroption{%
187 \beamer@endpause
188 \beamer@alt<#1>{\beamer@begininvisible\gdef\beamer@endpause{\beamer@endinvisible}}%
189 {\beamer@spacingcover\gdef\beamer@endpause{\beamer@spacingcover}}%
190 \aftergroup\beamer@noargsonslide
191 },
192 uncover'/.style={/tikz/ext/cover={#1}},
193 aobs visible'/.style={/tikz/ext/aobs invisible={#1}},
194 visible'/.style={/tikz/ext/invisible={#1}},
195 cover'/.style={/tikz/ext/uncover={#1}},
196 invisible'/.style={/tikz/ext/visible={#1}},
197 aobs invisible'/.style={/tikz/ext/aobs visible={#1}},
198 /handlers/.ext_</.code=\tikzext@beamer@handler#1\pgf@stop,
199 beamer shortcuts/.code=\pgfqkeys{/tikz/ext/beamer shortcuts}{#1},
200 beamer shortcuts/aot/.code={%
201 \pgfkeysdef{/tikz/alt}{\pgfkeysvalueof{/utils/ext/alt/.@cmd}##1\pgfeov}%
202 \pgfkeysdef{/tikz/only}{\pgfkeysvalueof{/utils/ext/only/.@cmd}##1\pgfeov}%
203 \pgfkeysdef{/tikz/temporal}{\pgfkeysvalueof{/utils/ext/temporal/.@cmd}##1\pgfeov}%
204 },
205 beamer shortcuts/first char/.is choice,
206 beamer shortcuts/@enable first char/.code 2 args={%
207 \pgfkeys@syntax@handlerstrue % \pgfkeys{/handlers/first char syntax=true}%
208 \pgfkeyssetvalue{/handlers/first char syntax/\expandafter\meaning\string#1}{#2}%
209 },
210 beamer shortcuts/enable first char </.style={/tikz/ext/beamer shortcuts/@enable first char={<}{\tikzext@beamer@firstchar}},
211 beamer shortcuts/enable first char/.value required,
212 beamer shortcuts/enable first char/.style={/tikz/ext/beamer shortcuts/@enable first char={#1}{\tikzext@beamer@graphfirstchar}},
213 beamer shortcuts/enable handler/.code={\pgfkeysdef{/handlers/.<}{\pgfkeysvalueof{/handlers/.ext_<}##1\pgfeov}},
214 }
215 \def\tikzext@temp#1{%
216 \pgfkeysdef{/tikz/ext/beamer shortcuts/first char/#1}{\pgfkeyssetvalue{/tikz/ext/beamer shortcuts/first char}{#1}}}
217 \tikzext@temp{visible}
218 \tikzext@temp{uncover}
219 \tikzext@temp{cover}
220 \tikzext@temp{aobs visible}
221 \tikzext@temp{aobs invisible}
222 \pgfkeyssetvalue{/tikz/ext/beamer shortcuts/first char}{uncover}
223 % first char syntax: <*overlay*> → uses "first char" = *overlay*
224 % <*overlay*>' → uses "first char"' = *overlay* (i.e. the inverse)
225 % <*overlay*> {options} → uses \only<*overlay*>{\pgfkeysalso{options}}
226 % <*overlay*>' {options} → uses \alt<*overlay*>{}{\pgfkeysalso{options}} (i.e. the inverse)
227 \def\tikzext@beamer@firstchar#1{\tikzext@beamer@firstchar@#1\pgf@stop}
228 \def\tikzext@beamer@firstchar@<#1>{%
229 \pgfutil@ifnextchar\pgf@stop{% just the overlay specifications, forward
230 % \pgfkeysvalueof{/tik}
231 \tikzextset{\pgfkeysvalueof{/tikz/ext/beamer shortcuts/first char}={#1}}%
232 \pgfutil@gobble
233 }{%
234 \pgfutil@ifnextchar={% graphs does silly things
235 \tikzext@beamer@firstchar@graph{#1}%
236 }{%
237 \pgfutil@ifnextchar'{% apo = invert overlay specification
238 \tikzext@beamer@firstchar@apo{#1}%
239 }{%
240 \pgfutil@ifnextchar\bgroup{% first options grouped, maybe there are more?
241 \tikzext@beamer@firstchar@onlyoralt{#1}%
242 }{%
243 \tikzext@beamer@firstchar@only{#1}%
244 }%
245 }%
246 }%
247 }%
248 }
249 \def\tikzext@beamer@firstchar@graph#1=#2\pgf@stop{%
250 \tikzextset{\pgfkeysvalueof{/tikz/ext/beamer shortcuts/first char}={#1}}%
251 }
252 \def\tikzext@beamer@firstchar@only#1#2\pgf@stop{%
253 \beamer@only<#1>{\pgfkeysalso{#2}}%
254 }
255 \def\tikzext@beamer@firstchar@onlyoralt#1#2{%
256 \pgfutil@ifnextchar\pgf@stop{%
257 \beamer@only<#1>{\pgfkeysalso{#2}}%
258 \pgfutil@gobble
259 }{% second options, must be in {}
260 \tikzext@beamer@firstchar@altortemp{#1}{#2}%
261 }%
262 }
263 \def\tikzext@beamer@firstchar@altortemp#1#2#3{%
264 \pgfutil@ifnextchar\pgf@stop{%
265 \beamer@alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}%
266 \pgfutil@gobble
267 }{% oh, there are third options, must be temporal
268 \tikzext@beamer@firstchar@temp{#1}{#2}{#3}%
269 }%
270 }
271 \def\tikzext@beamer@firstchar@temp#1#2#3#4\pgf@stop{%
272 \temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}%
273 }
274
275 \def\tikzext@beamer@firstchar@apo#1'{%
276 \pgfutil@ifnextchar\pgf@stop{% just the overlay specifications, forward (and invert)
277 \tikzextset{\pgfkeysvalueof{/tikz/ext/beamer shortcuts/first char}'={#1}}%
278 \pgfutil@gobble
279 }{%
280 \pgfutil@ifnextchar={% graphs does silly things
281 \tikzext@beamer@firstchar@apo@graph{#1}%
282 }{%
283 \pgfutil@ifnextchar\bgroup{%
284 \tikzext@beamer@firstchar@apo@onlyoralt{#1}%
285 }{%
286 \tikzext@beamer@firstchar@apo@only{#1}%
287 }%
288 }%
289 }%
290 }
291 \def\tikzext@beamer@firstchar@apo@graph#1=#2\pgf@stop{%
292 \tikzextset{\pgfkeysvalueof{/tikz/ext/beamer shortcuts/first char}'={#1}}%
293 }
294 \def\tikzext@beamer@firstchar@apo@only#1#2\pgf@stop{%
295 \beamer@alt<#1>{}{\pgfkeysalso{#2}}%
296 }
297 \def\tikzext@beamer@firstchar@apo@onlyoralt#1#2{%
298 \pgfutil@ifnextchar\pgf@stop{%
299 \beamer@alt<#1>{}{\pgfkeysalso{#2}}%
300 }{% second options, must be in {}
301 \tikzext@beamer@firstchar@apo@altortemp{#1}{#2}%
302 }%
303 }
304 \def\tikzext@beamer@firstchar@apo@altortemp#1#2#3{%
305 \pgfutil@ifnextchar\pgf@stop{%
306 \beamer@alt<#1>{\pgfkeysalso{#3}}{\pgfkeysalso{#2}}%
307 }{% oh, there arethird options, must be temporal
308 \tikzext@beamer@firstchar@apo@temp{#1}{#2}{#3}%
309 }%
310 }
311 \def\tikzext@beamer@firstchar@apo@temp#1#2#3#4\pgf@stop{%
312 \temporal<#1>{\pgfkeysalso{#4}}{\pgfkeysalso{#3}}{\pgfkeysalso{#2}}%
313 }
314 \def\tikzext@beamer@graphfirstchar#1{\expandafter\tikzext@beamer@firstchar@\pgfutil@gobble#1\pgf@stop}
315
316 % handler .ext_< = *overlay*> → uses the key w/o options on *overlay*
317 % .ext_< = *overlay*>' → uses the key w/o options unless on *overlay*
318 % .ext_< = *overlay*> {options} → uses the key /w options on *overlay*
319 % .ext_< = *overlay*>' {options} → uses the key /w options unless on *overlay*
320 \def\tikzext@beamer@handler#1>{%
321 \pgfutil@ifnextchar\pgf@stop
322 {\beamer@only<#1>{\pgfkeysalso{\pgfkeyscurrentpath}}}%
323 {%
324 \pgfutil@ifnextchar'%
325 {\tikzext@beamer@handler@apo{#1}}%
326 {\tikzext@beamer@handler@{#1}}%
327 }%
328 }
329 \def\tikzext@beamer@handler@#1#2\pgf@stop{%
330 \beamer@only<#1>{\pgfkeysalso{\pgfkeyscurrentpath={#2}}}%
331 }
332 \def\tikzext@beamer@handler@apo#1'{%
333 \pgfutil@ifnextchar\pgf@stop{%
334 \beamer@alt<#1>{}{\pgfkeysalso{\pgfkeyscurrentpath}}%
335 \pgfutil@gobble
336 }{%
337 \tikzext@beamer@handler@apo@opts{#1}%
338 }%
339 }
340 \def\tikzext@beamer@handler@apo@opts#1#2\pgf@stop{%
341 \beamer@alt<#1>{}{\pgfkeysalso{\pgfkeyscurrentpath={#2}}}%
342 }
343
344 % ext/ keys need special handling in graphs library
345 \def\tikzext@beamer@graphs@firstchar#1{%
346 \pgfutil@in@{>}{#1}%
347 \ifpgfutil@in@
348 \tikzext@beamer@firstchar{#1}%
349 \else
350 \tikz@lg@parse@less{#1}%
351 \fi
352 }
353 \pgfkeysdef{/tikz/ext/beamer shortcuts/enable first char < graphs}{%
354 \pgfkeysvalueof{/tikz/ext/beamer shortcuts/@enable first char/.@cmd}{<}{\tikzext@beamer@graphs@firstchar}\pgfeov
355 }
356 \pgfkeysdef{/tikz/graphs/ext/uncover}{%
357 \pgfkeysaddvalue{/tikz/graphs/@edges styling}{}{,/tikz/ext/uncover={#1}}%
358 \pgfkeysvalueof{/tikz/ext/uncover/.@cmd}{#1}\pgfeov}
359 \pgfkeysdef{/tikz/graphs/ext/visible}{%
360 \pgfkeysadd{/tikz/graphs/@edges styling}{}{,/tikz/ext/visible={#1}}%
361 \pgfkeysvalueof{/tikz/ext/visible/.@cmd}{#1}\pgfeov}
362 \pgfkeysdef{/tikz/graphs/ext/cover}{%
363 \pgfkeysaddvalue{/tikz/graphs/@edges styling}{}{,/tikz/ext/cover={#1}}%
364 \pgfkeysvalueof{/tikz/ext/cover/.@cmd}{#1}\pgfeov}
365 \pgfkeysdef{/tikz/graphs/ext/invisible}{%
366 \pgfkeysaddvalue{/tikz/graphs/@edges styling}{}{,/tikz/ext/invisible={#1}}%
367 \pgfkeysvalueof{/tikz/ext/invisible/.@cmd}{#1}\pgfeov}
368 \pgfkeysdef{/tikz/graphs/ext/better beamer shortcut}{%
369 \pgfkeyslet{/handlers/first char syntax/\expandafter\meaning\string<}\relax % disable < shortcut
370 \pgfkeysaddvalue{/tikz/graphs/@edges styling}{}{,/tikz/ext/beamer shortcuts/enable first char <}%
371 \pgfkeys{
372 /tikz/graphs/@nodes styling/.append style={/tikz/ext/beamer shortcuts/enable first char < graphs},
373 /tikz/every label/.append style={/tikz/ext/beamer shortcuts/enable first char <}
374 }%
375 }