]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-spanner.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / spacing-spanner.cc
index 39638ff007cfd28199893f3580c568068a566946..4c301b6a648ff2cd293e8237b201695863d669cc 100644 (file)
@@ -35,7 +35,7 @@ using namespace std;
 */
 Rational
 Spacing_spanner::effective_shortest_duration (Grob *me,
-                                             Link_array__Grob_ const &all)
+                                             vector<Grob*> const &all)
 {
   SCM preset_shortest = me->get_property ("common-shortest-duration");
   Rational global_shortest;
@@ -61,7 +61,7 @@ Spacing_spanner::set_springs (SCM smob)
   /*
     can't use get_system() ? --hwn.
   */
-  Link_array__Grob_ all (get_root_system (me)->columns ());
+  vector<Grob*> all (get_root_system (me)->columns ());
 
   set_explicit_neighbor_columns (all);
 
@@ -86,13 +86,13 @@ Spacing_spanner::set_springs (SCM smob)
   stuff, then.
 */
 Rational
-Spacing_spanner::find_shortest (Grob *me, Link_array__Grob_ const &cols)
+Spacing_spanner::find_shortest (Grob *me, vector<Grob*> const &cols)
 {
   /*
     ascending in duration
   */
-  std::vector<Rational> durations;
-  std::vector<int> counts;
+  vector<Rational> durations;
+  vector<int> counts;
 
   Rational shortest_in_measure;
   shortest_in_measure.set_infinite (1);
@@ -115,7 +115,7 @@ Spacing_spanner::find_shortest (Grob *me, Link_array__Grob_ const &cols)
          shortest_in_measure = min (shortest_in_measure, this_shortest.main_part_);
        }
       else if (!shortest_in_measure.is_infinity ()
-              && Item::is_breakable (cols[i]))
+              && Paper_column::is_breakable (cols[i]))
        {
          vsize j = 0;
          for (; j < durations.size (); j++)
@@ -225,19 +225,19 @@ Spacing_spanner::generate_pair_spacing (Grob *me,
 
 void
 Spacing_spanner::generate_springs (Grob *me,
-                                  Link_array__Grob_ const &cols,
+                                  vector<Grob*> const &cols,
                                   Spacing_options const *options)
 {
-  Paper_column *next = 0;
-  Paper_column *next_next = 0;
-  for (vsize i = cols.size (); i--;)
+  Paper_column *prev = 0;
+  for (vsize i = 0; i < cols.size (); i++)
     {
       Paper_column *col = dynamic_cast<Paper_column *> (cols[i]);
-      if (next)
-       generate_pair_spacing (me, col, next, next_next, options);
+      Paper_column *next = (i < cols.size()-1) ? dynamic_cast<Paper_column *> (cols[i+1]) : 0;
+      
+      if (i > 0)
+       generate_pair_spacing (me, prev, col, next, options);
 
-      next_next = next;
-      next = col;
+      prev = col;
     }
 }
 
@@ -260,7 +260,20 @@ Spacing_spanner::musical_column_spacing (Grob *me,
   Real compound_fixed_note_space = 0.0;
 
   if (options->stretch_uniformly_)
-    compound_note_space = base_note_space;
+    {
+      compound_note_space = base_note_space;
+            
+      if (!Paper_column::is_musical (right_col))
+       {
+         /*
+           Crude fix for notes that lead up to barlines and time sigs.
+         */
+         Interval lext = right_col->extent (right_col, X_AXIS);
+         if (!lext.is_empty ())
+           compound_note_space += -lext[LEFT];
+       }
+      
+    }
   else
     {
       int wish_count = 0;