From a92cc48aa85e1ae538175bb3bc917fc17f5c9fe1 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Sun, 5 Aug 2007 17:31:54 +1000 Subject: [PATCH] Tweaks to Note_spacing. --- lily/note-spacing.cc | 16 +++++++++------- lily/spacing-interface.cc | 27 ++++++++++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 88c459240f..139521b15e 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -66,16 +66,18 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, adjust things so there are no collisions. */ Drul_array skys = Spacing_interface::skylines (me, right_col); - Real min_dist = max (0.0, skys[LEFT].distance (skys[RIGHT])); + 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); - /* if the right object sticks out a lot, include a bit of extra space. - But only for non-musical-columns; this shouldn't apply to accidentals */ + /* 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)) - min_desired_space = max (min_desired_space, - left_head_end + LEFT * skys[RIGHT].max_height ()); - - Real ideal = base_space - increment + min_desired_space; + ideal = max (ideal, base_space - increment + distance); stem_dir_correction (me, right_col, increment, &ideal, &min_desired_space); diff --git a/lily/spacing-interface.cc b/lily/spacing-interface.cc index 93bd1c2cfa..8d1e0b036a 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); + Real shift = g->pure_relative_y_coordinate (system, 0, INT_MAX); + Real raise = g->relative_coordinate (columns[d], X_AXIS); + + skylines[d].shift (-shift); + skylines[d].raise (-raise); + 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); + skylines[d].raise (raise); } } } -- 2.39.2