X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fspacing-interface.cc;h=2033cfcac43898dfc6b68e3dbb87d6aca6847501;hb=227a1e46f9141ec80829a432f78edbdab8a39c48;hp=93bd1c2cfaf0549de703ef1892748916729b818e;hpb=a93cdac09beaeb940a1776a5177fb823d1fa8337;p=lilypond.git diff --git a/lily/spacing-interface.cc b/lily/spacing-interface.cc index 93bd1c2cfa..2033cfcac4 100644 --- a/lily/spacing-interface.cc +++ b/lily/spacing-interface.cc @@ -17,6 +17,7 @@ #include "paper-column.hh" #include "separation-item.hh" #include "skyline.hh" +#include "system.hh" /* return the right-pointing skyline of the left-items and the left-pointing skyline of the right-items (with the skyline of the left-items in @@ -38,29 +39,41 @@ Spacing_interface::skylines (Grob *me, Grob *right_col) Drul_array > items (ly_scm2link_array (orig->get_object ("left-items")), ly_scm2link_array (orig->get_object ("right-items"))); + Grob *system = me->get_system (); + Grob *left_col = dynamic_cast (me)->get_column (); + + Drul_array columns (left_col, right_col); + Direction d = LEFT; do { - skylines[d].set_minimum_height (0.0); - for (vsize i = 0; i < items[d].size (); i++) { - Grob *g = items[d][i]; - if (Item *it = dynamic_cast (g)) - if (Grob *piece = it->find_prebroken_piece (break_dirs[d])) + Item *g = dynamic_cast (items[d][i]); + if (g) + if (Item *piece = g->find_prebroken_piece (break_dirs[d])) g = piece; - if (Separation_item::has_interface (g)) + if (g && Separation_item::has_interface (g) && g->get_column () == columns[d]) { SCM sky_scm = g->get_property ("horizontal-skylines"); Skyline_pair *sky = Skyline_pair::unsmob (sky_scm); + + extract_grob_set (g, "elements", elts); + Grob *ycommon = common_refpoint_of_array (elts, g, Y_AXIS); + Real shift = ycommon->pure_relative_y_coordinate (system, 0, INT_MAX); + + skylines[d].shift (-shift); + if (sky) skylines[d].merge ((*sky)[-d]); else programming_error ("separation item has no skyline"); - + if (d == RIGHT && items[LEFT].size ()) skylines[d].merge (Separation_item::conditional_skyline (items[d][i], items[LEFT][0])); + + skylines[d].shift (shift); } } } @@ -83,6 +96,15 @@ Spacing_interface::minimum_distance (Grob *me, Grob *right) this will add a new column to RIGHT-ITEMS. Here we look at the columns, and return the left-most. If there are multiple columns, we prune RIGHT-ITEMS. + + If we end up pruning, we add a left-neighbor to every column that + gets pruned. This ensures that loose columns in cross-staff music + do indeed get marked as loose. The problem situation is when a voice + passes from staff 1 to staff 2 and a clef appears later on in staff 1. + Then the NoteSpacing attached to the last note in staff 1 has two + right-items: one pointing to the next note in staff 2 and one pointing + to the clef. We will prune the clef right-item here and, unless we add + a left-neighbor to the clef, it won't get marked as loose. */ Item * Spacing_interface::right_column (Grob *me) @@ -109,6 +131,8 @@ Spacing_interface::right_column (Grob *me) mincol = col; } + else if (rank > min_rank) + prune = true; } if (prune && a) @@ -117,7 +141,15 @@ Spacing_interface::right_column (Grob *me) for (vsize i = right.size (); i--;) { if (dynamic_cast (right[i])->get_column () != mincol) - right.erase (right.begin () + i); + { + extract_grob_set (right[i], "left-neighbors", lns); + if (lns.empty ()) + Pointer_group_interface::add_grob (right[i], + ly_symbol2scm ("left-neighbors"), + dynamic_cast (me)->get_column ()); + + right.erase (right.begin () + i); + } } } @@ -215,8 +247,10 @@ Spacing_interface::extremal_break_aligned_grob (Grob *me, ADD_INTERFACE (Spacing_interface, - "This object calculates the desired and minimum distances between two columns.", + "This object calculates the desired and minimum distances" + " between two columns.", + /* properties */ "left-items " "right-items " );