From d4207e548f637fae12ec3df140d0f190dd422154 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Mon, 6 Aug 2007 13:17:21 +1000 Subject: [PATCH] Tweak spacing between a musical and a non-musical column. --- lily/include/pointer-group-interface.hh | 1 + lily/note-spacing.cc | 22 ++++++++++++++-------- lily/pointer-group-interface.cc | 12 ++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lily/include/pointer-group-interface.hh b/lily/include/pointer-group-interface.hh index d1c7d0e7c4..581d635299 100644 --- a/lily/include/pointer-group-interface.hh +++ b/lily/include/pointer-group-interface.hh @@ -22,6 +22,7 @@ public: static void add_unordered_grob (Grob *, SCM nm, Grob *); static void set_ordered (Grob *, SCM, bool); static Grob_array *get_grob_array (Grob*, SCM); + static Grob *find_grob (Grob*, SCM, bool (*pred) (Grob*)); }; vector const &internal_extract_grob_array (Grob const *elt, SCM symbol); diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 139521b15e..af8fb0d6e0 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" @@ -69,16 +70,21 @@ Note_spacing::get_spacing (Grob *me, Item *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 ideal = base_space - increment + left_head_end; - /* 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 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 ()) + { + Grob *bar = Pointer_group_interface::find_grob (right_col, + ly_symbol2scm ("elements"), + Bar_line::has_interface); + + if (bar) + ideal -= bar->extent (right_col, X_AXIS)[LEFT]; + } + ideal = max (ideal, min_desired_space); stem_dir_correction (me, right_col, increment, &ideal, &min_desired_space); Spring ret (ideal, min_dist); diff --git a/lily/pointer-group-interface.cc b/lily/pointer-group-interface.cc index d1302391e4..08af94839d 100644 --- a/lily/pointer-group-interface.cc +++ b/lily/pointer-group-interface.cc @@ -45,6 +45,18 @@ Pointer_group_interface::get_grob_array (Grob *me, SCM sym) return arr; } +Grob * +Pointer_group_interface::find_grob (Grob *me, SCM sym, bool (*pred) (Grob*)) +{ + Grob_array *arr = get_grob_array (me, sym); + + for (vsize i = 0; i < arr->size (); i++) + if (pred (arr->grob (i))) + return arr->grob (i); + + return 0; +} + void Pointer_group_interface::add_grob (Grob *me, SCM sym, Grob *p) { -- 2.39.5