OLD | NEW |
1 ;;;; This file is part of LilyPond, the GNU music typesetter. | 1 ;;;; This file is part of LilyPond, the GNU music typesetter. |
2 ;;;; | 2 ;;;; |
3 ;;;; Copyright (C) 2004--2012 Jan Nieuwenhuizen <janneke@gnu.org> | 3 ;;;; Copyright (C) 2004--2012 Jan Nieuwenhuizen <janneke@gnu.org> |
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 ;;;; | 5 ;;;; |
6 ;;;; LilyPond is free software: you can redistribute it and/or modify | 6 ;;;; LilyPond is free software: you can redistribute it and/or modify |
7 ;;;; it under the terms of the GNU General Public License as published by | 7 ;;;; it under the terms of the GNU General Public License as published by |
8 ;;;; the Free Software Foundation, either version 3 of the License, or | 8 ;;;; the Free Software Foundation, either version 3 of the License, or |
9 ;;;; (at your option) any later version. | 9 ;;;; (at your option) any later version. |
10 ;;;; | 10 ;;;; |
11 ;;;; LilyPond is distributed in the hope that it will be useful, | 11 ;;;; LilyPond is distributed in the hope that it will be useful, |
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 ;;;; GNU General Public License for more details. | 14 ;;;; GNU General Public License for more details. |
15 ;;;; | 15 ;;;; |
16 ;;;; You should have received a copy of the GNU General Public License | 16 ;;;; You should have received a copy of the GNU General Public License |
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 (define-public (layout-extract-page-properties layout) | 19 (define-public (layout-extract-page-properties layout) |
20 (list (append `((line-width . ,(ly:paper-get-number | 20 (list (append `((line-width . ,(ly:paper-get-number |
21 » » » » layout 'line-width))) | 21 layout 'line-width))) |
22 » » (ly:output-def-lookup layout 'text-font-defaults)))) | 22 (ly:output-def-lookup layout 'text-font-defaults)))) |
23 | 23 |
24 ;;;;;;;;;;;;;;;;;; | 24 ;;;;;;;;;;;;;;;;;; |
25 | 25 |
26 (define-public ((marked-up-headfoot what-odd what-even) | 26 (define-public ((marked-up-headfoot what-odd what-even) |
27 layout scopes page-number is-last-bookpart is-bookpart-last-page
) | 27 layout scopes page-number is-last-bookpart is-bookpart-last-page
) |
28 "Read variables @var{what-odd}, @var{what-even} from @var{layout}, | 28 "Read variables @var{what-odd}, @var{what-even} from @var{layout}, |
29 and interpret them as markup. The @var{props} argument will include | 29 and interpret them as markup. The @var{props} argument will include |
30 variables set in @var{scopes} and @code{page:is-bookpart-last-page}, | 30 variables set in @var{scopes} and @code{page:is-bookpart-last-page}, |
31 @code{page:is-last-bookpart}, @code{page:page-number-string}, and | 31 @code{page:is-last-bookpart}, @code{page:page-number-string}, and |
32 @code{page:page-number}." | 32 @code{page:page-number}." |
33 | 33 |
34 (define (get sym) | 34 (define (get sym) |
35 (ly:output-def-lookup layout sym)) | 35 (ly:output-def-lookup layout sym)) |
36 | 36 |
37 (define (interpret-in-page-env potential-markup) | 37 (define (interpret-in-page-env potential-markup) |
38 (if (markup? potential-markup) | 38 (if (markup? potential-markup) |
39 » (let* ((alists (map ly:module->alist scopes)) | 39 (let* ((alists (map ly:module->alist scopes)) |
40 » (prefixed-alists | 40 (prefixed-alists |
41 » » (map (lambda (alist) | 41 (map (lambda (alist) |
42 » » (map (lambda (entry) | 42 (map (lambda (entry) |
43 » » » (cons | 43 (cons |
44 » » » (string->symbol | 44 (string->symbol |
45 » » » » (string-append | 45 (string-append |
46 » » » » "header:" | 46 "header:" |
47 » » » » (symbol->string (car entry)))) | 47 (symbol->string (car entry)))) |
48 » » » (cdr entry))) | 48 (cdr entry))) |
49 » » » alist)) | 49 alist)) |
50 » » alists)) | 50 alists)) |
51 » (pgnum-alist | 51 (pgnum-alist |
52 » » (list | 52 (list |
53 » » (cons 'header:tagline | 53 (cons 'header:tagline |
54 » » (ly:modules-lookup scopes 'tagline | 54 (ly:modules-lookup scopes 'tagline |
55 » » » » » (ly:output-def-lookup layout 'tagline)
)) | 55 (ly:output-def-lookup layout 'tagline)
)) |
56 » » (cons 'page:is-last-bookpart is-last-bookpart) | 56 (cons 'page:is-last-bookpart is-last-bookpart) |
57 » » (cons 'page:is-bookpart-last-page is-bookpart-last-page) | 57 (cons 'page:is-bookpart-last-page is-bookpart-last-page) |
58 » » (cons 'page:page-number-string | 58 (cons 'page:page-number-string |
59 » » (number->string page-number)) | 59 (number->string page-number)) |
60 » » (cons 'page:page-number page-number))) | 60 (cons 'page:page-number page-number))) |
61 » (props (append | 61 (props (append |
62 » » (list pgnum-alist) | 62 (list pgnum-alist) |
63 » » prefixed-alists | 63 prefixed-alists |
64 » » (layout-extract-page-properties layout)))) | 64 (layout-extract-page-properties layout)))) |
65 » (interpret-markup layout props potential-markup)) | 65 (interpret-markup layout props potential-markup)) |
66 | 66 |
67 » empty-stencil)) | 67 empty-stencil)) |
68 | 68 |
69 (interpret-in-page-env | 69 (interpret-in-page-env |
70 (if (and (even? page-number) | 70 (if (and (even? page-number) |
71 » (markup? (get what-even))) | 71 (markup? (get what-even))) |
72 (get what-even) | 72 (get what-even) |
73 (get what-odd)))) | 73 (get what-odd)))) |
74 | 74 |
75 (define-public ((marked-up-title what) layout scopes) | 75 (define-public ((marked-up-title what) layout scopes) |
76 "Read variables @var{what} from @var{scopes}, and interpret it as markup. | 76 "Read variables @var{what} from @var{scopes}, and interpret it as markup. |
77 The @var{props} argument will include variables set in @var{scopes} (prefixed | 77 The @var{props} argument will include variables set in @var{scopes} (prefixed |
78 with `header:'." | 78 with `header:'." |
79 | 79 |
80 (define (get sym) | 80 (define (get sym) |
81 (let ((x (ly:modules-lookup scopes sym))) | 81 (let ((x (ly:modules-lookup scopes sym))) |
82 (if (markup? x) x #f))) | 82 (if (markup? x) x #f))) |
83 | 83 |
84 (let* ((alists (map ly:module->alist scopes)) | 84 (let* ((alists (map ly:module->alist scopes)) |
85 » (prefixed-alist | 85 (prefixed-alist |
86 » (map (lambda (alist) | 86 (map (lambda (alist) |
87 » » (map (lambda (entry) | 87 (map (lambda (entry) |
88 » » » (cons | 88 (cons |
89 » » » (string->symbol | 89 (string->symbol |
90 » » » (string-append | 90 (string-append |
91 » » » "header:" | 91 "header:" |
92 » » » (symbol->string (car entry)))) | 92 (symbol->string (car entry)))) |
93 » » » (cdr entry))) | 93 (cdr entry))) |
94 » » alist)) | 94 alist)) |
95 » alists)) | 95 alists)) |
96 » (props (append prefixed-alist | 96 (props (append prefixed-alist |
97 » » » (layout-extract-page-properties layout))) | 97 (layout-extract-page-properties layout))) |
98 | 98 |
99 » (markup (ly:output-def-lookup layout what))) | 99 (markup (ly:output-def-lookup layout what))) |
100 | 100 |
101 (if (markup? markup) | 101 (if (markup? markup) |
102 » (interpret-markup layout props markup) | 102 (interpret-markup layout props markup) |
103 » (ly:make-stencil '() '(1 . -1) '(1 . -1))))) | 103 (ly:make-stencil '() '(1 . -1) '(1 . -1))))) |
OLD | NEW |