1 %------------------------------------------------------------------%
2 % Opéra Libre -- titling.ly %
4 % (c) Valentin Villenave, 2008 %
6 %------------------------------------------------------------------%
8 %%depends on: text-functions.ly, decoupage.ly, nomenclature.ly, graphics.ly
10 %%needs to be included directly at the top of the master \book block.
12 %%%%%%%%%%%%%%%%%%%%%%%%%% General titling %%%%%%%%%%%%%%%%%%%%%%%%%%
15 scoreTitleMarkup
= \markup {
17 \on-the-fly
#print-all-headers
{ \bookTitleMarkup \hspace #1 }
20 \fontsize #10 \fromproperty #'header
:acte
22 \fontsize #6 \fromproperty #'header
:piece
24 \fromproperty #'header
:dessin
29 % TODO headers and footers
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Preamble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %% Special block --------------------------------------------------%
39 %% Internal \paper definitions ------------------------------------%
43 left-margin
= #9 % ???
45 line-width
= #(- paper-width
(+ left-margin right-margin
))
46 bookTitleMarkup
= \markup {
48 \override #'(baseline-skip
. 5)
53 \fontsize #5 \sans \fromproperty #'header
:libretto
57 \line { \fontsize #15 \transparent "A" }
61 \fontsize #5 \sans \fromproperty #'header
:composer
65 \line { \fontsize #5 " " }
68 \fontsize #15 \sans \fromproperty #'header
:title
71 \fontsize #2 \sans \fromproperty #'header
:subtitle
76 \fromproperty #'header
:illustration
81 tocTitleMarkup
= \markup \column {
83 \fontsize #2 \underline \smallCaps \TableTitre
88 tocActMarkup
= \markup \large \column {
90 \fill-line
{ \null \bold \fromproperty #'toc
:text
\null }
93 tocItemMarkup
= \markup \large \fill-line
{
94 \fromproperty #'toc
:text
\fromproperty #'toc
:page
96 tocQuoteMarkup
= \markup {
97 \hspace #4 \italic \fromproperty #'toc
:text
100 oddFooterMarkup
= \markup {
103 %% Copyright header field only on first page.
104 \on-the-fly
#first-page
105 \fontsize #2 \sans \rounded-box
\fromproperty #'header
:scoretype
109 \on-the-fly
#first-page
110 \fontsize #1 \sans \fromproperty #'header
:copyright
114 %% Tagline header field only on last page.
115 \on-the-fly
#last-page
\fromproperty #'header
:tagline
119 scoreTitleMarkup
= \markup \null
122 %% The actual pages -----------------------------------------------%
125 \override #'(box-padding
. 1.0)
126 \translate #'(0 . -
190)
134 \override #'(baseline-skip
. 5)
138 \fontsize #3 \OperaLivret
139 \fontsize #3 \OperaPartition
141 \fontsize #10 \bold \OperaTitre
142 \fontsize #2 \OperaSousTitre
144 \fill-line
{ \line {\hspace #2 \Skyline }}
152 \markuplines \table-of-contents
153 \markup \fill-line
{ \Bilboquet }
158 %% Markup commands ------------------------------------------------%
160 %%% Interpret the odd or even page headers, based on header text
161 %%% added using `add-odd-page-header-text' or `add-even-page-header-text'.
163 #(define-markup-command (odd-header layout props) ()
164 (header-markup-aux layout props #t))
166 #(define-markup-command (even-header layout props) ()
167 (header-markup-aux layout props #f))
170 evenHeaderMarkup = \markup \even-header
171 oddHeaderMarkup = \markup \odd-header
178 #(define-public (add-toplevel-markup parser text)
179 (collect-scores-for-book parser (list text)))
181 #(define-public (add-toc-item parser markup-symbol text)
182 (collect-music-for-book parser
183 (add-toc-item! markup-symbol text)))
186 %%% Rehearsal numbers
189 #(define-public rehearsal-number #f)
190 #(define-public increase-rehearsal-major-number #f)
191 #(let ((major-number 0)
193 (set! increase-rehearsal-major-number
195 (set! major-number (1+ major-number))
196 (set! minor-number 0)))
197 (set! rehearsal-number
199 (set! minor-number (1+ minor-number))
200 (format #f "~a-~a" major-number minor-number))))
203 %%% Table of contents
205 #(define-markup-command (paper-prop layout props name default)
207 "Get the value of a \\paper property, or defaults to some value"
208 (let ((val (ly:output-def-lookup layout name)))
209 (interpret-markup layout props (if (markup? val)
214 line-width = #(- paper-width (* 40 mm))
215 %horizontal-shift = 5
218 ragged-last-bottom = ##t
220 between-system-space = 1\cm
221 between-system-padding = #5
224 oddFooterMarkup = \markup \column {
226 %% put copyright only on pagenr. 1
227 \on-the-fly #(lambda (layout props arg)
228 (if (and (= 1 (chain-assoc-get 'page:page-number props -1))
229 (not (chain-assoc-get 'page:last? props #f)))
230 (interpret-markup layout props arg)
232 \fromproperty #'header:longcopyright
235 %% put tagline on last page
236 \on-the-fly #(lambda (layout props arg)
237 (if (chain-assoc-get 'page:last? props #f)
238 (interpret-markup layout props arg)
240 \fill-line { \fromproperty #'header:tagline }
243 evenFooterMarkup = \markup \column {
245 %% put notice on second page
246 \on-the-fly #(lambda (layout props arg)
247 (if (= 2 (chain-assoc-get 'page:page-number props -1))
248 (interpret-markup layout props arg)
250 \fill-line { \fromproperty #'header:notes }
253 %% put tagline on last page
254 \on-the-fly #(lambda (layout props arg)
255 (if (chain-assoc-get 'page:last? props #f)
256 (interpret-markup layout props arg)
258 \fill-line { \fromproperty #'header:tagline }
264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 %%% Table of contents
267 #(define-markup-command (paper-prop layout props name default)
269 "Get the value of a \\paper property, or defaults to some value"
270 (let ((val (ly:output-def-lookup layout name)))
271 (interpret-markup layout props (if (markup? val)
276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277 %%% Markup commands for page headers
279 #(define-public add-odd-page-header-text #f)
280 #(define-public add-even-page-header-text #f)
281 #(define header-markup-aux #f)
282 #(let ((odd-label-header-table (list))
283 (odd-page-header-table (list))
284 (even-label-header-table (list))
285 (even-page-header-table (list)))
286 (set! header-markup-aux
287 (lambda (layout props odd)
288 (define (page-text page-number table)
291 (let* ((elment (car table))
294 (display-1st (caddr elment)))
295 (cond ((and (= page-number p) (not display-1st)) #f)
296 ((>= page-number p) text)
297 (else (page-text page-number (cdr table)))))))
299 `(delay-stencil-evaluation
300 ,(delay (ly:stencil-expr
302 (if (or (and odd (null? odd-page-header-table))
303 (and (not odd) (null? even-page-header-table)))
304 (let ((page-header-table (list)))
305 (for-each (lambda (label-header)
306 (let* ((label (car label-header))
307 (text-disp (cdr label-header))
308 (table (ly:output-def-lookup layout 'label-page-table))
309 (label-page (and (list? table) (assoc label table)))
310 (page-number (and label-page (cdr label-page)))
311 (prev-value (and page-number (assoc page-number page-header-table))))
313 (set! page-header-table (cons (cons page-number text-disp)
315 (set! page-header-table
316 (assoc-set! page-header-table
318 (list (car text-disp) (caddr prev-value)))))))
319 (reverse (if odd odd-label-header-table even-label-header-table)))
321 (set! odd-page-header-table page-header-table)
322 (set! even-page-header-table page-header-table))))
323 (interpret-markup layout props
324 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
325 (text (page-text page-number (if odd odd-page-header-table even-page-header-table)))
326 (text-markup (markup #:italic (or text "")))
327 (page-number-markup (number->string page-number)))
328 (cond ((or (= 1 page-number) (not text)) (markup #:null))
329 (odd (markup #:fill-line (#:null text-markup page-number-markup)))
330 (else (markup #:fill-line (page-number-markup text-markup #:null))))))))))
332 (ly:stencil-extent (interpret-markup layout props "XXX") Y))))
333 (set! add-odd-page-header-text
334 (lambda (parser text display-1st)
335 (let ((label (gensym "header")))
336 (set! odd-label-header-table
337 (cons (list label text display-1st)
338 odd-label-header-table))
339 (collect-music-for-book parser
342 'page-label label)))))
343 (set! add-even-page-header-text
344 (lambda (parser text display-1st)
345 (let ((label (gensym "header")))
346 (set! even-label-header-table
347 (cons (list label text display-1st)
348 even-label-header-table))
349 (collect-music-for-book parser
352 'page-label label))))))
354 #(define-markup-command (odd-header layout props) ()
355 (header-markup-aux layout props #t))
357 #(define-markup-command (even-header layout props) ()
358 (header-markup-aux layout props #f))
361 evenHeaderMarkup = \markup \even-header
362 oddHeaderMarkup = \markup \odd-header