]> git.donarmstrong.com Git - lilypond.git/commitdiff
Implements multiple-line non-cross-staff glissandi.
authorMike Solomon <mike@apollinemike.com>
Fri, 1 Jul 2011 09:36:41 +0000 (11:36 +0200)
committerMike Solomon <mike@apollinemike.com>
Fri, 1 Jul 2011 09:36:41 +0000 (11:36 +0200)
Glissandi, not being placed outside the staff, are not bumped up or
down depending on other outside staff grobs that may appear after
a line break.  Thus, all they need to know are the terminus positions
on the Y axis in order to be typeset.  This means that they can span
multiple lines.

input/regression/glissando-broken-multiple.ly [new file with mode: 0644]
lily/line-spanner.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/output-lib.scm

diff --git a/input/regression/glissando-broken-multiple.ly b/input/regression/glissando-broken-multiple.ly
new file mode 100644 (file)
index 0000000..4ef945b
--- /dev/null
@@ -0,0 +1,18 @@
+\header {
+  texidoc = "When broken, glissandi can span multiple lines."
+
+}
+\version "2.15.0"
+\paper {
+  ragged-right = ##t
+}
+
+\relative c'' {
+  \override Glissando #'breakable = ##t
+  \override Glissando #'after-line-breaking = ##t
+  d1\glissando
+  \break s1
+  \break s1
+  \break s1
+  c,1^\ff\trill
+}
index d7f4837a2511f936877ec8d1d0e09e04b827a5ed..69cbc69ce0544400a34b99ee748d634dc0933253 100644 (file)
@@ -269,9 +269,14 @@ Line_spanner::print (SCM smob)
   while (flip (&d) != LEFT);
 
   Grob *my_common_y = common_y[LEFT]->common_refpoint (common_y[RIGHT], Y_AXIS);
-  do
-    span_points[d][Y_AXIS] += common_y[d]->relative_coordinate (my_common_y, Y_AXIS);
-  while (flip (&d) != LEFT);
+  bool simple_y = to_boolean (me->get_property ("simple-Y")) && !to_boolean (me->get_property ("cross-staff"));
+
+  if (!simple_y)
+    {
+      do
+        span_points[d][Y_AXIS] += common_y[d]->relative_coordinate (my_common_y, Y_AXIS);
+      while (flip (&d) != LEFT);
+    }
 
   Interval normalized_endpoints = robust_scm2interval (me->get_property ("normalized-endpoints"), Interval (0, 1));
   Real y_length = span_points[RIGHT][Y_AXIS] - span_points[LEFT][Y_AXIS];
@@ -334,7 +339,7 @@ Line_spanner::print (SCM smob)
     }
 
   line.translate (Offset (-me->relative_coordinate (commonx, X_AXIS),
-                         -me->relative_coordinate (my_common_y, Y_AXIS)));
+                         simple_y ? 0.0 : -me->relative_coordinate (my_common_y, Y_AXIS)));
 
 
   return line.smobbed_copy ();
@@ -351,6 +356,7 @@ ADD_INTERFACE (Line_spanner,
               "left-bound-info "
               "note-columns "
               "right-bound-info "
+              "simple-Y "
               "thickness "
               "to-barline "
               );
index 8f05a8b324a366f90fb9227b9f893fa6fdf7f57e..a10e62b965a25bf73c9b0ff3f89c923e3e76fe1d 100644 (file)
@@ -735,6 +735,8 @@ placed vertically.")
      (side-relative-direction ,ly:dir? "Multiply direction of
 @code{direction-source} with this to get the direction of this
 object.")
+     (simple-Y ,boolean? "Should the Y placement of a spanner
+disregard changes in system heights?")
      (size ,number? "Size of object, relative to standard size.")
      (skyline-horizontal-padding ,number? "For determining the
 vertical distance between two staves, it is possible to have a
index ecfeee3d6bf35bd3f7ebeb5e113420bf2e821e2d..d2162ce58724d7eed32258b0eed2c63afbddcd0c 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)
        (stencil . ,ly:line-spanner::print)
        (style . line)
        (X-extent . #f)
index 1081377907907cd9860a8a14217798080bfe3034..a9581e5e8e0b47129cd94ecdb5cfaf019b6dc225 100644 (file)
@@ -792,6 +792,31 @@ between the two text elements."
     (ly:grob-property grob 'dot-placement-list))))
 
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; 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))
+        (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)))
+
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; scripts