X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpage-breaking.cc;h=d81e32d230108ff61bb54979837ffd9e1d121461;hb=b0a0b0da364a2379e3a26a0cd6af87fece1594fb;hp=f81683a2573277f2de404409219cba8d31aef005;hpb=435b36a3e6576cebf794d815ae7cc78b652180f9;p=lilypond.git diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index f81683a257..d81e32d230 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2006--2011 Joe Neeman + Copyright (C) 2006--2012 Joe Neeman LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -183,8 +183,12 @@ compress_lines (const vector &orig) compressed.title_ = old.title_; // adds footnotes of one line to the footnotes of another - compressed.footnotes_.insert (compressed.footnotes_.begin (), - old.footnotes_.begin (), old.footnotes_.end ()); + compressed.footnote_heights_.insert (compressed.footnote_heights_.begin (), + old.footnote_heights_.begin (), + old.footnote_heights_.end ()); + compressed.in_note_heights_.insert (compressed.in_note_heights_.begin (), + old.in_note_heights_.begin (), + old.in_note_heights_.end ()); ret.back () = compressed; } @@ -250,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; @@ -263,11 +267,10 @@ Page_breaking::Page_breaking (Paper_book *pb, Break_predicate is_break, Prob_bre footnote_separator_stencil_height_ = 0.0; footnote_padding_ = robust_scm2double (pb->paper_->c_variable ("footnote-padding"), 0.0); + in_note_padding_ = robust_scm2double (pb->paper_->c_variable ("in-note-padding"), 0.0); footnote_footer_padding_ = robust_scm2double (pb->paper_->c_variable ("footnote-footer-padding"), 0.0); - footnote_number_raise_ = (to_boolean (pb->paper_->c_variable ("footnote-auto-numbering")) - ? robust_scm2double (pb->paper_->c_variable ("footnote-number-raise"), 0.0) - : 0.0); + footnote_number_raise_ = robust_scm2double (pb->paper_->c_variable ("footnote-number-raise"), 0.0); if (systems_per_page_ && (max_systems_per_page_ || min_systems_per_page_)) { @@ -334,6 +337,12 @@ Page_breaking::footnote_separator_stencil_height () const return footnote_separator_stencil_height_; } +Real +Page_breaking::in_note_padding () const +{ + return in_note_padding_; +} + Real Page_breaking::footnote_padding () const { @@ -531,15 +540,15 @@ Page_breaking::breakpoint_property (vsize breakpoint, char const *str) } SCM -Page_breaking::get_page_configuration (SCM systems, int page_num, int footnote_count, bool ragged, bool last) +Page_breaking::get_page_configuration (SCM systems, int page_num, bool ragged, bool last) { SCM dummy_page = make_page (page_num, last); - Page_layout_problem layout (book_, dummy_page, systems, footnote_count); + Page_layout_problem layout (book_, dummy_page, systems); return scm_is_pair (systems) ? layout.solution (ragged) : SCM_EOL; } SCM -Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, int footnote_num, bool last) +Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, bool last) { // Create a stencil for each system. SCM paper_systems = SCM_EOL; @@ -565,20 +574,14 @@ Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, int foot 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 (); - footnote_num = (to_boolean (book_->paper_->c_variable ("reset-footnotes-on-new-page")) - ? 0 - : footnote_num); + SCM footnotes = Page_layout_problem::get_footnotes_from_lines (systems); - SCM footnotes = Page_layout_problem::get_footnotes_from_lines (systems, - footnote_num, - book_); + foot = Page_layout_problem::add_footnotes_to_footer (footnotes, foot, book_); - 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; @@ -593,11 +596,13 @@ Page_breaking::make_pages (vector lines_per_page, SCM systems) int first_page_number = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1); SCM ret = SCM_EOL; + bool reset_footnotes_on_new_page = to_boolean (book_->top_paper ()->c_variable ("reset-footnotes-on-new-page")); SCM label_page_table = book_->top_paper ()->c_variable ("label-page-table"); 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 @@ -605,6 +610,7 @@ Page_breaking::make_pages (vector 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++) { @@ -614,9 +620,23 @@ Page_breaking::make_pages (vector lines_per_page, SCM systems) SCM line_count = scm_from_int (lines_per_page[i]); SCM lines = scm_list_head (systems, line_count); int fn_lines = Page_layout_problem::get_footnote_count (lines); - SCM config = get_page_configuration (lines, page_num, footnote_count, rag, bookpart_last_page); + Page_layout_problem::add_footnotes_to_lines (lines, reset_footnotes_on_new_page ? 0 : footnote_count, book_); + + 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_list_3 (lines, config, scm_from_int ((int)footnote_count)), systems_configs_fncounts); + systems_configs_fncounts = scm_cons (scm_cons (lines, config), systems_configs_fncounts); footnote_count += fn_lines; systems = scm_list_tail (systems, line_count); } @@ -626,11 +646,10 @@ Page_breaking::make_pages (vector lines_per_page, SCM systems) for (SCM s = systems_configs_fncounts; scm_is_pair (s); s = scm_cdr (s)) { SCM lines = scm_caar (s); - SCM config = scm_cadar (s); - int footnote_num = scm_to_int (scm_caddar (s)); + SCM config = scm_cdar (s); bool bookpart_last_page = (s == systems_configs_fncounts); - SCM page = draw_page (lines, config, page_num, footnote_num, bookpart_last_page); + SCM page = draw_page (lines, config, page_num, bookpart_last_page); /* collect labels */ SCM page_num_scm = scm_from_int (page_num); for (SCM l = lines; scm_is_pair (l); l = scm_cdr (l))