From: David Nalesnik Date: Wed, 4 Feb 2015 20:07:01 +0000 (-0600) Subject: Allow independent adjustment of minimum length for spanner siblings X-Git-Tag: release/2.19.16-1~2^2~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3668bac590386ed98cf517d7bd71f79ae35abbc4;p=lilypond.git Allow independent adjustment of minimum length for spanner siblings 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. --- diff --git a/input/regression/minimum-length-after-break.ly b/input/regression/minimum-length-after-break.ly new file mode 100644 index 0000000000..8d8fbb6145 --- /dev/null +++ b/input/regression/minimum-length-after-break.ly @@ -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 index 0000000000..ef824ac254 --- /dev/null +++ b/input/regression/minimum-length-broken-ties.ly @@ -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 = { + 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 +} diff --git a/lily/spanner.cc b/lily/spanner.cc index 66b35dcd1b..8475231321 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -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 (me); System *root = get_root_system (me); Drul_array 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 " diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 5970da7542..7e912722e6 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -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