Merge git://repo.or.cz/opera_libre
[opera_libre.git] / master / titling.ly
blob310553cdce128ea6fdd070640f70d8f28655f091
1 %------------------------------------------------------------------%
2 % Opéra Libre -- titling.ly %
3 % %
4 % (c) Valentin Villenave, 2008 %
5 % %
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 %%%%%%%%%%%%%%%%%%%%%%%%%%
14 \paper {
15 scoreTitleMarkup = \markup {
16 \column {
17 \on-the-fly #print-all-headers { \bookTitleMarkup \hspace #1 }
18 \fill-line {
19 \center-column {
20 \fontsize #10 \fromproperty #'header:acte
21 \vspace #1
22 \fontsize #6 \fromproperty #'header:piece
23 \vspace #1
24 \fromproperty #'header:dessin
29 % TODO headers and footers
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Preamble %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %% Special block --------------------------------------------------%
37 \bookpart {
39 %% Internal \paper definitions ------------------------------------%
41 \paper {
42 indent = #0
43 left-margin = #9 % ???
44 right-margin = #10
45 line-width = #(- paper-width (+ left-margin right-margin))
46 bookTitleMarkup = \markup {
47 \vspace #20
48 \override #'(baseline-skip . 5)
49 \column {
50 \combine
51 \column {
52 \fill-line {
53 \fontsize #5 \sans \fromproperty #'header:libretto
54 \null
56 \vspace #4
57 \line { \fontsize #15 \transparent "A" }
58 \vspace #4
59 \fill-line {
60 \null
61 \fontsize #5 \sans \fromproperty #'header:composer
64 \column {
65 \line { \fontsize #5 " " }
66 \vspace #4
67 \fill-line {
68 \fontsize #15 \sans \fromproperty #'header:title
70 \fill-line {
71 \fontsize #2 \sans \fromproperty #'header:subtitle
74 \vspace #4
75 \fill-line {
76 \fromproperty #'header:illustration
81 tocTitleMarkup = \markup \column {
82 \fill-line {
83 \fontsize #2 \underline \smallCaps \TableTitre
85 \vspace #2
88 tocActMarkup = \markup \large \column {
89 \hspace #1
90 \fill-line { \null \bold \fromproperty #'toc:text \null }
91 \hspace #1
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 {
101 \column {
102 \fill-line {
103 %% Copyright header field only on first page.
104 \on-the-fly #first-page
105 \fontsize #2 \sans \rounded-box\fromproperty #'header:scoretype
107 \vspace #1
108 \fill-line {
109 \on-the-fly #first-page
110 \fontsize #1 \sans \fromproperty #'header:copyright
113 \fill-line {
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 -----------------------------------------------%
123 \pageBreak
124 \markup {
125 \override #'(box-padding . 1.0)
126 \translate #'(0 . -190)
127 \fill-line {
128 \box \BigNotice
131 \pageBreak
132 \markup {
133 \vspace #5
134 \override #'(baseline-skip . 5)
135 \fill-line {
136 \center-column {
137 \fill-line {
138 \fontsize #3 \OperaLivret
139 \fontsize #3 \OperaPartition
141 \fontsize #10 \bold \OperaTitre
142 \fontsize #2 \OperaSousTitre
143 \vspace #10
144 \fill-line { \line {\hspace #2 \Skyline }}
145 \vspace #10
146 \CharacterList
150 \pageBreak
151 \markup \vspace #5
152 \markuplines \table-of-contents
153 \markup \fill-line { \Bilboquet }
154 \pageBreak
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))
169 \paper {
170 evenHeaderMarkup = \markup \even-header
171 oddHeaderMarkup = \markup \odd-header
175 %%% Toplevel markups
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)
192 (minor-number 0))
193 (set! increase-rehearsal-major-number
194 (lambda ()
195 (set! major-number (1+ major-number))
196 (set! minor-number 0)))
197 (set! rehearsal-number
198 (lambda ()
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)
206 (symbol? markup?)
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)
212 \paper {
214 line-width = #(- paper-width (* 40 mm))
215 %horizontal-shift = 5
216 bottom-margin = #20
217 ragged-bottom = ##t
218 ragged-last-bottom = ##t
219 left-margin = #20
220 between-system-space = 1\cm
221 between-system-padding = #5
224 oddFooterMarkup = \markup \column {
225 \fill-line {
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)
231 empty-stencil))
232 \fromproperty #'header:longcopyright
234 \fill-line {
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)
239 empty-stencil))
240 \fill-line { \fromproperty #'header:tagline }
243 evenFooterMarkup = \markup \column {
244 \fill-line {
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)
249 empty-stencil))
250 \fill-line { \fromproperty #'header:notes }
252 \fill-line {
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)
257 empty-stencil))
258 \fill-line { \fromproperty #'header:tagline }
264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 %%% Table of contents
267 #(define-markup-command (paper-prop layout props name default)
268 (symbol? markup?)
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)
273 default))))
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)
289 (if (null? table)
291 (let* ((elment (car table))
292 (p (car elment))
293 (text (cadr elment))
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)))))))
298 (ly:make-stencil
299 `(delay-stencil-evaluation
300 ,(delay (ly:stencil-expr
301 (begin
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))))
312 (if (not prev-value)
313 (set! page-header-table (cons (cons page-number text-disp)
314 page-header-table))
315 (set! page-header-table
316 (assoc-set! page-header-table
317 page-number
318 (list (car text-disp) (caddr prev-value)))))))
319 (reverse (if odd odd-label-header-table even-label-header-table)))
320 (if odd
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))))))))))
331 (cons 0 0)
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
340 (make-music 'Music
341 'page-marker #t
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
350 (make-music 'Music
351 'page-marker #t
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))
360 \paper {
361 evenHeaderMarkup = \markup \even-header
362 oddHeaderMarkup = \markup \odd-header