X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpage-turn-page-breaking.cc;h=07b61d92bf84bec98e0537a8ee8a5c66413f0e1e;hb=3623cfc12bb53499a591ae45ac61931bafc6bf20;hp=d2e501cb65d034bcb8c63a52aa6e0418bf19c3c9;hpb=728c1f61013a32153c647a72ca31bc2353754803;p=lilypond.git diff --git a/lily/page-turn-page-breaking.cc b/lily/page-turn-page-breaking.cc index d2e501cb65..07b61d92bf 100644 --- a/lily/page-turn-page-breaking.cc +++ b/lily/page-turn-page-breaking.cc @@ -1,9 +1,20 @@ /* - page-turn-page-breaking.cc -- implement Page_turn_page_breaking + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2006--2011 Joe Neeman - (c) 2006--2007 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "page-turn-page-breaking.hh" @@ -18,14 +29,25 @@ #include "system.hh" #include "warn.hh" +template static bool -is_break (Grob *g) +is_break (T *g) { - return scm_is_symbol (g->get_property ("page-turn-permission")); + bool turnable = scm_is_symbol (g->get_property ("page-turn-permission")); + + if (turnable && + (!scm_is_symbol (g->get_property ("page-break-permission")) + || !scm_is_symbol (g->get_property ("line-break-permission")))) + { + programming_error ("found a page-turnable place which was not breakable"); + turnable = false; + } + + return turnable; } Page_turn_page_breaking::Page_turn_page_breaking (Paper_book *pb) - : Page_breaking (pb, is_break) + : Page_breaking (pb, is_break, is_break) { } @@ -65,14 +87,14 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start, if (start == 0 && auto_first) { if (min_p_count % 2) - result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number); + result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number, 0); else result = space_systems_on_n_pages (configuration, min_p_count, page_number); } else if (page_number % 2 == min_p_count % 2) result = space_systems_on_n_pages (configuration, min_p_count, page_number); else - result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number); + result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number, blank_page_penalty ()); Break_node ret; ret.prev_ = start - 1; @@ -122,7 +144,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 ("part-first-page-number"), 1); + int p_num = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1); if (start > 0) { /* except possibly for the first page, enforce the fact that first_page_number_ @@ -192,8 +214,8 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint) if (start == 0 && end == 1 && this_start_best.first_page_number_ == 1 && this_start_best.page_count_ > 1) - warning (_ ("cannot fit the first page turn onto a single page. " - "Consider setting first-page-number to an even number.")); + warning (_ ("cannot fit the first page turn onto a single page." + " Consider setting first-page-number to an even number.")); if (this_start_best.demerits_ < best.demerits_) best = this_start_best; @@ -247,6 +269,9 @@ Page_turn_page_breaking::make_lines (vector *psoln) SCM Page_turn_page_breaking::make_pages (vector const &soln, SCM systems) { + if (scm_is_null (systems)) + return SCM_EOL; + vector lines_per_page; for (vsize i = 0; i < soln.size (); i++) { @@ -260,7 +285,7 @@ Page_turn_page_breaking::make_pages (vector 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 ("part-first-page-number"), + book_->paper_->set_variable (ly_symbol2scm ("first-page-number"), scm_from_int (soln[0].first_page_number_)); return Page_breaking::make_pages (lines_per_page, systems); }