1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2006--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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))
22 (define-public (paper-system-title? system)
23 (equal? #t (ly:prob-property system 'is-title)
26 (define-public (paper-system-stencil system)
27 (ly:prob-property system 'stencil))
29 (define-public (paper-system-layout system)
31 ((g (paper-system-system-grob system)))
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)
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))
53 (arrow (if (number? bottomspace)
54 (annotate-y-interval layout
56 (cons (- (car y-extent) bottomspace)
63 (ly:stencil-add stencil arrow)))
65 (set! (ly:prob-property system 'stencil)
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
77 (ly:grob-property grob 'pure-Y-extent)
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))
87 (paper-system-title? next-system))
88 (ly:output-def-lookup layout 'before-title-spacing))
90 (ly:output-def-lookup layout 'between-system-spacing))))
91 (last-staff-Y (car (paper-system-staff-extents system))))
94 (annotate-spacing-spec layout spacing-spec last-staff-Y (car (paper-system-extent system Y)))))
97 (stack-stencils X RIGHT 0.5
101 (if (not (null? annotations))
102 (set! (ly:prob-property system 'stencil)
104 (ly:prob-property system '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)))