From: Keith OHara Date: Wed, 18 Dec 2013 01:20:22 +0000 (-0800) Subject: note-spacing: let compressibility be uniform; issue 3304 X-Git-Tag: release/2.19.0-1~10 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=50e45591ccb79a49a738af09e692df64d343c951;p=lilypond.git note-spacing: let compressibility be uniform; issue 3304 Comments implied that half the width of accidentals, etc., was added to the ideal spacing between notes, but in fact only compressibility was affected. The non-uniform compressibility caused note-spacing to become non-uniform when the lines were compressed. For example A sequence {\stemUp a a d a] would have the head of the D tuck under the preceding A. This commit keeps spacing uniform on compressed lines until objects come within padding of each other. --- diff --git a/input/regression/baerenreiter-sarabande.ly b/input/regression/baerenreiter-sarabande.ly index 426bbf4b18..892359dfc2 100644 --- a/input/regression/baerenreiter-sarabande.ly +++ b/input/regression/baerenreiter-sarabande.ly @@ -1,6 +1,6 @@ \version "2.17.6" -forcedLastBreak = { \break } +forcedLastBreak = {} %% { \break } if needed to match original breaks %% We want this to perfectly match the Bärenreiter spacing. %% If we're not using 6 systems, there's definitely a problem. @@ -171,10 +171,9 @@ smallerPaper = \layout { ragged-bottom = ##t indent = 7. \mm line-width =183.5 \mm - obsolete-between-system-space = 25\mm - system-system-spacing #'basic-distance = #(/ obsolete-between-system-space staff-space) + system-system-spacing #'basic-distance = 14.22 % 25mm, in staff-spaces system-system-spacing #'padding = #0 - score-system-spacing #'basic-distance = #(/ obsolete-between-system-space staff-space) + score-system-spacing #'basic-distance = #0 score-system-spacing #'padding = #0 system-count = 6 diff --git a/input/regression/spanner-alignment.ly b/input/regression/spanner-alignment.ly index 02e04ece7d..2b4210841d 100644 --- a/input/regression/spanner-alignment.ly +++ b/input/regression/spanner-alignment.ly @@ -16,7 +16,7 @@ ignoring things like pedal marks. } \new Dynamics = "dynamics" { \repeat unfold 2 { - s1\cresc s1\f s1\dim s1\p + s1\cresc s1\f s1\dim s1\p \break } } \new Staff = "down" { diff --git a/lily/include/note-spacing.hh b/lily/include/note-spacing.hh index 945362ab06..b8788f92ff 100644 --- a/lily/include/note-spacing.hh +++ b/lily/include/note-spacing.hh @@ -31,7 +31,7 @@ public: static Spring get_spacing (Grob *me, Item *, Spring, Real); static void stem_dir_correction (Grob *me, Item *next_col, Real incr, - Real *, Real *); + Real *space); }; #endif /* NOTE_SPACING_HH */ diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index e59aa6ec84..4f5713c14a 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -35,10 +35,6 @@ #include "stem.hh" #include "warn.hh" -/* - TODO: detect hshifts due to collisions, and account for them in - spacing? -*/ /* Adjust the ideal and minimum distance between note columns, based on the notehead size, skylines, and optical illusions. @@ -76,16 +72,11 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, The main factor that determines the amount of space is the width of the note head (or the rest). For example, a quarter rest gets almost 0.5 ss less horizontal space than a note. - - The other parts of a note column (eg. flags, accidentals, etc.) don't get - the full amount of space. We give them half the amount of space, but then - adjust things so there are no collisions. */ Real ideal = base.distance () - increment + left_head_end; Drul_array skys = Spacing_interface::skylines (me, right_col); Real distance = skys[LEFT].distance (skys[RIGHT], robust_scm2double (right_col->get_property ("skyline-vertical-padding"), 0.0)); Real min_dist = max (0.0, distance); - Real min_desired_space = (ideal + min_dist) / 2; base.set_min_distance (min_dist); /* If we have a NonMusical column on the right, we measure the ideal distance @@ -99,20 +90,20 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, Bar_line::non_empty_barline); if (bar) + ideal -= bar->extent (right_col, X_AXIS)[LEFT]; + else { - Real shift = bar->extent (right_col, X_AXIS)[LEFT]; - ideal -= shift; - min_desired_space -= max (shift, 0.0); + /* Measure ideal distance to the right side of the NonMusical column + but keep at least half the gap we would have had to a note */ + Real min_desired_space = (ideal + min_dist) / 2.0; + ideal -= right_col->extent (right_col, X_AXIS)[RIGHT]; + ideal = max (ideal, min_desired_space); } - else - ideal -= right_col->extent (right_col, X_AXIS)[RIGHT]; } - ideal = max (ideal, min_desired_space); - stem_dir_correction (me, right_col, increment, &ideal, &min_desired_space); + stem_dir_correction (me, right_col, increment, &ideal); base.set_distance (max (0.0, ideal)); - base.set_inverse_compress_strength (max (0.0, ideal - min_desired_space)); return base; } @@ -207,7 +198,7 @@ same_direction_correction (Grob *note_spacing, Drul_array head_posns) void Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, Real increment, - Real *space, Real *fixed) + Real *space) { Drul_array stem_dirs (CENTER, CENTER); Drul_array stem_posns; @@ -311,7 +302,6 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, && !acc_right) correction = same_direction_correction (me, head_posns); - *fixed += correction; *space += correction; /* there used to be a correction for bar_xextent () here, but