From: Mike Solomon Date: Thu, 22 Sep 2011 07:05:58 +0000 (+0200) Subject: Fixes Issue 1301 (colliding note and clef). X-Git-Tag: release/2.15.13-1~38 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=943ba7c0e397eacc957cbbc5ad924053407139aa;p=lilypond.git Fixes Issue 1301 (colliding note and clef). Loose columns are now: -) better spaced between their fixed counterpoints see spacing-loose-columns.cc -) spaced with respect to the left column against which they collide, not the column directly to the left. see spacing-determine-loose-columns.cc --- diff --git a/input/regression/spacing-loose-polyphony.ly b/input/regression/spacing-loose-polyphony.ly new file mode 100644 index 0000000000..cb539878e9 --- /dev/null +++ b/input/regression/spacing-loose-polyphony.ly @@ -0,0 +1,17 @@ +\version "2.15.13" + +\header { + texidoc = "Loose columns (here, the treble clef) are spaced +correctly in polyphonic music. +" +} + +\new PianoStaff << + \new Staff \relative c' { + \times 2/3 { g'4 a2 } + } + \new Staff \relative c' { + \clef bass fis,,8 cis' + \clef treble g'' fis, + } +>> diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index 99d9e596af..a195495529 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -191,7 +191,6 @@ Spacing_spanner::prune_loose_columns (Grob *me, Spacing_options *options) { vector newcols; - for (vsize i = 0; i < cols->size (); i++) { Grob *c = cols->at (i); @@ -243,14 +242,14 @@ Spacing_spanner::prune_loose_columns (Grob *me, /* Set distance constraints for loose columns */ - Drul_array next_door (dynamic_cast (cols->at (i - 1)), - dynamic_cast (cols->at (i + 1))); + Drul_array next_door (dynamic_cast (left_neighbor), + dynamic_cast (right_neighbor)); set_distances_for_loose_col (me, c, next_door, options); } } - if (!loose) + else newcols.push_back (c); } diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index fb5e326369..cc706fb6b0 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -112,8 +112,21 @@ set_loose_columns (System *which, Column_x_positions const *posns) clique.push_back (right); + /* + We use two vectors to keep track of loose column spacing: + clique_spacing keeps track of ideal spaces. + clique_tight_spacing keeps track of minimum spaces. + Below, a scale factor is applied to the shifting of loose columns that + aims to preserve clique_spacing but gets closer to clique_tight_spacing as the + space becomes smaller. This is used because the rods placed for loose columns + are tight (meaning they use minimum distances - see set_distances_for_loose_columns). + However, other rods may widen this distance, in which case we don't want a crammed score. + Thus, we aim for non-crammed, and fall back on crammed as needed. + */ vector clique_spacing; + vector clique_tight_spacing; clique_spacing.push_back (0.0); + clique_tight_spacing.push_back (0.0); for (vsize j = 1; j + 1 < clique.size (); j++) { Grob *clique_col = clique[j]; @@ -134,11 +147,25 @@ set_loose_columns (System *which, Column_x_positions const *posns) programming_error ("Column without spacing object"); Real base_note_space = 0.0; + Real tight_note_space = 0.0; if (Paper_column::is_musical (next_col) && Paper_column::is_musical (loose_col)) - base_note_space = Spacing_spanner::note_spacing (spacing, loose_col, next_col, - &options); + { + Real base = Spacing_spanner::note_spacing (spacing, loose_col, next_col, + &options); + if (Note_spacing::has_interface (spacing)) + { + Spring spring = Note_spacing::get_spacing (spacing, next_col, base, options.increment_);; + base_note_space = spring.distance (); + tight_note_space = spring.min_distance (); + } + else + { + base_note_space = base; + tight_note_space = base; + } + } else { Spring spring = Spacing_spanner::standard_breakable_column_spacing (spacing, @@ -146,29 +173,34 @@ set_loose_columns (System *which, Column_x_positions const *posns) &options); base_note_space = spring.distance (); + tight_note_space = spring.min_distance (); } - base_note_space = max (base_note_space, - robust_relative_extent (loose_col, loose_col, X_AXIS)[RIGHT] - - robust_relative_extent (next_col, next_col, X_AXIS)[LEFT]); - clique_spacing.push_back (base_note_space); + clique_tight_spacing.push_back (tight_note_space); } - Real default_padding = 1.0; - clique_spacing.push_back (default_padding); - + Real permissible_distance = clique.back ()->relative_coordinate (common, X_AXIS) - robust_relative_extent (clique[0], common, X_AXIS)[RIGHT]; Real right_point = robust_relative_extent (clique.back (), common, X_AXIS)[LEFT]; - Grob *finished_right_column = clique.back (); + Real sum_tight_spacing = 0; + Real sum_spacing = 0; + // currently a magic number - what would be a good grob to hold this property? + Real left_padding = 0.15; + for (vsize j = 0; j < clique_spacing.size (); j++) + { + sum_tight_spacing += clique_tight_spacing[j]; + sum_spacing += clique_spacing[j]; + } + Real scale_factor = max (0.0, min (1.0, (permissible_distance - left_padding - sum_tight_spacing) / (sum_spacing - sum_tight_spacing))); for (vsize j = clique.size () - 2; j > 0; j--) { Paper_column *clique_col = dynamic_cast (clique[j]); right_point = finished_right_column->relative_coordinate (common, X_AXIS); - Real distance_to_next = clique_spacing[j]; + Real distance_to_next = clique_tight_spacing[j] + (clique_spacing[j] - clique_tight_spacing[j]) * scale_factor; Real my_offset = right_point - distance_to_next;