]> git.donarmstrong.com Git - lilypond.git/commitdiff
Allow independent adjustment of minimum length for spanner siblings
authorDavid Nalesnik <david.nalesnik@gmail.com>
Wed, 4 Feb 2015 20:07:01 +0000 (14:07 -0600)
committerDavid Nalesnik <david.nalesnik@gmail.com>
Sat, 14 Feb 2015 14:54:15 +0000 (08:54 -0600)
The property minimum-length does not allow independent adjustment
of the siblings of broken spanners.  This patch adds a property,
minimum-length-after-break, which, if set, behaves similarly to minimum-length,
but only affects siblings starting a line.  If minimum-length-after-break is
unset, minimum-length still controls all lengths.

A regtest demonstrates usage of the new property with a number of spanners.
Another regtest demonstrates usage and compatibility of minimum-distance
and minimum-distance-after-break.

input/regression/minimum-length-after-break.ly [new file with mode: 0644]
input/regression/minimum-length-broken-ties.ly [new file with mode: 0644]
lily/spanner.cc
scm/define-grob-properties.scm

diff --git a/input/regression/minimum-length-after-break.ly b/input/regression/minimum-length-after-break.ly
new file mode 100644 (file)
index 0000000..8d8fbb6
--- /dev/null
@@ -0,0 +1,45 @@
+\version "2.19.16"
+
+\header {
+  texidoc = "The property @code{minimum-length-after-break} can be
+used to stretch broken spanners starting after a line break.  The
+following example shows usage for a variety of spanners.
+"
+}
+
+\layout {
+  ragged-right = ##t
+}
+
+{
+  \once \override Tie.minimum-length-after-break = 20
+  a1~
+  \break
+  a1
+
+  \once \override Slur.minimum-length-after-break = 20
+  a1(
+  \break
+  d'1)
+
+  \once \override TextSpanner.springs-and-rods = #ly:spanner::set-spacing-rods
+  \once \override TextSpanner.minimum-length-after-break = 20
+  a1\startTextSpan
+  \break
+  a1\stopTextSpan
+
+  \once \override Hairpin.after-line-breaking = ##t
+  \once \override Hairpin.to-barline = ##f
+  \once \override Hairpin.minimum-length-after-break = 20
+  a1\<
+  \break
+  a1\!
+
+  \once \override Glissando.springs-and-rods = #ly:spanner::set-spacing-rods
+  \once \override Glissando.breakable = ##t
+  \once \override Glissando.after-line-breaking = ##t
+  \once \override Glissando.minimum-length-after-break = 20
+  a1\glissando
+  \break
+  d'1
+}
diff --git a/input/regression/minimum-length-broken-ties.ly b/input/regression/minimum-length-broken-ties.ly
new file mode 100644 (file)
index 0000000..ef824ac
--- /dev/null
@@ -0,0 +1,39 @@
+\version "2.19.16"
+
+\header {
+  texidoc = "The following shows the interaction between the
+properties @code{minimum-length} and
+@code{minimum-length-after-break}.  When @code{minimum-length}
+is used alone, both segments of the tie are affected.  The
+properties @code{minimum-length-after-break} only affects
+the sibling starting a line.  Both properties may be used
+together to create independent changes of both siblings.  This
+example shows that both properties have an identical effect on
+the sibling after the break.
+"
+}
+
+\layout {
+  ragged-right = ##t
+}
+
+music = {
+  <gis' cis'' dis'' gis''>1~
+  \break
+  q1
+}
+
+{
+  % default
+  \music
+
+  \once \override Tie.minimum-length = 11
+  \music
+
+  \once \override Tie.minimum-length-after-break = 11
+  \music
+
+  \once \override Tie.minimum-length = 8
+  \once \override Tie.minimum-length-after-break = 11
+  \music
+}
index 66b35dcd1b8b53df0438bcccddc62b96be71b134..84752313213c5df7c3c8ff6e03473cae3e8c1e53 100644 (file)
@@ -366,9 +366,10 @@ Spanner::set_spacing_rods (SCM smob)
 {
   Grob *me = Grob::unsmob (smob);
   SCM num_length = me->get_property ("minimum-length");
-  if (scm_is_number (num_length))
+  SCM broken_length = me->get_property ("minimum-length-after-break");
+  if (scm_is_number (num_length)
+     || scm_is_number (broken_length))
     {
-      Rod r;
       Spanner *sp = dynamic_cast<Spanner *> (me);
       System *root = get_root_system (me);
       Drul_array<Item *> bounds (sp->get_bound (LEFT),
@@ -389,9 +390,23 @@ Spanner::set_spacing_rods (SCM smob)
 
           r.item_drul_[LEFT] = cols.back ()->find_prebroken_piece (RIGHT);
           r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
+          if (scm_is_number (broken_length))
+            /*
+              r.distance_ may have been modified by add_to_cols ()
+              above.  For treatment of minimum-distance-after-break
+              consistent with minimum-distance (which will use the
+              changed value), we cannot directly reset r.distance_ to
+              broken_length.
+            */
+            r.distance_ += robust_scm2double (broken_length, 0) -
+              robust_scm2double (num_length, 0);
           r.add_to_cols ();
         }
 
+      Rod r;
+      /*
+        As r is a fresh rod, we can set distance_ with no complication.
+      */
       r.distance_ = robust_scm2double (num_length, 0);
       r.item_drul_[LEFT] = sp->get_bound (LEFT);
       r.item_drul_[RIGHT] = sp->get_bound (RIGHT);
@@ -546,6 +561,7 @@ ADD_INTERFACE (Spanner,
                /* properties */
                "normalized-endpoints "
                "minimum-length "
+               "minimum-length-after-break "
                "spanner-broken "
                "spanner-id "
                "to-barline "
index 5970da75422edce4c62b401540e0005a2a945328..7e912722e65cebc6cce525219163c924b4c77150 100644 (file)
@@ -637,6 +637,11 @@ this long, normally in the horizontal direction.  This requires an
 appropriate callback for the @code{springs-and-rods} property.  If
 added to a @code{Tie}, this sets the minimum distance between
 noteheads.")
+     (minimum-length-after-break ,ly:dimension? "If set, try to make
+a broken spanner starting a line this long.  This requires an
+appropriate callback for the @code{springs-and-rods} property.  If
+added to a @code{Tie}, this sets the minimum distance to the
+notehead.")
      (minimum-length-fraction ,number? "Minimum length of ledger line
 as fraction of note head size.")
      (minimum-space ,ly:dimension? "Minimum distance that the victim