]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 1285.
authorJoe Neeman <joeneeman@gmail.com>
Mon, 25 Oct 2010 23:56:22 +0000 (16:56 -0700)
committerJoe Neeman <joeneeman@gmail.com>
Fri, 5 Nov 2010 22:12:17 +0000 (15:12 -0700)
Use stretchable space to inform page breaking.

lily/constrained-breaking.cc
lily/include/constrained-breaking.hh
lily/page-spacing.cc

index e82397f653364f2b08be397f613950f373632eca..ba3fc4d5cbecc0080ebdec48431a7ccf674d71ca 100644 (file)
@@ -380,16 +380,6 @@ Constrained_breaking::initialize ()
 
   ragged_right_ = to_boolean (pscore_->layout ()->c_variable ("ragged-right"));
   ragged_last_ = to_boolean (pscore_->layout ()->c_variable ("ragged-last"));
-  /* NOTE: currently, we aren't using the space_ field of a
-     Line_details for anything.  That's because the approximations
-     used for scoring a page configuration don't actually space things
-     properly (for speed reasons) using springs anchored at the staff
-     refpoints.  Rather, the "space" is placed between the extent
-     boxes.  To get a good result, therefore, the "space" value for
-     page breaking needs to be much smaller than the "space" value for
-     page layout.  Currently, we just make it zero always, which means
-     that we will always prefer a tighter vertical layout.
-  */
   system_system_space_ = 0;
   system_system_padding_ = 0;
   system_system_min_distance_ = 0;
@@ -404,6 +394,13 @@ Constrained_breaking::initialize ()
   SCM between_scores_spec = l->c_variable ("score-system-spacing");
   SCM title_spec = l->c_variable ("score-markup-spacing");
   SCM page_breaking_spacing_spec = l->c_variable ("page-breaking-system-system-spacing");
+
+  Page_layout_problem::read_spacing_spec (spacing_spec,
+                                         &system_system_space_,
+                                         ly_symbol2scm ("space"));
+  Page_layout_problem::read_spacing_spec (page_breaking_spacing_spec,
+                                         &system_system_space_,
+                                         ly_symbol2scm ("space"));
   Page_layout_problem::read_spacing_spec (spacing_spec,
                                          &system_system_padding_,
                                          ly_symbol2scm ("padding"));
@@ -508,13 +505,16 @@ Constrained_breaking::fill_line_details (Line_details *const out, vsize start, v
                         || isnan (rest_of_line_extent[RIGHT]))
     ? Interval (0, 0) : rest_of_line_extent;
   out->shape_ = Line_shape (begin_of_line_extent, rest_of_line_extent);
-  out->refpoint_extent_ = sys->pure_refpoint_extent (start_rank, end_rank);
   out->padding_ = last ? score_system_padding_ : system_system_padding_;
   out->title_padding_ = score_markup_padding_;
   out->min_distance_ = last ? score_system_min_distance_ : system_system_min_distance_;
   out->title_min_distance_ = score_markup_min_distance_;
   out->space_ = system_system_space_;
   out->inverse_hooke_ = out->full_height () + system_system_space_;
+
+  out->refpoint_extent_ = sys->pure_refpoint_extent (start_rank, end_rank);
+  if (out->refpoint_extent_.is_empty ())
+    out->refpoint_extent_ = Interval (0, 0);
 }
 
 Real
@@ -561,6 +561,7 @@ Line_details::Line_details (Prob *pb, Output_def *paper)
   SCM first_scm = pb->get_property ("first-markup-line");
   first_markup_line_ = to_boolean (first_scm);
   tight_spacing_ = to_boolean (pb->get_property ("tight-spacing"));
+  refpoint_extent_ = Interval (0, 0);
 }
 
 Real
index f29ee6310fef8d9e68257a112230f091285d2639..63d695dfe36b0a0c36ec012e81019e7e68b95922 100644 (file)
@@ -104,6 +104,7 @@ struct Line_details {
     last_markup_line_ = false;
     first_markup_line_ = false;
     tallness_ = 0;
+    refpoint_extent_ = Interval (0, 0);
   }
 
   Line_details (Prob *pb, Output_def *paper);
index b3a7ed8a4146f3ddbd8e9da8f1a7e1b9968cf0bb..bb6b5063b9e885a1133c6f8923e840e9b59c3066 100644 (file)
@@ -57,7 +57,13 @@ Page_spacing::append_system (const Line_details &line)
       first_line_ = line;
     }
 
-  spring_len_ += line.space_;
+  // line.space_ measures the spring which goes from the bottom refpoint
+  // of one system to the top refpoint of the next. spring_len_ measures
+  // how much of that is stretchable.
+  Real refpoint_dist = last_line_.tallness_
+    + last_line_.refpoint_extent_[DOWN]
+    - line.refpoint_extent_[UP];
+  spring_len_ += max (0.0, line.space_ - refpoint_dist);
   inverse_spring_k_ += line.inverse_hooke_;
 
   last_line_ = line;
@@ -74,7 +80,11 @@ Page_spacing::prepend_system (const Line_details &line)
   rod_height_ -= first_line_.full_height ();
   rod_height_ += first_line_.tallness_;
   rod_height_ += line.full_height();
-  spring_len_ += line.space_;
+
+  Real refpoint_dist = line.tallness_
+    + line.refpoint_extent_[DOWN]
+    - first_line_.refpoint_extent_[UP];
+  spring_len_ += max (0.0, line.space_ - refpoint_dist);
   inverse_spring_k_ += line.inverse_hooke_;
 
   first_line_ = line;