]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spacing-loose-columns.cc
* lily/tie-engraver.cc (struct Head_event_tuple): store both
[lilypond.git] / lily / spacing-loose-columns.cc
index bae5e99de15aac014aadfa1a50349a5e7c1eb7e5..13a37071c04e69af72df52a1b5f2439241f5085e 100644 (file)
@@ -13,7 +13,7 @@
 #include "staff-spacing.hh"
 #include "note-spacing.hh"
 #include "spacing-spanner.hh"
-
+#include "warn.hh"
 #include "moment.hh"
 
 /* Find the loose columns in POSNS, and drape them around the columns
@@ -79,7 +79,7 @@ set_loose_columns (System *which, Column_x_positions const *posns)
          Grob *clique_col = clique[j];
 
          Paper_column *loose_col = dynamic_cast<Paper_column *> (clique[j]);
-         Paper_column *last_col = dynamic_cast<Paper_column *> (clique[j-1]);
+         Paper_column *next_col = dynamic_cast<Paper_column *> (clique[j + 1]);
 
          Grob *spacing = unsmob_grob (clique_col->get_object ("spacing"));
          if (Grob *grace_spacing = unsmob_grob (clique_col->get_object ("grace-spacing")))
@@ -88,29 +88,33 @@ set_loose_columns (System *which, Column_x_positions const *posns)
            }
          
          Spacing_options options;
-         options.init_from_grob (spacing);
+         if (spacing)
+           options.init_from_grob (spacing);
+         else
+           programming_error ("Column without spacing object");
 
          bool expand_only = false;
          Real base_note_space = 0.0;
 
-         if (Paper_column::is_musical (last_col)
+         if (Paper_column::is_musical (next_col)
              && Paper_column::is_musical (loose_col))
-           base_note_space = Spacing_spanner::note_spacing (spacing, last_col, loose_col,
+           base_note_space = Spacing_spanner::note_spacing (spacing, loose_col, next_col, 
                                                             &options, &expand_only);
          else
            {
              Real fixed, space;
              
-             Spacing_spanner::standard_breakable_column_spacing (spacing, last_col,
-                                                                 loose_col, &fixed, &space,
+             Spacing_spanner::standard_breakable_column_spacing (spacing, 
+                                                                 loose_col, next_col,
+                                                                 &fixed, &space,
                                                                  &options);
 
              base_note_space = space;
            }
 
          base_note_space = max (base_note_space,
-                                robust_relative_extent (last_col, last_col, X_AXIS)[RIGHT]
-                                - robust_relative_extent (loose_col, loose_col, X_AXIS)[LEFT]);
+                                robust_relative_extent (loose_col, loose_col, X_AXIS)[RIGHT]
+                                - robust_relative_extent (next_col, next_col, X_AXIS)[LEFT]);
          
          clique_spacing.push_back (base_note_space);
        }