X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fone-line-page-breaking.cc;h=a3276f4216c6b876274f8def526188ebaf60a733;hb=b872748c6aa8bb721ced458691b38ac2fac5dfc8;hp=2175e1727a48658de49819109dab82acf92f8c9e;hpb=85c0e5ad855373f43a22fd3a204f963486bde354;p=lilypond.git diff --git a/lily/one-line-page-breaking.cc b/lily/one-line-page-breaking.cc index 2175e1727a..a3276f4216 100644 --- a/lily/one-line-page-breaking.cc +++ b/lily/one-line-page-breaking.cc @@ -40,42 +40,52 @@ One_line_page_breaking::~One_line_page_breaking () } /* - This is a somewhat unconventional page-breaking algorithm. Every - score will be put on a single page, whose width is enough - to fit the entire score one one line. Line breaks and page breaks - are ignored, as are the page dimensions in the paper block. + This is a somewhat unconventional page-breaking algorithm. Every + score is put on a single page, whose width is enough to fit the entire + score on one line. Line breaks and page breaks are ignored, and the + paper-width setting in the paper block is modified to fit the music. */ SCM One_line_page_breaking::solve () { SCM all_pages = SCM_EOL; + Real max_width = 0; for (vsize i = 0; i < system_specs_.size (); ++i) - if (Paper_score *ps = system_specs_[i].pscore_) - { - vector cols = ps->root_system ()->used_columns (); - - // No indent, "infinite" line width, ragged. - Column_x_positions pos = get_line_configuration (cols, numeric_limits::max (), 0, true); - vector positions; - positions.push_back (pos); - - ps->root_system ()->break_into_pieces (positions); - ps->root_system ()->do_break_substitution_and_fixup_refpoints (); - Grob *system = ps->root_system ()->broken_intos_[0]; - Real width = system->extent (system, X_AXIS).length (); - Real height = system->extent (system, Y_AXIS).length (); - - // HACK: probably shouldn't be modifying the paper_; better to modify the page - // afterwards. - book_->paper_->set_variable (ly_symbol2scm ("paper-width"), scm_from_double (width + 100)); - // TODO: figure out what the height should be. - //book_->paper_->set_variable (ly_symbol2scm ("paper-height"), scm_from_double (height)); - vector lines_per_page; - lines_per_page.push_back (1); - SCM systems = scm_list_1 (system->self_scm ()); - SCM pages = make_pages (lines_per_page, systems); - all_pages = scm_cons (scm_car (pages), all_pages); - } + { + if (Paper_score *ps = system_specs_[i].pscore_) + { + vector cols = ps->root_system ()->used_columns (); + + // No indent, "infinite" line width, ragged. + Column_x_positions pos = get_line_configuration (cols, numeric_limits::max (), 0, true); + vector positions; + positions.push_back (pos); + + ps->root_system ()->break_into_pieces (positions); + ps->root_system ()->do_break_substitution_and_fixup_refpoints (); + Grob *system = ps->root_system ()->broken_intos_[0]; + + vector lines_per_page; + lines_per_page.push_back (1); + SCM systems = scm_list_1 (system->self_scm ()); + SCM pages = make_pages (lines_per_page, systems); + + max_width = max (max_width, system->extent (system, X_AXIS).length ()); + all_pages = scm_cons (scm_car (pages), all_pages); + } + else if (Prob *pb = system_specs_[i].prob_) + // Because we don't call Page_breaking::systems in this algorithm, + // we need to manually unprotect the titles. + pb->unprotect (); + } + + // Alter paper-width so that it is large enough to fit every system. + // TODO: it might be nice to allow different pages to have different widths. + // This would need support in the backends (eg. framework-ps.scm). + Real right_margin = robust_scm2double (book_->paper_->c_variable ("right-margin"), 0.0); + Real left_margin = robust_scm2double (book_->paper_->c_variable ("left-margin"), 0.0); + Real width = max_width + right_margin + left_margin; + book_->paper_->set_variable (ly_symbol2scm ("paper-width"), scm_from_double (width)); return scm_reverse_x (all_pages, SCM_EOL); }