From de67aa455a54cd7fcf95902ee60c4bdef7072063 Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Sat, 6 Apr 2013 10:03:44 +0200 Subject: [PATCH] Hairpin minimum-length has not effect at end of line; issue 2785. Fixes the springs and rods callback so that broken left items and center items are used as potential bounds of spanners, which allows both cases to be considered in the simple spacer when scoring line breaking configurations. --- input/regression/minimum-length-end-line.ly | 16 ++++++++++++++++ lily/simple-spacer.cc | 3 +++ lily/spanner.cc | 17 +++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 input/regression/minimum-length-end-line.ly diff --git a/input/regression/minimum-length-end-line.ly b/input/regression/minimum-length-end-line.ly new file mode 100644 index 0000000000..29ba2f7127 --- /dev/null +++ b/input/regression/minimum-length-end-line.ly @@ -0,0 +1,16 @@ +\version "2.17.16" + +\header { + texidoc = "Long spanners at the end of the lines stretch measures +correctly. +" +} + +{ + \override Hairpin.minimum-length = #60 + \override Hairpin.to-barline = ##t + \repeat unfold 4 a1 + a1\< + a1\> + a1\! +} diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 61afdb9bcc..aef524da87 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -387,6 +387,9 @@ get_column_description (vector const &cols, vsize col_index, bool line_s if (cols[j] == other) description.rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s)))); else /* it must end at the LEFT prebroken_piece */ + /* see Spanner::set_spacing_rods for more comments on how + to deal with situations where we don't know if we're + ending yet on the left prebroken piece */ description.end_rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s)))); } } diff --git a/lily/spanner.cc b/lily/spanner.cc index a6a2cb7e93..79496dd4f5 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -385,6 +385,23 @@ Spanner::set_spacing_rods (SCM smob) r.item_drul_[LEFT] = sp->get_bound (LEFT); r.item_drul_[RIGHT] = sp->get_bound (RIGHT); r.add_to_cols (); + + /* + We do not know yet if the spanner is going to have a bound that is + broken. To account for this uncertainty, we add the rod twice: + once for the central column (see above) and once for the left column + (see below). As end_rods_ are never used when rods_ are used and vice + versa, this rod will only be accessed once for each spacing + configuraiton before line breaking. Then, as a grob never exists in + both unbroken and broken forms after line breaking, only one of these + two rods will be in the column vector used for spacing in + simple-spacer.cc get_line_confugration. + */ + if (Item *left_pbp = sp->get_bound (RIGHT)->find_prebroken_piece (LEFT)) + { + r.item_drul_[RIGHT] = left_pbp; + r.add_to_cols (); + } } return SCM_UNSPECIFIED; -- 2.39.2