]> git.donarmstrong.com Git - lilypond.git/commitdiff
Tweak spacing between a musical and a non-musical column.
authorJoe Neeman <joeneeman@gmail.com>
Mon, 6 Aug 2007 03:17:21 +0000 (13:17 +1000)
committerJoe Neeman <joeneeman@gmail.com>
Mon, 6 Aug 2007 03:17:21 +0000 (13:17 +1000)
lily/include/pointer-group-interface.hh
lily/note-spacing.cc
lily/pointer-group-interface.cc

index d1c7d0e7c44c2e7ba3918e2707d31af2a3c4294a..581d63529904848f889a756f6aea73e29ffb96c9 100644 (file)
@@ -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<Grob*> const &internal_extract_grob_array (Grob const *elt, SCM symbol);
index 139521b15eb7ac2382e97dbd5be79f897b8fe330..af8fb0d6e09f3aff39c97950278f75722a06653d 100644 (file)
@@ -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);
index d1302391e477983a49aed12317f03569a04ef5ae..08af94839d443930a0f7e26240f9038745a2aa1b 100644 (file)
@@ -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)
 {