From 1dd946408282051972bc75c849cd406670174da1 Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Sat, 2 Jul 2011 23:09:06 +0200 Subject: [PATCH] Fixes the multi-line glissandos to use more intelligent line breaks. --- input/regression/glissando-broken-multiple.ly | 7 +++ lily/line-spanner.cc | 4 +- scm/define-grobs.scm | 3 +- scm/output-lib.scm | 45 +++++++++++-------- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/input/regression/glissando-broken-multiple.ly b/input/regression/glissando-broken-multiple.ly index 4ef945b427..906f984be4 100644 --- a/input/regression/glissando-broken-multiple.ly +++ b/input/regression/glissando-broken-multiple.ly @@ -15,4 +15,11 @@ \break s1 \break s1 c,1^\ff\trill + % Subsequent glissando prints correctly instead of + % using the Y positions from the previous one. + a'1\glissando + \break s1 + \break s1 + \break s1 + e1^\ff\trill } diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index 69cbc69ce0..d50b94834a 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -224,6 +224,9 @@ Line_spanner::print (SCM smob) { Spanner *me = dynamic_cast (unsmob_grob (smob)); + // Triggers simple-Y calculations + bool simple_y = to_boolean (me->get_property ("simple-Y")) && !to_boolean (me->get_property ("cross-staff")); + Drul_array bounds (me->get_property ("left-bound-info"), me->get_property ("right-bound-info")); @@ -269,7 +272,6 @@ Line_spanner::print (SCM smob) while (flip (&d) != LEFT); Grob *my_common_y = common_y[LEFT]->common_refpoint (common_y[RIGHT], Y_AXIS); - bool simple_y = to_boolean (me->get_property ("simple-Y")) && !to_boolean (me->get_property ("cross-staff")); if (!simple_y) { diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index d2162ce587..9a8d14a1c3 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -927,7 +927,6 @@ (Glissando . ( (after-line-breaking . ,ly:spanner::kill-zero-spanned-time) - (before-line-breaking . ,glissando::before-line-breaking) (bound-details . ((right . ((attach-dir . ,CENTER) (padding . 1.5) )) @@ -939,7 +938,7 @@ (left-bound-info . ,ly:line-spanner::calc-left-bound-info) (normalized-endpoints . ,ly:spanner::calc-normalized-endpoints) (right-bound-info . ,ly:line-spanner::calc-right-bound-info) - (simple-Y . #t) + (simple-Y . ,glissando::make-simple-y) (stencil . ,ly:line-spanner::print) (style . line) (X-extent . #f) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index a9581e5e8e..01953a9412 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -795,26 +795,35 @@ between the two text elements." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; glissando -(define-public (glissando::before-line-breaking grob) - "Establishes the Y terminus points of the glissando based on the pre-broken -positions of its left and right bounds." - (let ((bound-details (ly:grob-property grob 'bound-details)) +(define-public (glissando::make-simple-y grob) + "Establishes the Y terminus points of the glissando based on the +pre-broken positions of its left and right bounds." + (let* ((siblings (ly:spanner-broken-into (ly:grob-original grob))) + (bound-details (ly:grob-property grob 'bound-details)) (extra-dy (ly:grob-property grob 'extra-dy 0.0))) - (for-each (lambda (dir-sym) - (let* ((details (assoc-get dir-sym bound-details)) - (dir (if (eq? dir-sym 'left) LEFT RIGHT)) - (bound (ly:spanner-bound grob dir)) - (common-y (ly:grob-common-refpoint grob bound Y)) - (y (+ (interval-center (ly:grob-extent bound common-y Y)) - (/ (* dir extra-dy) - 2)))) - (if (not (assoc-get 'Y details)) - (set! bound-details (assoc-set! bound-details dir-sym - (acons 'Y y details)))))) - '(left right)) - - (set! (ly:grob-property grob 'bound-details) bound-details))) + (and (pair? siblings) + (for-each (lambda (dir-sym) + (let* ((details (assoc-get dir-sym bound-details)) + (dir (if (eq? dir-sym 'left) LEFT RIGHT)) + (good-grob (if (eq? dir-sym 'left) + (first siblings) + (last siblings))) + (bound (ly:spanner-bound good-grob dir)) + (common-y (ly:grob-common-refpoint good-grob + bound + Y)) + (y (+ (interval-center (ly:grob-extent bound + common-y + Y)) + (/ (* dir extra-dy) + 2)))) + (if (not (assoc-get 'Y details)) + (set! bound-details (assoc-set! bound-details dir-sym + (acons 'Y y details)))))) + '(left right)) + + (set! (ly:grob-property grob 'bound-details) bound-details)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -- 2.39.2