From: Joe Neeman Date: Sun, 9 Nov 2008 02:53:30 +0000 (-0800) Subject: Implement space_systems_with_fixed_number_per_page. X-Git-Tag: release/2.13.1-1~61^2~13 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=53aef0e0ffb5333e319da1a4ba6f12f205bf259c;p=lilypond.git Implement space_systems_with_fixed_number_per_page. --- diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index 8228910080..09307df0d5 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -801,11 +801,44 @@ Page_breaking::space_systems_on_best_pages (vsize configuration, vsize first_pag return finalize_spacing_result (configuration, best); } -Page_spacing_result space_systems_with_fixed_number_per_page (vsize configuration_index, - int systems_per_page, - vsize first_page_num) +Page_spacing_result +Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration, + int systems_per_page, + vsize first_page_num) { - return Page_spacing_result (); + Page_spacing_result res; + Page_spacing space (page_height (first_page_num, false), page_top_space_); + vsize line = 0; + vsize page = 0; + vsize page_first_line = 0; + + cache_line_details (configuration); + while (line < cached_line_details_.size ()) + { + page++; + space.clear (); + space.resize (page_height (first_page_num + page, false)); + + int system_count_on_this_page = 0; + while (system_count_on_this_page < systems_per_page + && line < cached_line_details_.size ()) + { + space.append_system (cached_line_details_[line]); + system_count_on_this_page += cached_line_details_[line].compressed_nontitle_lines_count_; + line++; + } + + res.systems_per_page_.push_back (line - page_first_line); + res.force_.push_back (space.force_); + res.penalty_ += cached_line_details_[line-1].page_penalty_; + page_first_line = line; + } + + /* Recalculate forces for the last page because we know now that is + was really the last page. */ + space.resize (page_height (first_page_num + page, true)); + res.force_.back () = space.force_; + return finalize_spacing_result (configuration, res); } Page_spacing_result