1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2000--2014 Jan Nieuwenhuizen <janneke@gnu.org>
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 check-beam-quant
21 "Check whether BEAM has POSL and POSR quants. POSL are (POSITION
22 . QUANT) pairs, where QUANT is -1 (hang), 0 (center), 1 (sit) or -2/ 2 (inter)
25 (let* ((thick (ly:grob-property beam 'beam-thickness))
26 (layout (ly:grob-layout beam))
27 (lthick (ly:output-def-lookup layout 'line-thickness))
28 (staff-thick lthick) ; fixme.
29 (quant->coord (lambda (p q)
32 (+ p (- (* 0.5 q thick) (* 0.5 q lthick))))))
33 (want-l (quant->coord (car posl) (cdr posl)))
34 (want-r (quant->coord (car posr) (cdr posr)))
35 (almost-equal (lambda (x y) (< (abs (- x y)) 1e-3))))
37 (if (or (not (almost-equal want-l (car posns)))
38 (not (almost-equal want-r (cdr posns))))
40 (ly:warning (_ "Error in beam quanting. Expected (~S,~S) found ~S.")
42 (set! (ly:grob-property beam 'annotation)
43 (format #f "(~S,~S)" want-l want-r))))
46 (define check-beam-slope-sign
49 "Check whether the slope of BEAM is correct wrt. COMPARISON."
50 (let* ((slope-sign (- (cdr posns) (car posns)))
51 (correct (comparison slope-sign 0)))
54 (ly:warning (_ "Error in beam quanting. Expected ~S 0, found ~S.")
55 (procedure-name comparison) slope-sign)
56 (set! (ly:grob-property beam 'annotation)
57 (format #f "~S 0" (procedure-name comparison))))
58 (set! (ly:grob-property beam 'annotation) ""))
62 (define-public (check-quant-callbacks l r)
64 ((check-beam-quant l r)
66 (beam::place-broken-parts-individually grob))))
69 (define-public (check-slope-callbacks comparison)
71 ((check-beam-slope-sign comparison)
73 (beam::place-broken-parts-individually grob))))