]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fixes the multi-line glissandos to use more intelligent line breaks.
authorMike Solomon <mike@apollinemike.com>
Sat, 2 Jul 2011 21:09:06 +0000 (23:09 +0200)
committerMike Solomon <mike@apollinemike.com>
Sat, 2 Jul 2011 21:12:02 +0000 (23:12 +0200)
input/regression/glissando-broken-multiple.ly
lily/line-spanner.cc
scm/define-grobs.scm
scm/output-lib.scm

index 4ef945b427c1d266be3854aa04aa3c1e98616fcb..906f984be4067291366fb02b712ad91ebf01bfca 100644 (file)
   \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
 }
index 69cbc69ce0544400a34b99ee748d634dc0933253..d50b94834a57c7fd3b6a83291d51acb7a0a23673 100644 (file)
@@ -224,6 +224,9 @@ Line_spanner::print (SCM smob)
 {
   Spanner *me = dynamic_cast<Spanner *> (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<SCM> 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)
     {
index d2162ce58724d7eed32258b0eed2c63afbddcd0c..9a8d14a1c31a434b0c02a72e194433ee818d1ed7 100644 (file)
     (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)
                                      ))
        (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)
index a9581e5e8e0b47129cd94ecdb5cfaf019b6dc225..01953a941215f60b06c9a30797c5d2c5e8d551f0 100644 (file)
@@ -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))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;