X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fnote-spacing.cc;h=ffb9d7c40ed28cecf85749e76afbce628c7ab6a2;hb=fc273c71061c4859cebc95bb91d86c9373d94f64;hp=139521b15eb7ac2382e97dbd5be79f897b8fe330;hpb=a92cc48aa85e1ae538175bb3bc917fc17f5c9fe1;p=lilypond.git diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 139521b15e..ffb9d7c40e 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -8,6 +8,7 @@ #include "note-spacing.hh" +#include "bar-line.hh" #include "directional-element-interface.hh" #include "grob-array.hh" #include "paper-column.hh" @@ -68,21 +69,36 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, Drul_array skys = Spacing_interface::skylines (me, right_col); Real distance = skys[LEFT].distance (skys[RIGHT]); Real min_dist = max (0.0, distance); - Real min_desired_space = left_head_end + (min_dist - left_head_end) / 2; - Real ideal = max (base_space - increment + left_head_end, min_desired_space); + Real min_desired_space = left_head_end + (min_dist - left_head_end + base_space - increment) / 2; + Real ideal = base_space - increment + left_head_end; + + /* 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 () + && to_boolean (me->get_property ("space-to-barline"))) + { + Grob *bar = Pointer_group_interface::find_grob (right_col, + ly_symbol2scm ("elements"), + Bar_line::has_interface); - /* If the NonMusicalPaperColumn on the right sticks out a lot, ensure that - the amount of whitespace between the end of the note-head and that column is - (base_spacing - increment) (without this line, this would be the distance, - not the whitespace) - */ - if (!Paper_column::is_musical (right_col)) - ideal = max (ideal, base_space - increment + distance); + if (bar) + { + Real shift = bar->extent (right_col, X_AXIS)[LEFT]; + ideal -= shift; + min_desired_space -= max (shift, 0.0); + } + 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); - Spring ret (ideal, min_dist); - ret.set_inverse_compress_strength (max (0.0, ideal - max (min_dist, 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)); return ret; } @@ -209,6 +225,8 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, for (vsize i = 0; i < items.size (); i++) { Item *it = dynamic_cast (items[i]); + if (!Note_column::has_interface (it)) + continue; /* don't correct if accidentals are sticking out of the right side. @@ -301,6 +319,7 @@ ADD_INTERFACE (Note_spacing, "right-items " "same-direction-correction " "stem-spacing-correction " + "space-to-barline " );