]> git.donarmstrong.com Git - lilypond.git/commitdiff
Notes or rests that fill an entire measure are preceded by some more space.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 7 Jan 2007 17:03:15 +0000 (18:03 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 7 Jan 2007 17:03:15 +0000 (18:03 +0100)
12 files changed:
input/regression/spacing-bar-whole-measure.ly [new file with mode: 0644]
lily/constrained-breaking.cc
lily/include/spacing-options.hh
lily/include/spacing-spanner.hh
lily/include/system.hh
lily/page-breaking.cc
lily/paper-column.cc
lily/paper-score.cc
lily/spacing-determine-loose-columns.cc
lily/spacing-options.cc
lily/spacing-spanner.cc
lily/system.cc

diff --git a/input/regression/spacing-bar-whole-measure.ly b/input/regression/spacing-bar-whole-measure.ly
new file mode 100644 (file)
index 0000000..e2cb1d9
--- /dev/null
@@ -0,0 +1,21 @@
+\header{
+  texidoc = "Notes that fill a whole measure are preceded by extra space. "
+  
+  }
+
+\version "2.11.10"
+
+\layout{
+  ragged-right=##t
+}
+
+\new Staff \relative {
+  \override Score.NonMusicalPaperColumn #'stencil = #ly:paper-column::print
+  \override Score.NonMusicalPaperColumn #'layer = #1
+  
+  \time 4/4
+  s1
+  c2. c4
+  \time 3/4
+  c2.
+}
index cbc22cfc05e8e4d49ee795f88ceae68b61c6704d..1a03c6b32402b6adcdcf51c04b6094f5c950d529 100644 (file)
@@ -329,7 +329,7 @@ Constrained_breaking::initialize ()
   Interval other_lines = line_dimensions_int (pscore_->layout (), 1);
   /* do all the rod/spring problems */
   breaks_ = pscore_->find_break_indices ();
-  all_ = pscore_->root_system ()->columns ();
+  all_ = pscore_->root_system ()->used_columns ();
   lines_.resize (breaks_.size (), breaks_.size (), Line_details ());
   vector<Real> forces = get_line_forces (all_,
                                         other_lines.length (),
index faebb55489e7d2eb0ba934c84d7c64ca3d7e41db..1b5ee32db09e49170f533713927f47bb1ffd3aee 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "lily-proto.hh"
 #include "rational.hh"
+#include "std-vector.hh"
 
 struct Spacing_options
 {
@@ -22,7 +23,8 @@ struct Spacing_options
   Rational global_shortest_;
   Real increment_;
   Real shortest_duration_space_;
-
+  vector<Grob*> columns_;
+  
   Spacing_options();
   void init_from_grob (Grob *me);
   Real get_duration_space (Rational d, bool *) const;
index 6a27eb158b7ae57e4123c27b3cdbc92d1ba185c6..6723dfefbfed25bb6c9b6790cb1f0091966c5992 100644 (file)
@@ -26,14 +26,14 @@ private:
   static Real get_duration_space (Moment dur, Spacing_options const *, bool *);
   static Rational effective_shortest_duration (Grob *me, vector<Grob*> const &all);
   static void breakable_column_spacing (Grob *, Item *l, Item *r, Spacing_options const *);
-  static void prune_loose_columns (Grob *, vector<Grob*> *cols, Spacing_options const *);
+  static void prune_loose_columns (Grob *, Spacing_options  *);
   static void set_explicit_neighbor_columns (vector<Grob*> const &cols);
   static void set_implicit_neighbor_columns (vector<Grob*> const &cols);
-  static void generate_springs (Grob *me, vector<Grob*> const &cols, Spacing_options const *);
+  static void generate_springs (Grob *me, Spacing_options const *);
   static void musical_column_spacing (Grob *, Item *, Item *, Spacing_options const *);
-  static vector<Grob*> get_columns (Spanner *me);
-  
+  static bool fills_measure (Grob *, Item *, Item *);
 public:
+  static vector<Grob*> get_columns (Grob *me);
   static Real note_spacing (Grob *, Grob *, Grob *, Spacing_options const *, bool *);
   static void standard_breakable_column_spacing (Grob *me, Item *l, Item *r,
                                                 Real *fixed, Real *space,
index 44bb21d516879af9b452cfb689cb1df605d464df..597b3204fc7c447b4699d39c563c9ece0270a42c 100644 (file)
@@ -44,8 +44,8 @@ public:
   DECLARE_GROB_INTERFACE();
 
   vector<Item*> broken_col_range (Item const *, Item const *) const;
-  vector<Grob*> columns () const;
-  Grob *column (int i) const;
+  vector<Grob*> used_columns () const;
+  Grob *column (vsize i) const;
 
   void add_column (Paper_column *);
   void typeset_grob (Grob *);
index b43c302367053bf5418ea7f77db00530f2cf2fcc..76cecc03c39fce34f590b036f21b3cf5d409efce 100644 (file)
@@ -255,7 +255,7 @@ Page_breaking::find_chunks_and_breaks (Break_predicate is_break)
     {
       if (all_[i].pscore_)
        {
-         vector<Grob*> cols = all_[i].pscore_->root_system ()->columns ();
+         vector<Grob*> cols = all_[i].pscore_->root_system ()->used_columns ();
          vector<vsize> line_breaker_columns;
          line_breaker_columns.push_back (0);
 
index 7d5009b957ef30115e6a223cb1add52b1006d6e8..e42a3417e22001df09314c455a52695f7a877bfb 100644 (file)
@@ -167,7 +167,6 @@ Paper_column::print (SCM p)
   Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01),
                                       Interval (-2, -1)));
   
-  System * my_system = me->get_system ();
   SCM small_letters = scm_cons (scm_acons (ly_symbol2scm ("font-size"),
                                           scm_from_int (-6), SCM_EOL),
                                properties);
index 047e880f3c1fc085ce2899f1efd65c03fc842b51..f299e56e8e74f04241ea7ae3d686706e29224e7a 100644 (file)
@@ -62,7 +62,7 @@ Paper_score::typeset_system (System *system)
 vector<vsize>
 Paper_score::find_break_indices () const
 {
-  vector<Grob*> all = root_system ()->columns ();
+  vector<Grob*> all = root_system ()->used_columns ();
   vector<vsize> retval;
 
   for (vsize i = 0; i < all.size (); i++)
@@ -125,7 +125,7 @@ Paper_score::process ()
      down the road.
 
      doubly, also done in Score_engraver */
-  vector<Grob*> pc (system_->columns ());
+  vector<Grob*> pc (system_->used_columns ());
   pc[0]->set_property ("line-break-permission", ly_symbol2scm ("allow"));
   pc.back ()->set_property ("line-break-permission", ly_symbol2scm ("allow"));
 
index 052e0d766bf441c64d1d7c71ec0c539be3864c9c..11e9caa18d5ced03ef77fc2b2fa335c839236cda 100644 (file)
@@ -194,9 +194,9 @@ Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c,
   between.
 */
 void
-Spacing_spanner::prune_loose_columns (Grob *me, vector<Grob*> *cols,
-                                     Spacing_options const *options)
-{
+Spacing_spanner::prune_loose_columns (Grob *me, Spacing_options *options)
+ {
+  vector<Grob*> *cols = &options->columns_;  
   vector<Grob*> newcols;
 
   for (vsize i = 0; i < cols->size (); i++)
index c0e11fa62cf7a074a1e059d99ac1e0cd2d0a55bf..9a73ad6d7f70abd51e00cd5e2031a6239c52d3c7 100644 (file)
@@ -8,9 +8,11 @@
 */
 
 #include "spacing-options.hh"
+#include "spacing-spanner.hh"
 #include "grob.hh"
 #include "misc.hh"
 #include "moment.hh"
+#include "spanner.hh"
 
 void
 Spacing_options::init_from_grob (Grob *me)
@@ -34,6 +36,7 @@ Spacing_options::init_from_grob (Grob *me)
   else
     global_shortest_ = shortest_dur.grace_part_;
 
+  columns_ = Spacing_spanner::get_columns (me);        // ugh.
 }
 
 Spacing_options::Spacing_options ()
index 497474d7d1f242d378f8aefe8a92135c457c2e11..fb91f0b0102b4c7e0432e0ffde48cb57e62e7eb4 100644 (file)
@@ -29,14 +29,15 @@ using namespace std;
 #include "warn.hh"
 
 vector<Grob*>
-Spacing_spanner::get_columns (Spanner *me)
+Spacing_spanner::get_columns (Grob *me_grob)
 {
-  vector<Grob*> all (get_root_system (me)->columns ());
+  Spanner *me = dynamic_cast<Spanner*> (me_grob);
+  vector<Grob*> all (get_root_system (me)->used_columns ());
   vsize start = binary_search (all, (Grob*)me->get_bound (LEFT),
                               &Paper_column::less_than);
   vsize end = binary_search (all, (Grob*) me->get_bound (RIGHT),
-                            &Paper_column::less_than);
-
+                            &Paper_column::less_than);  
+  
   all = vector<Grob*>::vector<Grob*> (all.begin () + start,
                                      all.begin () + end + 1);
   return all;
@@ -51,15 +52,14 @@ Spacing_spanner::set_springs (SCM smob)
   /*
     can't use get_system() ? --hwn.
   */
-  vector<Grob*> all (get_columns (me));
-  set_explicit_neighbor_columns (all);
-
   Spacing_options options;
   options.init_from_grob (me);
 
-  prune_loose_columns (me, &all, &options);
-  set_implicit_neighbor_columns (all);
-  generate_springs (me, all, &options);
+  set_explicit_neighbor_columns (options.columns_);
+
+  prune_loose_columns (me, &options);
+  set_implicit_neighbor_columns (options.columns_);
+  generate_springs (me, &options);
 
   return SCM_UNSPECIFIED;
 }
@@ -216,14 +216,13 @@ Spacing_spanner::generate_pair_spacing (Grob *me,
 
 void
 Spacing_spanner::generate_springs (Grob *me,
-                                  vector<Grob*> const &cols,
                                   Spacing_options const *options)
 {
   Paper_column *prev = 0;
-  for (vsize i = 0; i < cols.size (); i++)
+  for (vsize i = 0; i < options->columns_.size (); i++)
     {
-      Paper_column *col = dynamic_cast<Paper_column *> (cols[i]);
-      Paper_column *next = (i < cols.size()-1) ? dynamic_cast<Paper_column *> (cols[i+1]) : 0;
+      Paper_column *col = dynamic_cast<Paper_column *> (options->columns_[i]);
+      Paper_column *next = (i < options->columns_.size()-1) ? dynamic_cast<Paper_column *> (options->columns_[i+1]) : 0;
       
       if (i > 0)
        generate_pair_spacing (me, prev, col, next, options);
@@ -394,6 +393,27 @@ Spacing_spanner::musical_column_spacing (Grob *me,
   Spaceable_grob::add_spring (left_col, right_col, distance, inverse_strength);
 }
 
+bool
+Spacing_spanner::fills_measure (Grob *me, Item *l, Item *r)
+{
+  return false;
+  System *sys = get_root_system (me);
+  Grob *next = sys->column (r->get_column()->get_rank () + 1);
+  if (!next)
+    return false;
+
+  Moment dt =
+    Paper_column::when_mom (next) - Paper_column::when_mom (r);
+  
+  Moment *len = unsmob_moment (l->get_property ("measure-length"));
+  if (!len)
+    return false;
+  
+  if (dt.main_part_ == len->main_part_)
+    return true;
+
+  return false;
+}
 /*
   Read hints from L and generate springs.
 */
@@ -427,7 +447,6 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r,
          /*
            column for the left one settings should be ok due automatic
            pointer munging.
-
          */
          assert (spacing_grob->get_column () == l);
 
@@ -474,6 +493,11 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r,
       
     }
 
+  if (fills_measure (me, l, r))
+    {
+      compound_space += 1.0; 
+    }
+  
   if (options->stretch_uniformly_ && l->break_status_dir () != RIGHT)
     compound_fixed = 0.0;
 
index 5070f9426cd92506b77d97e3a9f108200f55e1ff..12ceddd1f53857d0e421c9eefdbbf294f87fa480 100644 (file)
@@ -467,7 +467,7 @@ System::broken_col_range (Item const *left, Item const *right) const
 /** Return all columns, but filter out any unused columns , since they might
     disrupt the spacing problem. */
 vector<Grob*>
-System::columns () const
+System::used_columns () const
 {
   extract_grob_set (this, "columns", ro_columns);
 
@@ -490,9 +490,12 @@ System::columns () const
 }
 
 Grob*
-System::column (int which) const
+System::column (vsize which) const
 {
   extract_grob_set (this, "columns", columns);
+  if (which >= columns.size ())
+    return 0;
+  
   return columns[which];
 }