]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/page-turn-page-breaking.cc
Merge branch 'master' into nested-bookparts
[lilypond.git] / lily / page-turn-page-breaking.cc
index 782399542c0ab01b47ba53c5283c4d6b80e50f0b..d2e501cb65d034bcb8c63a52aa6e0418bf19c3c9 100644 (file)
@@ -61,7 +61,7 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start,
      min_p_count has that evenness. (For example, if PAGE-NUMBER is even and
      min_p_count is even, we don't even consider the blank page option). */
 
-  Spacing_result result;
+  Page_spacing_result result;
   if (start == 0 && auto_first)
     {
       if (min_p_count % 2)
@@ -93,13 +93,13 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start,
   return ret;
 }
 
-/* "final page" meaning the number of the final right-hand page,
-   which always has an odd page number */
+/* The number of pages taken up by a Break_node, including
+   the blank page if there is one */
 vsize
-Page_turn_page_breaking::final_page_num (Break_node const &b)
+Page_turn_page_breaking::total_page_count (Break_node const &b)
 {
   vsize end = b.first_page_number_ + b.page_count_;
-  return end - 1 + (end % 2);
+  return end - 1 + (end % 2) - b.first_page_number_;
 }
 
 extern bool debug_page_breaking_scoring;
@@ -122,7 +122,7 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
       if (start > 0 && best.demerits_ < state_[start-1].demerits_)
         continue;
 
-      int p_num = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1);
+      int p_num = robust_scm2int (book_->paper_->c_variable ("part-first-page-number"), 1);
       if (start > 0)
         {
          /* except possibly for the first page, enforce the fact that first_page_number_
@@ -160,7 +160,7 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint)
               if (isinf (cur.demerits_)
                  || (cur.page_count_  + (p_num % 2) > 2
                      && (!isinf (this_start_best.demerits_))
-                     && final_page_num (cur) > final_page_num (this_start_best)))
+                     && total_page_count (cur) > total_page_count (this_start_best)))
                 {
                   ok_page = false;
                   break;
@@ -206,8 +206,8 @@ Page_turn_page_breaking::solve ()
 {
   state_.clear ();
   message (_f ("Calculating page and line breaks (%d possible page breaks)...",
-               (int)breaks_.size () - 1) + " ");
-  for (vsize i = 0; i + 1 < breaks_.size (); i++)
+               (int) last_break_position ()));
+  for (vsize i = 0; i < last_break_position (); i++)
     {
       calc_subproblem (i);
       progress_indication (string ("[") + to_string (i + 1) + "]");
@@ -260,7 +260,7 @@ Page_turn_page_breaking::make_pages (vector<Break_node> const &soln, SCM systems
 
   /* this should only actually modify first-page-number if
      auto-first-page-number was true. */
-  book_->paper_->set_variable (ly_symbol2scm ("first-page-number"),
+  book_->paper_->set_variable (ly_symbol2scm ("part-first-page-number"),
                               scm_from_int (soln[0].first_page_number_));
   return Page_breaking::make_pages (lines_per_page, systems);
 }