Debian Codegraph @

texmf-dist/tex/latex/beamer/beamerbaseboxes.sty

raw
1 % Copyright 2003-2007 by Till Tantau
2 % Copyright 2010 by Vedran Mileti\'c
3 % Copyright 2012,2015 by Vedran Mileti\'c, Joseph Wright
4 % Copyright 2020-2026 by Joseph Wright, samcarter
5 %
6 % This file may be distributed and/or modified
7 %
8 % 1. under the LaTeX Project Public License and/or
9 % 2. under the GNU Public License.
10 %
11 % See the file LICENSE.md for more details.
12
13 \def\beamerboxesdeclarecolorscheme#1#2#3{% scheme name, upper color, lower color
14 \setbeamercolor{@scheme upper #1}{fg=white,bg={#2}}
15 \setbeamercolor{@scheme lower #1}{bg={#3}}
16 }
17
18 \define@key{beamerboxes}{scheme}{\def\bmb@upper{@scheme upper #1}\def\bmb@lower{@scheme lower #1}}
19 \define@key{beamerboxes}{upper}{\def\bmb@upper{#1}}
20 \define@key{beamerboxes}{lower}{\def\bmb@lower{#1}}
21 \define@key{beamerboxes}{width}{\edef\bmb@width{#1}}
22 \define@key{beamerboxes}{shadow}[true]{\csname bmb@shadow#1\endcsname}
23 \define@key{beamerboxes}{bgopacity}{\def\bmb@bgopacity{#1}}
24
25 \newif\ifbmb@shadow
26 \newbox\bmb@box
27 \newbox\bmb@colorbox
28 \newdimen\bmb@boxwidth
29 \newdimen\bmb@boxheight
30 \newdimen\bmb@prevheight
31 \newdimen\bmb@temp
32 \newdimen\bmb@dima
33 \newdimen\bmb@dimb
34 \newdimen\bmb@prevheight
35
36 \newcommand\beamerboxesrounded[2][]{%
37 \global\let\beamer@firstlineitemizeunskip=\relax%
38 \vbox\bgroup%
39 \setkeys{beamerboxes}{upper=block title,lower=block body,width=\textwidth,shadow=false}%
40 \setkeys{beamerboxes}{#1}%
41 {%
42 \usebeamercolor{\bmb@lower}%
43 \globalcolorstrue%
44 \colorlet{lower.bg}{bg}%
45 }%
46 {%
47 \usebeamercolor{\bmb@upper}%
48 \globalcolorstrue%
49 \colorlet{upper.bg}{bg}%
50 }%
51 %
52 % Typeset head
53 %
54 \vskip4bp
55 \setbox\bmb@box=\hbox{%
56 \begin{minipage}[b]{\bmb@width}%
57 \usebeamercolor[fg]{\bmb@upper}%
58 #2%
59 \end{minipage}}%
60 \ifdim\wd\bmb@box=0pt%
61 \setbox\bmb@box=\hbox{}%
62 \ht\bmb@box=1.5pt%
63 \bmb@prevheight=-4.5pt%
64 \else%
65 \wd\bmb@box=\bmb@width%
66 \bmb@temp=\dp\bmb@box%
67 \ifdim\bmb@temp<1.5pt%
68 \bmb@temp=1.5pt%
69 \fi%
70 \setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
71 \dp\bmb@box=0pt%
72 \bmb@prevheight=\ht\bmb@box%
73 \fi%
74 \bmb@temp=\bmb@width%
75 \bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
76 \bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
77 \hbox{%
78 \begin{pgfpicture}{0bp}{+-\ht\bmb@box}{0bp}{+-\ht\bmb@box}
79 \ifdim\wd\bmb@box=0pt%
80 \color{lower.bg}%
81 \else%
82 \color{upper.bg}%
83 \fi%
84 \ifdefined\bmb@bgopacity\pgfsetfillopacity{\bmb@bgopacity}\fi
85 \pgfpathqmoveto{-4bp}{-1bp}
86 \pgfpathqcurveto{-4bp}{1.2bp}{-2.2bp}{3bp}{0bp}{3bp}
87 \pgfpathlineto{\pgfpoint{\bmb@temp}{3bp}}
88 \pgfpathcurveto%
89 {\pgfpoint{\bmb@dima}{3bp}}%
90 {\pgfpoint{\bmb@dimb}{1.2bp}}%
91 {\pgfpoint{\bmb@dimb}{-1bp}}%
92 \bmb@dima=-\ht\bmb@box%
93 \ifdefined\bmb@bgopacity%
94 % Only with explicity specified opacity, make sure that there is no
95 % overlap between top and bottom part of the box
96 \ifdim\wd\bmb@box=0pt%
97 \advance\bmb@dima by .5pt%
98 \else%
99 \advance\bmb@dima by -1.07pt%
100 \fi%
101 \else%
102 \advance\bmb@dima by -2pt%
103 \fi%
104 \pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
105 \pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
106 \pgfusepath{fill}
107 \end{pgfpicture}%
108 \copy\bmb@box%
109 }%
110 \nointerlineskip%
111 \vskip-1pt%
112 \ifdim\wd\bmb@box=0pt%
113 \else%
114 \hbox{%
115 \begin{pgfpicture}{0pt}{0pt}{\bmb@width}{6pt}
116 \bmb@dima=\bmb@width%
117 \advance\bmb@dima by8bp%
118 \pgfpathrectangle{\pgfpoint{-4bp}{-1bp}}{\pgfpoint{\bmb@dima}{8bp}}
119 \pgfusepath{clip}
120 \ifdefined\bmb@bgopacity\pgfsetfillopacity{\bmb@bgopacity}\fi%
121 {\pgftransformshift{\pgfpoint{-4bp}{0bp}}\pgftext[left,base]{\pgfuseshading{bmb@transition}}}%
122 \end{pgfpicture}%
123 }%
124 \nointerlineskip%
125 \vskip-0.5pt%
126 \fi%
127 \setbox\bmb@colorbox=\hbox{{\pgfpicturetrue%
128 \ifdefined\bmb@bgopacity\pgfsetfillopacity{\bmb@bgopacity}\fi%
129 \pgfsetcolor{lower.bg}}}%
130 \setbox\bmb@box=\hbox\bgroup\begin{minipage}[b]{\bmb@width}%
131 \vskip2pt%
132 \usebeamercolor[fg]{\bmb@lower}%
133 \colorlet{beamerstructure}{upper.bg}%
134 \colorlet{structure}{upper.bg}%
135 %\color{.}%
136 }
137
138 \def\endbeamerboxesrounded{%
139 \end{minipage}\egroup%
140 \bmb@temp=\dp\bmb@box%
141 \advance\bmb@temp by.5pt%
142 \setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
143 \dp\bmb@box=0pt%
144 \bmb@boxwidth=\bmb@width%
145 \bmb@boxheight=\ht\bmb@box%
146 \advance\bmb@boxheight by4bp%
147 \advance\bmb@boxheight by\bmb@prevheight%
148 \ifbmb@shadow%
149 \xdef\beamer@storecolorhook{\beamer@colorhook}
150 \xdef\beamer@colorhook{}
151 \pgfdeclareradialshading{bmb@shadowball}{\pgfpointorigin}
152 {%
153 color(0bp)=(pgftransparent!50);
154 color(4bp)=(pgftransparent!100)
155 }%
156 \pgfdeclareradialshading{bmb@shadowballlarge}{\pgfpointorigin}
157 {%
158 color(0bp)=(pgftransparent!0);
159 color(8bp)=(pgftransparent!100)
160 }%
161 \pgfdeclarehorizontalshading{bmb@shadowhorz\the\bmb@boxheight}{\[email protected]}
162 {%
163 color(0bp)=(pgftransparent!0);
164 color(8bp)=(pgftransparent!100)
165 }%
166 \pgfdeclareverticalshading{bmb@shadowvert\the\bmb@boxwidth}{\bmb@boxwidth-4bp}
167 {%
168 color(0bp)=(pgftransparent!100);
169 color(8bp)=(pgftransparent!0)
170 }%
171 \begingroup%
172 \selectcolormodel{gray}
173 \pgfdeclarefading{bmb@shadowmask\the\bmb@boxwidth\the\bmb@boxheight}
174 {%
175 \begin{pgfpicture}
176 \pgftext[at=\pgfpoint{4bp}{4bp}]{\pgfuseshading{bmb@shadowball}}% bottom left shadow
177 \ifdim\bmb@boxheight>9.5bp%
178 \pgftext[at=\pgfpoint{\bmb@boxwidth}{8bp}]{\pgfuseshading{bmb@shadowballlarge}}% bottom right shadow
179 \pgftext[at=\pgfpoint{\bmb@boxwidth+4bp}{\bmb@boxheight+2bp}]{\pgfuseshading{bmb@shadowball}}% top right shadow
180 \pgftext[base, at=\pgfpoint{\bmb@boxwidth+4bp}{7.5bp}]{\pgfuseshading{bmb@shadowhorz\the\bmb@boxheight}}% right edge shadow
181 \else%
182 \pgftext[at=\pgfpoint{\bmb@boxwidth}{4bp}]{\pgfuseshading{bmb@shadowball}}% right shadow
183 \fi%
184 \pgftext[left, at=\pgfpoint{4bp}{4bp}]{\pgfuseshading{bmb@shadowvert\the\bmb@boxwidth}}% bottom edge
185 %
186 % clipping is needed because shadow is typeset on top of box
187 \begin{pgfscope}
188 \pgfsetcolor{beamer@safeblack}
189 \pgfpathrectangle{\pgfpoint{4bp}{8.1bp}}{\pgfpoint{\bmb@boxwidth}{\bmb@boxheight-2bp}}
190 \pgfusepath{fill}
191 \ifdefined\bmb@bgopacity%
192 % More precise clipping if bgopacity is specified
193 \pgfpathqmoveto{-4bp}{8.2bp}
194 \pgfpathqlineto{-4bp}{8bp}
195 \pgfpathqcurveto{-4bp}{5.8bp}{-2.2bp}{4bp}{0bp}{4bp}
196 \pgfpathlineto{\pgfpoint{\bmb@boxwidth}{4bp}}
197 \pgfpathqcurveto{\dimexpr\bmb@boxwidth+2.2bp}{4bp}{\dimexpr\bmb@boxwidth+4bp}{5.8bp}{\dimexpr\bmb@boxwidth+4bp}{8bp}
198 \pgfpathqlineto{\dimexpr\bmb@boxwidth+4bp}{8.2bp}
199 \pgfusepath{fill}
200 \fi%
201 \end{pgfscope}
202 \end{pgfpicture}%
203 \hskip4bp%
204 }%
205 \endgroup%
206 \fi%
207 \bmb@temp=\bmb@width%
208 \bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
209 \bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
210 \hbox{%
211 \begin{pgfpicture}{0bp}{0bp}{0bp}{0bp}
212 \ifbmb@shadow%
213 \begin{pgfscope}
214 \pgfsetfillcolor{beamer@safeblack}%
215 \pgfpathrectangle{\pgfpoint{0bp}{-7bp}}
216 {\pgfpoint{\bmb@boxwidth+8bp}{\bmb@boxheight+6bp}}
217 \pgfsetfading{bmb@shadowmask\the\bmb@boxwidth\the\bmb@boxheight}{%
218 \pgftransformshift{\pgfpoint{0.5\bmb@boxwidth+6bp}{0.5\bmb@boxheight-4bp}}}
219 \pgfusepath{fill}
220 \end{pgfscope}
221 \fi%
222 \unhbox\bmb@colorbox%
223 \pgfpathqmoveto{-4bp}{1bp}
224 \pgfpathqcurveto{-4bp}{-1.2bp}{-2.2bp}{-3bp}{0bp}{-3bp}
225 \pgfpathlineto{\pgfpoint{\the\bmb@temp}{-3bp}}
226 \pgfpathcurveto%
227 {\pgfpoint{\the\bmb@dima}{-3bp}}%
228 {\pgfpoint{\the\bmb@dimb}{-1.2bp}}%
229 {\pgfpoint{\the\bmb@dimb}{1bp}}%
230 {
231 \bmb@dima=\ht\bmb@box%
232 \ifdefined\bmb@bgopacity%
233 % Remove overlap with bgtransparency specified
234 \advance\bmb@dima by-.5pt%
235 \fi%
236 \pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
237 \pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
238 \pgfusepath{fill}
239 }
240 \end{pgfpicture}%
241 \box\bmb@box%
242 }%
243 \ifbmb@shadow%
244 \vskip4bp minus 2bp%
245 \else%
246 \vskip2bp%
247 \fi%
248 \ifbmb@shadow%
249 \xdef\beamer@colorhook{\beamer@storecolorhook}
250 \fi
251 \egroup% of \vbox\bgroup
252 }
253
254 % Shadings
255
256 % Transition line
257 \pgfdeclareverticalshading[lower.bg,upper.bg]{bmb@transition}{200cm}{%
258 color(0pt)=(lower.bg); color(2pt)=(lower.bg); color(4pt)=(upper.bg)}