From eb71b343f91d1fbe1842f653fb285e12934ed072 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Thu, 6 Aug 2009 07:57:41 +1000 Subject: [PATCH] Fix 462. Mark invisible barlines as loose columns. --- input/regression/spacing-empty-bar.ly | 10 ++++++++++ lily/paper-column.cc | 1 + lily/spacing-determine-loose-columns.cc | 26 ++++++++++++++++++++----- lily/spacing-spanner.cc | 2 +- scm/define-grob-properties.scm | 2 ++ 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 input/regression/spacing-empty-bar.ly diff --git a/input/regression/spacing-empty-bar.ly b/input/regression/spacing-empty-bar.ly new file mode 100644 index 0000000000..3a8cd9c435 --- /dev/null +++ b/input/regression/spacing-empty-bar.ly @@ -0,0 +1,10 @@ +\version "2.13.4" + +\header { + texidoc = "Empty barlines do not affect spacing." +} + +{ + c'4 c' \bar "" c' c' \break + \repeat unfold 10 { c' c' c' c' \bar "" \noBreak } +} \ No newline at end of file diff --git a/lily/paper-column.cc b/lily/paper-column.cc index e8533e9453..3308cf251c 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -365,6 +365,7 @@ ADD_INTERFACE (Paper_column, "line-break-system-details " "line-break-penalty " "line-break-permission " + "maybe-loose " "page-break-penalty " "page-break-permission " "page-turn-penalty " diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index 7aa42caece..90db1e01e1 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -47,8 +47,7 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) } - if (Paper_column::is_musical (col) - || Paper_column::is_breakable (col)) + if (Paper_column::is_musical (col)) return false; /* @@ -79,8 +78,11 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) if (!l_neighbor || !r_neighbor) return false; - if (l == l_neighbor && r == r_neighbor) - return false; + /* If a non-empty column (ie. not \bar "") is placed nicely in series with + its neighbor (ie. no funny polyphonic stuff), don't make it loose. + */ + if (l == l_neighbor && r == r_neighbor && col->extent (col, X_AXIS).length () > 0) + return false; /* Only declare loose if the bounds make a little sense. This means @@ -106,7 +108,12 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) Grob *h = gelts[j]; if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar")) - return false; + { + extract_grob_set (h, "elements", helts); + for (vsize k = helts.size (); k--;) + if ("" != robust_scm2string (helts[k]->get_property ("glyph-name"), "")) + return false; + } } } } @@ -185,6 +192,15 @@ Spacing_spanner::prune_loose_columns (Grob *me, bool loose = (i > 0 && i + 1 < cols->size ()) && is_loose_column (cols->at (i - 1), c, cols->at (i + 1), options); + /* Breakable columns never get pruned; even if they are loose, + their broken pieces are not. However, we mark them so that + the spacing can take their mid-line looseness into account. */ + if (loose && Paper_column::is_breakable (c)) + { + loose = false; + c->set_property ("maybe-loose", SCM_BOOL_T); + } + if (loose) { Grob *right_neighbor = unsmob_grob (c->get_object ("right-neighbor")); diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 274905faf5..cc5170de79 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -168,7 +168,7 @@ Spacing_spanner::generate_pair_spacing (Grob *me, if (Paper_column::is_musical (left_col)) { if (!Paper_column::is_musical (right_col) - && options->float_nonmusical_columns_ + && (options->float_nonmusical_columns_ || to_boolean (right_col->get_property ("maybe-loose"))) && after_right_col && Paper_column::is_musical (after_right_col)) { diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index ac09201044..bdd702bce9 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -1004,6 +1004,8 @@ supported by this object. It is initialized from the @code{meta} field.") (least-squares-dy ,number? "The ideal beam slope, without damping.") + (maybe-loose ,boolean? "Used to mark a breakable column that is +loose if and only if it is in the middle of a line.") (meta ,list? "Provide meta information. It is an alist with the entries @code{name} and @code{interfaces}.") (minimum-distances ,list? "A list of rods that have the format -- 2.39.5