Update \sacredHarpHeads and \aikenHeads to use new sol head
[lilypond/mpolesky.git] / scm / paper-system.scm
blobaa0f855672736b990af76ad61880ca4a4ae9ff4d
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 2006--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
4 ;;;;
5 ;;;; LilyPond is free software: you can redistribute it and/or modify
6 ;;;; it under the terms of the GNU General Public License as published by
7 ;;;; the Free Software Foundation, either version 3 of the License, or
8 ;;;; (at your option) any later version.
9 ;;;;
10 ;;;; LilyPond is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ;;;; GNU General Public License for more details.
14 ;;;;
15 ;;;; You should have received a copy of the GNU General Public License
16 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 (define-module (scm paper-system))
20 (use-modules (lily))
22 (define-public (paper-system-title? system)
23   (equal? #t (ly:prob-property system 'is-title)
24           ))
26 (define-public (paper-system-stencil system)
27   (ly:prob-property system 'stencil))
29 (define-public (paper-system-layout system)
30   (let*
31       ((g (paper-system-system-grob system)))
33     (if (ly:grob? g)
34         (ly:grob-layout  g)
35         #f)))
37 (define-public (paper-system-system-grob paper-system)
38   (ly:prob-property paper-system 'system-grob))
40 (define-public (paper-system-extent system axis)
41   (ly:stencil-extent (paper-system-stencil system) axis))
43 (define-public (paper-system-staff-extents ps)
44   (ly:prob-property ps 'staff-refpoint-extent '(0 . 0)))
46 (define-public (paper-system-annotate-last system layout)
47   (let*
48       ((bottomspace (ly:prob-property system 'bottom-space))
49        (y-extent (paper-system-extent system Y))
50        (x-extent (paper-system-extent system X))
51        (stencil (ly:prob-property system 'stencil))
52      
53        (arrow (if (number? bottomspace)
54                (annotate-y-interval layout
55                                     "bottom-space"
56                                     (cons (- (car y-extent) bottomspace)
57                                           (car y-extent))
58                                     #t)
59                #f)))
60     
61     (if arrow
62         (set! stencil
63               (ly:stencil-add stencil arrow)))
65     (set! (ly:prob-property system 'stencil)
66           stencil)
67   ))
69 ; TODO: annotate the spacing for every spaceable staff within the system.
70 (define-public (paper-system-annotate system next-system layout)
71   "Add arrows and texts to indicate which lengths are set."
72   (let* ((annotations (list))
73          (grob (ly:prob-property system 'system-grob))
74          (estimate-extent (if (ly:grob? grob)
75                               (annotate-y-interval layout
76                                                    "extent-estimate"
77                                                    (ly:grob-property grob 'pure-Y-extent)
78                                                    #f)
79                               #f)))
80     (let* ((spacing-spec (cond ((and next-system
81                                      (paper-system-title? system)
82                                      (paper-system-title? next-system))
83                                 (ly:output-def-lookup layout 'between-title-spacing))
84                                ((paper-system-title? system)
85                                 (ly:output-def-lookup layout 'after-title-spacing))
86                                ((and next-system
87                                      (paper-system-title? next-system))
88                                 (ly:output-def-lookup layout 'before-title-spacing))
89                                (else
90                                 (ly:output-def-lookup layout 'between-system-spacing))))
91            (last-staff-Y (car (paper-system-staff-extents system))))
93       (set! annotations
94             (annotate-spacing-spec layout spacing-spec last-staff-Y (car (paper-system-extent system Y)))))
95     (if estimate-extent
96         (set! annotations
97               (stack-stencils X RIGHT 0.5
98                               (list annotations
99                                     estimate-extent))))
100                                 
101     (if (not (null? annotations))
102         (set! (ly:prob-property system 'stencil)
103               (ly:stencil-add
104                (ly:prob-property system 'stencil)
105                (ly:make-stencil
106                 (ly:stencil-expr annotations)
107                 (ly:stencil-extent empty-stencil X)
108                 (ly:stencil-extent empty-stencil Y)))))
109     (ly:prob-property system 'stencil)))