]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 850.
authorJoe Neeman <joeneeman@gmail.com>
Mon, 12 Oct 2009 02:19:59 +0000 (19:19 -0700)
committerJoe Neeman <joeneeman@gmail.com>
Mon, 12 Oct 2009 02:19:59 +0000 (19:19 -0700)
When page breaking, take into account the padding before, after and between
titles.

input/regression/page-breaking-title-padding.ly [new file with mode: 0644]
input/regression/page-breaking-title-padding2.ly [new file with mode: 0644]
input/regression/page-breaking-title-padding3.ly [new file with mode: 0644]
lily/constrained-breaking.cc
lily/include/constrained-breaking.hh
lily/page-breaking.cc
lily/page-spacing.cc

diff --git a/input/regression/page-breaking-title-padding.ly b/input/regression/page-breaking-title-padding.ly
new file mode 100644 (file)
index 0000000..203fbde
--- /dev/null
@@ -0,0 +1,18 @@
+\version "2.13.4"
+
+#(set-default-paper-size "a6")
+
+\book {
+  \header {
+    texidoc = "Padding between titles is honoured by the page breaker.
+This should take up two pages."
+  }
+
+  \paper {
+    between-title-spacing = #'((padding . 300))
+  }
+
+  \markup "00"
+  \markup "01"
+  { c' }
+}
diff --git a/input/regression/page-breaking-title-padding2.ly b/input/regression/page-breaking-title-padding2.ly
new file mode 100644 (file)
index 0000000..60ec2cf
--- /dev/null
@@ -0,0 +1,18 @@
+\version "2.13.4"
+
+#(set-default-paper-size "a6")
+
+\book {
+  \header {
+    texidoc = "Padding after titles is honoured by the page breaker.
+This should take up two pages."
+  }
+
+  \paper {
+    after-title-spacing = #'((padding . 300))
+  }
+
+  \markup "00"
+  \markup "01"
+  { c' }
+}
diff --git a/input/regression/page-breaking-title-padding3.ly b/input/regression/page-breaking-title-padding3.ly
new file mode 100644 (file)
index 0000000..945e828
--- /dev/null
@@ -0,0 +1,21 @@
+\version "2.13.4"
+
+#(set-default-paper-size "a6")
+
+\book {
+  \header {
+    texidoc = "Padding before titles is honoured by the page breaker.
+This should take up two pages."
+  }
+
+  \paper {
+    before-title-spacing = #'((padding . 300))
+  }
+
+  \markup "00"
+  \markup "01"
+  \score {
+    { c'1 \allowPageTurn }
+  }
+  \markup "02"
+}
index f0f96164df8991993a52cbde3cdec4327dcb8021..44c2abc70a22556a55a9a3e5f4ee10fee5637c62 100644 (file)
@@ -381,10 +381,12 @@ Constrained_breaking::initialize ()
   */
   between_system_space_ = 0;
   between_system_padding_ = 0;
+  before_title_padding_ = 0;
 
   Output_def *l = pscore_->layout ();
 
   SCM spacing_spec = l->c_variable ("between-system-spacing");
+  SCM title_spec = l->c_variable ("before-title-spacing");
   SCM page_breaking_spacing_spec = l->c_variable ("page-breaking-between-system-spacing");
   Page_layout_problem::read_spacing_spec (spacing_spec,
                                          &between_system_padding_,
@@ -392,6 +394,9 @@ Constrained_breaking::initialize ()
   Page_layout_problem::read_spacing_spec (page_breaking_spacing_spec,
                                          &between_system_padding_,
                                          ly_symbol2scm ("padding"));
+  Page_layout_problem::read_spacing_spec (title_spec,
+                                         &before_title_padding_,
+                                         ly_symbol2scm ("padding"));
 
   Interval first_line = line_dimensions_int (pscore_->layout (), 0);
   Interval other_lines = line_dimensions_int (pscore_->layout (), 1);
@@ -472,6 +477,7 @@ Constrained_breaking::fill_line_details (Line_details *const out, vsize start, v
                  || isnan (extent[RIGHT]))
     ? Interval (0, 0) : extent;
   out->padding_ = between_system_padding_;
+  out->title_padding_ = before_title_padding_;
   out->space_ = between_system_space_;
   out->inverse_hooke_ = extent.length () + between_system_space_;
 }
@@ -485,3 +491,28 @@ Constrained_breaking::combine_demerits (Real force, Real prev_force)
   return force * force + (prev_force - force) * (prev_force - force);
 }
 
+Line_details::Line_details (Prob *pb, Output_def *paper)
+{
+  SCM spec = paper->c_variable ("after-title-spacing");
+  SCM title_spec = paper->c_variable ("between-title-spacing");
+  padding_ = 0;
+  title_padding_ = 0;
+  Page_layout_problem::read_spacing_spec (spec, &padding_, ly_symbol2scm ("padding"));
+  Page_layout_problem::read_spacing_spec (title_spec, &title_padding_, ly_symbol2scm ("padding"));
+
+  last_column_ = 0;
+  force_ = 0;
+  extent_ = unsmob_stencil (pb->get_property ("stencil")) ->extent (Y_AXIS);
+  bottom_padding_ = 0;
+  space_ = robust_scm2double (pb->get_property ("next-space"), 1.0);
+  inverse_hooke_ = 1.0;
+  break_permission_ = ly_symbol2scm ("allow");
+  page_permission_ = pb->get_property ("page-break-permission");
+  turn_permission_ = pb->get_property ("page-turn-permission");
+  break_penalty_ = 0;
+  page_penalty_ = robust_scm2double (pb->get_property ("page-break-penalty"), 0);
+  turn_penalty_ = robust_scm2double (pb->get_property ("page-turn-penalty"), 0);
+  title_ = to_boolean (pb->get_property ("is-title"));
+  compressed_lines_count_ = 1;
+  compressed_nontitle_lines_count_ = title_ ? 0 : 1;
+}
index 4767902da9a4203b384bb5fe04fa256c1ddadbe7..1562dc1d17eddc17d224820d15769afa3b780699 100644 (file)
@@ -21,6 +21,7 @@ struct Line_details {
 
   Real padding_;  /* compulsory space after this system (if we're not
                     last on a page) */
+  Real title_padding_;
   Real bottom_padding_;
   Real space_;    /* spring length */
   Real inverse_hooke_;
@@ -47,6 +48,7 @@ struct Line_details {
     last_column_ = 0;
     force_ = infinity_f;
     padding_ = 0;
+    title_padding_ = 0;
     bottom_padding_ = 0;
     space_ = 0;
     inverse_hooke_ = 1;
@@ -61,25 +63,7 @@ struct Line_details {
     compressed_nontitle_lines_count_ = 1;
   }
 
-  Line_details (Prob *pb)
-  {
-    last_column_ = 0;
-    force_ = 0;
-    extent_ = unsmob_stencil (pb->get_property ("stencil")) ->extent (Y_AXIS);
-    padding_ = robust_scm2double (pb->get_property ("next-padding"), 0);
-    bottom_padding_ = 0;
-    space_ = robust_scm2double (pb->get_property ("next-space"), 1.0);
-    inverse_hooke_ = 1.0;
-    break_permission_ = ly_symbol2scm ("allow");
-    page_permission_ = pb->get_property ("page-break-permission");
-    turn_permission_ = pb->get_property ("page-turn-permission");
-    break_penalty_ = 0;
-    page_penalty_ = robust_scm2double (pb->get_property ("page-break-penalty"), 0);
-    turn_penalty_ = robust_scm2double (pb->get_property ("page-turn-penalty"), 0);
-    title_ = to_boolean (pb->get_property ("is-title"));
-    compressed_lines_count_ = 1;
-    compressed_nontitle_lines_count_ = title_ ? 0 : 1;
-  }
+  Line_details (Prob *pb, Output_def *paper);
 };
 
 /*
@@ -131,6 +115,7 @@ private:
   bool ragged_right_;
   bool ragged_last_;
   Real between_system_space_;
+  Real before_title_padding_;
   Real between_system_padding_;
 
   /* the (i,j)th entry is the configuration for breaking between
index 038b0af2479b3f4db7a5a29488a493a9cc136f38..5020a33eba00df7a296be3146c4f8f78df6f9a40 100644 (file)
@@ -89,8 +89,10 @@ compress_lines (const vector<Line_details> &orig)
        {
          Line_details const &old = ret.back ();
          Line_details compressed = orig[i];
+         Real padding = orig[i].title_ ? old.title_padding_ : old.padding_;
+
          compressed.extent_[DOWN] = old.extent_[DOWN];
-         compressed.extent_[UP] = old.extent_[UP] + orig[i].extent_.length () + old.padding_;
+         compressed.extent_[UP] = old.extent_[UP] + orig[i].extent_.length () + padding;
          compressed.space_ += old.space_;
          compressed.inverse_hooke_ += old.inverse_hooke_;
 
@@ -751,11 +753,6 @@ Page_breaking::cache_line_details (vsize configuration_index)
   if (cached_configuration_index_ != configuration_index)
     {
       cached_configuration_index_ = configuration_index;
-      Real padding = 0;
-      SCM spacing_spec = book_->paper_->c_variable ("between-system-spacing");
-      SCM page_breaking_spacing_spec = book_->paper_->c_variable ("page-breaking-between-system-spacing");
-      Page_layout_problem::read_spacing_spec (spacing_spec, &padding, ly_symbol2scm ("padding"));
-      Page_layout_problem::read_spacing_spec (page_breaking_spacing_spec, &padding, ly_symbol2scm ("padding"));
 
       Line_division &div = current_configurations_[configuration_index];
       uncompressed_line_details_.clear ();
@@ -774,10 +771,7 @@ Page_breaking::cache_line_details (vsize configuration_index)
          else
            {
              assert (div[i] == 1);
-             uncompressed_line_details_.push_back (Line_details (system_specs_[sys].prob_));
-             uncompressed_line_details_.back ().padding_ =
-                robust_scm2double (system_specs_[sys].prob_->get_property ("next-padding"),
-                                   padding);
+             uncompressed_line_details_.push_back (Line_details (system_specs_[sys].prob_, book_->paper_));
            }
        }
       cached_line_details_ = compress_lines (uncompressed_line_details_);
@@ -849,8 +843,12 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num)
   for (vsize i = 0; i < cached_line_details_.size (); i++)
     {
       Real ext_len = cached_line_details_[i].extent_.length ();
-      Real next_rod_height = cur_rod_height + ext_len
-       + ((cur_rod_height > 0) ? cached_line_details_[i].padding_: 0);
+      Real padding = 0;
+      if (cur_rod_height > 0)
+       padding = cached_line_details_[i].title_ ?
+         cached_line_details_[i-1].title_padding_ : cached_line_details_[i-1].padding_;
+
+      Real next_rod_height = cur_rod_height + ext_len + padding;
       Real next_spring_height = cur_spring_height + cached_line_details_[i].space_;
       Real next_height = next_rod_height + (ragged () ? next_spring_height : 0)
        + min_whitespace_at_bottom_of_page (cached_line_details_[i]);
index ab8085c1d59b92900fd46cd7ac72f59f425e3f91..e6112e095e95dab45ef370460f225773b4105256 100644 (file)
@@ -40,7 +40,7 @@ Page_spacing::append_system (const Line_details &line)
   if (!rod_height_)
     first_line_ = line;
 
-  rod_height_ += last_line_.padding_;
+  rod_height_ += line.title_ ? last_line_.title_padding_ : last_line_.padding_;
 
   rod_height_ += line.extent_.length ();
   spring_len_ += line.space_;
@@ -55,7 +55,7 @@ void
 Page_spacing::prepend_system (const Line_details &line)
 {
   if (rod_height_)
-    rod_height_ += line.padding_;
+    rod_height_ += first_line_.title_ ? line.title_padding_ : line.padding_;
   else
     last_line_ = line;