]> git.donarmstrong.com Git - lilypond.git/commitdiff
Take measure length from left command column. Fixes #168
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 5 Dec 2006 15:15:11 +0000 (16:15 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 5 Dec 2006 15:15:11 +0000 (16:15 +0100)
Put Spacing_options in separate header.

input/regression/spacing-measure-length.ly [new file with mode: 0644]
lily/include/lily-proto.hh
lily/include/spacing-options.hh [new file with mode: 0644]
lily/include/spacing-spanner.hh
lily/spacing-basic.cc
lily/spacing-determine-loose-columns.cc
lily/spacing-loose-columns.cc
lily/spacing-options.cc
lily/spacing-spanner.cc
lily/system.cc

diff --git a/input/regression/spacing-measure-length.ly b/input/regression/spacing-measure-length.ly
new file mode 100644 (file)
index 0000000..848f278
--- /dev/null
@@ -0,0 +1,26 @@
+\header {
+
+  texidoc = "Horizontal spacing is bounded by of the current measure length.
+This means that the 3/8 setting does not affect the whole rest spacing." 
+
+}
+
+
+\version "2.11.1"
+
+\layout {
+  ragged-right = ##t
+}
+
+\score {
+  \new Staff \with {
+    \remove Separating_line_group_engraver
+  } {
+    \relative c' {
+      \override Score.SpacingSpanner #'uniform-stretching = ##t
+      \set Score.proportionalNotationDuration = #(ly:make-moment 4 25)
+      r1
+      \time 3/8 r4.
+    }
+  }
+} 
index 58e7cb4c84d897eea7440752a686d366c9dd636a..c3082aaddd429231183583e2b9cd009925b300e5 100644 (file)
@@ -150,6 +150,7 @@ class Simultaneous_music_iterator;
 class Skyline_entry;
 class Slur_configuration;
 class Slur_score_state;
+class Spacing_options;
 class Span_score_bar_engraver;
 class Spanner;
 class Staff_group_bar_engraver;
diff --git a/lily/include/spacing-options.hh b/lily/include/spacing-options.hh
new file mode 100644 (file)
index 0000000..faebb55
--- /dev/null
@@ -0,0 +1,30 @@
+/* 
+  spacing-options.hh -- declare Spacing_options
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2006 Han-Wen Nienhuys <hanwen@lilypond.org>
+  
+*/
+
+#ifndef SPACING_OPTIONS_HH
+#define SPACING_OPTIONS_HH
+
+#include "lily-proto.hh"
+#include "rational.hh"
+
+struct Spacing_options
+{
+  bool packed_;
+  bool stretch_uniformly_;
+  bool float_nonmusical_columns_;
+  bool float_grace_columns_;
+  Rational global_shortest_;
+  Real increment_;
+  Real shortest_duration_space_;
+
+  Spacing_options();
+  void init_from_grob (Grob *me);
+  Real get_duration_space (Rational d, bool *) const;
+};
+#endif /* SPACING_OPTIONS_HH */
index b1d760c4413ef1a04857baf5f58720aa733edea9..3dace37510894ae0154fe1c0c2b908a78f0c762f 100644 (file)
 #include "std-vector.hh"
 #include "grob-interface.hh"
 
-struct Spacing_options
-{
-  bool packed_;
-  bool stretch_uniformly_;
-  bool float_nonmusical_columns_;
-  bool float_grace_columns_;
-  Rational global_shortest_;
-  Real increment_;
-  Real shortest_duration_space_;
-
-  Spacing_options();
-  void init_from_grob (Grob *me);
-  Real get_duration_space (Rational d, bool *) const;
-};
-
 /*
   TODO: prune to public interface.
 */
index fcae3dfcc2d707aee0463aa3814a7004bbb12ab0..2e81fdf416237d2569dcedd1f94960cb91e02bba 100644 (file)
@@ -7,9 +7,13 @@
 */
 
 #include "spacing-spanner.hh"
+
+#include "spacing-options.hh"
 #include "moment.hh"
 #include "paper-column.hh"
 #include "warn.hh"
+#include "pointer-group-interface.hh"
+#include "system.hh"
 
 /*
   LilyPond spaces by taking a simple-minded spacing algorithm, and
@@ -75,6 +79,34 @@ Spacing_spanner::standard_breakable_column_spacing (Grob *me, Item *l, Item *r,
     }
 }
 
+Moment *
+get_measure_length (Grob *column)
+{
+  Grob * sys = column->get_parent (X_AXIS);
+
+  extract_grob_set (sys, "columns", cols);
+
+  vsize col_idx = binary_search (cols, column,
+                                Paper_column::less_than);
+
+  if (col_idx == VPOS)
+    {
+      programming_error ( __FUNCTION__ + string (": Unknown column"));
+      return 0;
+    }
+  
+  do
+    {
+      if (Moment *len = unsmob_moment (cols[col_idx]->get_property ("measure-length")))
+       {
+         return len;
+       }
+    }
+  while (col_idx-- != 0);
+  
+  return 0;
+}
+
 Real
 Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc,
                               Spacing_options const *options,
@@ -106,7 +138,7 @@ Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc,
        several measures.
       */
 
-      Moment *dt = unsmob_moment (rc->get_property ("measure-length"));
+      Moment *dt = get_measure_length (lc);
       if (dt)
        {
          delta_t = min (delta_t, *dt);
index 37fe47f8d5bb30945830d3435cd9b0faa9bd1620..fe5a89c80bc3f0193a42422eb14bbec43577c352 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "staff-spacing.hh"
 
+#include "spacing-options.hh"
 #include "system.hh"
 #include "paper-column.hh"
 #include "column-x-positions.hh"
index 13a37071c04e69af72df52a1b5f2439241f5085e..94bc552e6f799ed47c3b8d9ad9b8668077ea6c43 100644 (file)
@@ -15,6 +15,7 @@
 #include "spacing-spanner.hh"
 #include "warn.hh"
 #include "moment.hh"
+#include "spacing-options.hh"
 
 /* Find the loose columns in POSNS, and drape them around the columns
    specified in BETWEEN-COLS.  */
index 916408aa7335af66d84c2d52ee15046a251b6ff9..c0e11fa62cf7a074a1e059d99ac1e0cd2d0a55bf 100644 (file)
@@ -7,7 +7,7 @@
 
 */
 
-#include "spacing-spanner.hh"
+#include "spacing-options.hh"
 #include "grob.hh"
 #include "misc.hh"
 #include "moment.hh"
index 2e174b65c22293dbe74d3b9c6a51fdbb655f1c67..31f7df6c8e72fba6e118f9dd2e0f4bf945cbe109 100644 (file)
 
 #include <math.h>
 #include <cstdio>
+
 using namespace std;
 
+#include "spacing-options.hh"
 #include "international.hh"
 #include "main.hh"
 #include "moment.hh"
index 3451ec6de1859b30f484f4748aa8616e98b9bcf5..c53099257f91110d63acdf5c9f2036a9b6aa97ea 100644 (file)
@@ -466,6 +466,7 @@ System::broken_col_range (Item const *left, Item const *right) const
   return ret;
 }
 
+
 /** Return all columns, but filter out any unused columns , since they might
     disrupt the spacing problem. */
 vector<Grob*>