X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fnote-spacing.cc;h=bd796a71354f5d2376164781befe70a7f852a5cd;hb=414e6ba6630d111217f0887ae3bb203a44506ddb;hp=93be9228e2f90ff06a5ec84eee17e2aa4509c471;hpb=5b22a25acdddcefdb982e413b4b82eb4cee7b4d8;p=lilypond.git diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 93be9228e2..bd796a7135 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 2001--2007 Han-Wen Nienhuys + (c) 2001--2009 Han-Wen Nienhuys */ #include "note-spacing.hh" @@ -23,6 +23,12 @@ #include "output-def.hh" #include "pointer-group-interface.hh" +static bool +non_empty_barline (Grob *me) +{ + return Bar_line::has_interface (me) && !me->extent (me, X_AXIS).is_empty (); +} + /* TODO: detect hshifts due to collisions, and account for them in spacing? @@ -74,11 +80,13 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, /* If we have a NonMusical column on the right, we measure the ideal distance to the bar-line (if present), not the start of the column. */ - if (!Paper_column::is_musical (right_col) && !skys[RIGHT].is_empty ()) + if (!Paper_column::is_musical (right_col) + && !skys[RIGHT].is_empty () + && to_boolean (me->get_property ("space-to-barline"))) { Grob *bar = Pointer_group_interface::find_grob (right_col, ly_symbol2scm ("elements"), - Bar_line::has_interface); + non_empty_barline); if (bar) { @@ -93,6 +101,8 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, ideal = max (ideal, min_desired_space); stem_dir_correction (me, right_col, increment, &ideal, &min_desired_space); + /* TODO: grace notes look bad when things are stretched. Should we increase + their stretch strength? */ Spring ret (max (0.0, ideal), min_dist); ret.set_inverse_compress_strength (max (0.0, ideal - min_desired_space)); ret.set_inverse_stretch_strength (max (0.1, base_space - increment)); @@ -181,7 +191,7 @@ same_direction_correction (Grob *note_spacing, Drul_array head_posns) } -/** +/* Correct for optical illusions. See [Wanske] p. 138. The combination up-stem + down-stem should get extra space, the combination down-stem + up-stem less. @@ -209,6 +219,8 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, Direction d = LEFT; + bool acc_right = false; + Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT, rcolumn->break_status_dir (), &bar_xextent); @@ -225,10 +237,10 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, continue; /* - don't correct if accidentals are sticking out of the right side. + Find accidentals which are sticking out of the right side. */ - if (d == RIGHT && Note_column::accidentals (it)) - return; + if (d == RIGHT) + acc_right = acc_right || Note_column::accidentals (it); Grob *stem = Note_column::get_stem (it); @@ -296,7 +308,12 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, correction *= 0.5; } } - else if (stem_dirs[LEFT] * stem_dirs[RIGHT] == 1) + /* + Only apply same direction correction if there are no + accidentals sticking out of the right hand side. + */ + else if (stem_dirs[LEFT] * stem_dirs[RIGHT] == 1 + && !acc_right) correction = same_direction_correction (me, head_posns); *space += correction; @@ -309,12 +326,12 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, ADD_INTERFACE (Note_spacing, "This object calculates spacing wishes for individual voices.", - + /* properties */ "knee-spacing-correction " "left-items " "right-items " "same-direction-correction " "stem-spacing-correction " - + "space-to-barline " );