]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/page-breaking.cc
Doc-de: updates for notation manual
[lilypond.git] / lily / page-breaking.cc
index 01d7469f52ed80ff45a1f9e5c102e1b262076ca3..9956c9f9784450c3a7f7fec8fd2d435af2ff7f10 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2006--2011 Joe Neeman <joeneeman@gmail.com>
+  Copyright (C) 2006--2012 Joe Neeman <joeneeman@gmail.com>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -254,11 +254,11 @@ Page_breaking::Page_breaking (Paper_book *pb, Break_predicate is_break, Prob_bre
   min_systems_per_page_ = max (0, robust_scm2int (pb->paper_->c_variable ("min-systems-per-page"), 0));
   orphan_penalty_ = robust_scm2int (pb->paper_->c_variable ("orphan-penalty"), 100000);
 
-  Stencil *footnote_separator = Page_layout_problem::get_footnote_separator_stencil (pb->paper_);
+  Stencil footnote_separator = Page_layout_problem::get_footnote_separator_stencil (pb->paper_);
 
-  if (footnote_separator)
+  if (!footnote_separator.is_empty ())
     {
-      Interval separator_extent = footnote_separator->extent (Y_AXIS);
+      Interval separator_extent = footnote_separator.extent (Y_AXIS);
       Real separator_span = separator_extent.length ();
 
       footnote_separator_stencil_height_ = separator_span;
@@ -466,7 +466,7 @@ Page_breaking::systems ()
           pb->unprotect ();
         }
     }
-  return scm_append (scm_reverse (ret));
+  return scm_append (scm_reverse_x (ret, SCM_EOL));
 }
 
 SCM
@@ -552,7 +552,7 @@ Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, bool las
 {
   // Create a stencil for each system.
   SCM paper_systems = SCM_EOL;
-  for (SCM s = scm_reverse (systems); scm_is_pair (s); s = scm_cdr (s))
+  for (SCM s = systems; scm_is_pair (s); s = scm_cdr (s))
     {
       SCM paper_system = scm_car (s);
       if (Grob *g = unsmob_grob (scm_car (s)))
@@ -563,6 +563,7 @@ Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, bool las
 
       paper_systems = scm_cons (paper_system, paper_systems);
     }
+  paper_systems = scm_reverse_x (paper_systems, SCM_EOL);
 
   // Create the page and draw it.
   SCM page = make_page (page_num, last);
@@ -574,14 +575,14 @@ Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, bool las
   p->set_property ("lines", paper_systems);
   p->set_property ("configuration", configuration);
 
-  Stencil *foot = unsmob_stencil (p->get_property ("foot-stencil"));
+  Stencil *foot_p = unsmob_stencil (p->get_property ("foot-stencil"));
+  Stencil foot = foot_p ? *foot_p : Stencil ();
 
   SCM footnotes = Page_layout_problem::get_footnotes_from_lines (systems);
 
-  Page_layout_problem::add_footnotes_to_footer (footnotes, foot, book_);
+  foot = Page_layout_problem::add_footnotes_to_footer (footnotes, foot, book_);
 
-  if (foot)
-    p->set_property ("foot-stencil", foot->smobbed_copy ());
+  p->set_property ("foot-stencil", foot.smobbed_copy ());
   scm_apply_1 (page_stencil, page, SCM_EOL);
 
   return page;
@@ -601,7 +602,8 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems)
   if (label_page_table == SCM_UNDEFINED)
     label_page_table = SCM_EOL;
 
-  // Build a list of (systems . configuration) pairs. Note that we lay out
+  // Build a list of (systems configuration . footnote-count) triples.
+  // Note that we lay out
   // the staves and find the configurations before drawing anything. Some
   // grobs (like tuplet brackets) look at their neighbours while drawing
   // themselves. If this happens before the neighbouring staves have
@@ -609,6 +611,7 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems)
   // Align_interface::align_to_ideal_distances might be called).
   SCM systems_configs_fncounts = SCM_EOL;
   vsize footnote_count = 0;
+  Real last_page_force = 0;
 
   for (vsize i = 0; i < lines_per_page.size (); i++)
     {
@@ -620,7 +623,19 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems)
       int fn_lines = Page_layout_problem::get_footnote_count (lines);
       Page_layout_problem::add_footnotes_to_lines (lines, reset_footnotes_on_new_page ? 0 : footnote_count, book_);
 
-      SCM config = get_page_configuration (lines, page_num, rag, bookpart_last_page);
+      SCM config = SCM_EOL;
+      SCM dummy_page = make_page (page_num, bookpart_last_page);
+      Page_layout_problem layout (book_, dummy_page, lines);
+      if (!scm_is_pair (systems))
+        config = SCM_EOL;
+      else if (rag && !ragged ())
+        // If we're ragged-last but not ragged, make the last page
+        // have the same force as the previous page.
+        config = layout.fixed_force_solution (last_page_force);
+      else
+        config = layout.solution (rag);
+
+      last_page_force = layout.force ();
 
       systems_configs_fncounts = scm_cons (scm_cons (lines, config), systems_configs_fncounts);
       footnote_count += fn_lines;