X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Flayout-beam.scm;h=8aae2d09d5622cc4840a7d68a020fde6faba5404;hb=9e781b7dc83b60a543ce218aa1a5f139f74c760f;hp=254f7154971820b719e864681a772c5bc2fdcd04;hpb=a6bd229f7fe1dc4a03478e14ccc0c0c66b225061;p=lilypond.git diff --git a/scm/layout-beam.scm b/scm/layout-beam.scm index 254f715497..8aae2d09d5 100644 --- a/scm/layout-beam.scm +++ b/scm/layout-beam.scm @@ -1,6 +1,6 @@ ;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; Copyright (C) 2000--2010 Jan Nieuwenhuizen +;;;; Copyright (C) 2000--2014 Jan Nieuwenhuizen ;;;; ;;;; LilyPond is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by @@ -15,62 +15,59 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with LilyPond. If not, see . -(define ((check-beam-quant posl posr) beam posns) - "Check whether BEAM has POSL and POSR quants. POSL are (POSITION -. QUANT) pairs, where QUANT is -1 (hang), 0 (center), 1 (sit) or -2/ 2 (inter) +(define check-beam-quant + (lambda (posl posr) + (lambda (beam posns) + "Check whether BEAM has POSL and POSR quants. POSL are (POSITION +. QUANT) pairs, where QUANT is -1 (hang), 0 (center), 1 (sit) or -2/ 2 (inter) " - (let* ((thick (ly:grob-property beam 'beam-thickness)) - (layout (ly:grob-layout beam)) - (lthick (ly:output-def-lookup layout 'line-thickness)) - (staff-thick lthick) ; fixme. - (quant->coord (lambda (p q) - (if (= 2 (abs q)) - (+ p (/ q 4.0)) - (+ p (- (* 0.5 q thick) (* 0.5 q lthick)))))) - (want-l (quant->coord (car posl) (cdr posl))) - (want-r (quant->coord (car posr) (cdr posr))) - (almost-equal (lambda (x y) (< (abs (- x y)) 1e-3)))) - - (if (or (not (almost-equal want-l (car posns))) - (not (almost-equal want-r (cdr posns)))) - (begin - (ly:warning (_ "Error in beam quanting. Expected (~S,~S) found ~S.") - want-l want-r posns) - (set! (ly:grob-property beam 'annotation) - (format "(~S,~S)" want-l want-r)))) - posns - )) + (let* ((thick (ly:grob-property beam 'beam-thickness)) + (layout (ly:grob-layout beam)) + (lthick (ly:output-def-lookup layout 'line-thickness)) + (staff-thick lthick) ; fixme. + (quant->coord (lambda (p q) + (if (= 2 (abs q)) + (+ p (/ q 4.0)) + (+ p (- (* 0.5 q thick) (* 0.5 q lthick)))))) + (want-l (quant->coord (car posl) (cdr posl))) + (want-r (quant->coord (car posr) (cdr posr))) + (almost-equal (lambda (x y) (< (abs (- x y)) 1e-3)))) + (if (or (not (almost-equal want-l (car posns))) + (not (almost-equal want-r (cdr posns)))) + (begin + (ly:warning (_ "Error in beam quanting. Expected (~S,~S) found ~S.") + want-l want-r posns) + (set! (ly:grob-property beam 'annotation) + (format #f "(~S,~S)" want-l want-r)))) + posns)))) -(define ((check-beam-slope-sign comparison) beam posns) - "Check whether the slope of BEAM is correct wrt. COMPARISON." - (let* ((slope-sign (- (cdr posns) (car posns))) - (correct (comparison slope-sign 0))) - (if (not correct) - (begin - (ly:warning (_ "Error in beam quanting. Expected ~S 0, found ~S.") - (procedure-name comparison) slope-sign) - (set! (ly:grob-property beam 'annotation) - (format "~S 0" (procedure-name comparison)))) - (set! (ly:grob-property beam 'annotation) "")) - posns)) +(define check-beam-slope-sign + (lambda (comparison) + (lambda (beam posns) + "Check whether the slope of BEAM is correct wrt. COMPARISON." + (let* ((slope-sign (- (cdr posns) (car posns))) + (correct (comparison slope-sign 0))) + (if (not correct) + (begin + (ly:warning (_ "Error in beam quanting. Expected ~S 0, found ~S.") + (procedure-name comparison) slope-sign) + (set! (ly:grob-property beam 'annotation) + (format #f "~S 0" (procedure-name comparison)))) + (set! (ly:grob-property beam 'annotation) "")) + posns)))) (define-public (check-quant-callbacks l r) - (list ly:beam::calc-least-squares-positions - ly:beam::slope-damping - ly:beam::shift-region-to-valid - ly:beam::quanting - (check-beam-quant l r) - )) + (lambda (grob) + ((check-beam-quant l r) + grob + (beam::place-broken-parts-individually grob)))) (define-public (check-slope-callbacks comparison) - (list ly:beam::calc-least-squares-positions - ly:beam::slope-damping - ly:beam::shift-region-to-valid - ly:beam::quanting - (check-beam-slope-sign comparison) - )) - + (lambda (grob) + ((check-beam-slope-sign comparison) + grob + (beam::place-broken-parts-individually grob))))