From: Han-Wen Nienhuys Date: Sun, 13 Jun 2004 12:44:54 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release/2.3.4~10 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=99433c54bea756a38ed6b2a70bc8c90cd0d37902;p=lilypond.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 21410ff984..ed7d3b2a5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,20 @@ 2004-06-13 Han-Wen Nienhuys + * lily/include/paper-system.hh: move cc/hh file from paper-line.* + + * lily/include/paper-line.hh: rename to Paper_system. + + * lily/include/paper-book.hh: doc class. + + * lily/paper-book.cc (c_ragged_page_breaks): remove functions. + + * scm/page-layout.scm (plain-footer): add tagline/copyright. + (plain-header): add instrument-name. + (default-page-make-stencil): bugfixes. + + * lily/parser.yy (book_body): allow \header anywhere in \book{} + * lily/paper-book.cc: remove copyright & tagline. Remove interactions with Page diff --git a/VERSION b/VERSION index b139ad6d99..2d2e4da5de 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=3 -PATCH_LEVEL=3 -MY_PATCH_LEVEL=hwn1 +PATCH_LEVEL=4 +MY_PATCH_LEVEL= diff --git a/input/test/page-breaks.ly b/input/test/page-breaks.ly index ab8d98359b..86668c7118 100644 --- a/input/test/page-breaks.ly +++ b/input/test/page-breaks.ly @@ -17,31 +17,32 @@ piece = "Piece" } +#(set-default-paper-size "a6") + pattern = { a b c d \break } +\book { + \score { + \context Staff \notes \relative c' { + %% 16: ideally cramped + %% 17: very bad without density + % \repeat unfold 17 { a b c d \break } -\score { - \context Staff \notes \relative c' { - %% 16: ideally cramped - %% 17: very bad without density -% \repeat unfold 17 { a b c d \break } + \pattern + \pattern + % \noPageBreak + \pattern + + % the following changes the location of the break. + % + % \pageBreak + + \pattern + \pattern + \pattern + \pattern + \repeat unfold 10 \pattern + } - \pattern - \pattern - % \noPageBreak - \pattern - - % the following changes the location of the break. - % - % \pageBreak - - \pattern - \pattern - \pattern - \pattern - \repeat unfold 10 \pattern - } - \paper { - #(set-default-paper-size "a6") - #(define page-breaking ly:optimal-page-breaks) } + } diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 9988d989c1..f43f3a54bd 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -111,7 +111,7 @@ class Output_property; class Paper_book; class Paper_column; class Output_def; -class Paper_line; +class Paper_system; class Paper_outputter; class Paper_score; class Paper_stream; diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index 3eca0424c2..3654b87107 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -24,7 +24,9 @@ struct Score_lines /* - DOCME. +This class is rather empty. It collects systems (Paper_system), and +exports them to the output backend, either as systems or as completely +formatted pages. */ class Paper_book @@ -33,8 +35,6 @@ class Paper_book SCM lines_; SCM pages_; - SCM copyright_; - SCM tagline_; public: SCM header_; Array score_lines_; diff --git a/lily/include/paper-line.hh b/lily/include/paper-line.hh deleted file mode 100644 index f1e9a464a4..0000000000 --- a/lily/include/paper-line.hh +++ /dev/null @@ -1,37 +0,0 @@ -/* - paper-line.hh -- declare Paper_line - - source file of the GNU LilyPond music typesetter - - (c) 2004 Jan Nieuwenhuizen -*/ -#ifndef PAPER_LINE_HH -#define PAPER_LINE_HH - -#include "lily-proto.hh" -#include "smobs.hh" -#include "offset.hh" -#include "stencil.hh" - -class Paper_line -{ - DECLARE_SMOBS (Paper_line, ); - Stencil stencil_; - bool is_title_; - -public: - Real penalty_; - int number_; - - Paper_line (Stencil, bool); - - Offset dim () const; - Stencil to_stencil () const; - SCM stencils () const; - bool is_title () const; - Real penalty () const; -}; - -DECLARE_UNSMOB (Paper_line, paper_line); - -#endif /* PAPER_LINE_HH */ diff --git a/lily/include/paper-system.hh b/lily/include/paper-system.hh new file mode 100644 index 0000000000..755e66f735 --- /dev/null +++ b/lily/include/paper-system.hh @@ -0,0 +1,45 @@ +/* + paper-system.hh -- declare Paper_system + + source file of the GNU LilyPond music typesetter + + (c) 2004 Jan Nieuwenhuizen +*/ +#ifndef PAPER_LINE_HH +#define PAPER_LINE_HH + +#include "lily-proto.hh" +#include "smobs.hh" +#include "offset.hh" +#include "stencil.hh" + +/* + A formatted "system" (A block of titling also is a Paper_system) + + To save memory, we don't keep around the System grobs, but put the + formatted content of the grob is put into a Paper_system. Page-breaking handles + Paper_system objects. + + */ +class Paper_system +{ + DECLARE_SMOBS (Paper_system, ); + Stencil stencil_; + bool is_title_; + +public: + Real penalty_; + int number_; + + Paper_system (Stencil, bool); + + Offset dim () const; + Stencil to_stencil () const; + SCM stencils () const; + bool is_title () const; + Real penalty () const; +}; + +DECLARE_UNSMOB (Paper_system, paper_line); + +#endif /* PAPER_LINE_HH */ diff --git a/lily/paper-book.cc b/lily/paper-book.cc index cbd690772e..86df95ebcd 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -11,7 +11,7 @@ #include "paper-book.hh" #include "output-def.hh" #include "paper-outputter.hh" -#include "paper-line.hh" +#include "paper-system.hh" #include "paper-score.hh" #include "stencil.hh" #include "warn.hh" @@ -120,10 +120,6 @@ LY_DEFINE (ly_output_formats, "ly:output-formats", return lst; } -/* - TODO: there is too much code dup, and the interface is not - clear. FIXME. - */ void Paper_book::output (String outname) { @@ -254,7 +250,7 @@ LY_DEFINE(ly_paper_book_book_paper, "ly:paper-book-book-paper", /* -TODO: resurrect more complex user-tweaks for titling . +TODO: resurrect more complex user-tweaks for titling? */ Stencil @@ -329,7 +325,7 @@ Paper_book::lines () if (!title.is_empty ()) { - Paper_line *pl = new Paper_line (title, true); + Paper_system *pl = new Paper_system (title, true); lines_ = scm_cons (pl->self_scm (), lines_); scm_gc_unprotect_object (pl->self_scm ()); @@ -341,7 +337,7 @@ Paper_book::lines () Stencil title = score_title (i); if (!title.is_empty ()) { - Paper_line *pl = new Paper_line (title, true); + Paper_system *pl = new Paper_system (title, true); lines_ = scm_cons (pl->self_scm (), lines_); scm_gc_unprotect_object (pl->self_scm ()); } @@ -358,10 +354,10 @@ Paper_book::lines () lines_ = scm_reverse (lines_); int i = 0; - Paper_line * last = 0; + Paper_system * last = 0; for (SCM s = lines_; s != SCM_EOL; s = ly_cdr (s)) { - Paper_line * p = unsmob_paper_line (ly_car (s)); + Paper_system * p = unsmob_paper_line (ly_car (s)); p->number_ = ++i; if (last && last->is_title ()) @@ -397,66 +393,6 @@ Paper_book::pages () -#if 0 - -static SCM -c_ragged_page_breaks (SCM lines, - Paper_book *book, - Real text_height, - Real first, Real last) -{ - int page_number = 0; - - Real book_height =0.; - for (SCM s = lines ; ly_c_pair_p (s); s = ly_cdr (s)) - { - book_height += unsmob_paper_line (ly_car (s))->dim ()[Y_AXIS]; - } - - int page_count = int (book_height / text_height + 0.5); // ceil? - SCM breaks = SCM_EOL; - Real page_height = text_height + first; - Real h = 0; - int number = 0; - for (SCM s = lines; ly_c_pair_p (s); s = ly_cdr (s)) - { - Paper_line *pl = unsmob_paper_line (ly_car (s)); - if (!pl->is_title () && h < page_height) - number++; - h += pl->dim ()[Y_AXIS]; - if (!pl->is_title () && h > page_height) - { - breaks = ly_snoc (scm_int2num (number), breaks); - page_number++; - page_height = text_height + (page_number == page_count) * last; - h = 0; - } - if (ly_cdr (s) == SCM_EOL) - breaks = ly_snoc (scm_int2num (pl->number_), breaks); - } - - return scm_vector (breaks); -} - -LY_DEFINE (ly_ragged_page_breaks, "ly:ragged-page-breaks", - 5, 0, 0, (SCM lines, SCM book, SCM text, SCM first, SCM last), - "Return a vector with line numbers of page breaks.") -{ - Paper_book* b = unsmob_paper_book (book); - - SCM_ASSERT_TYPE (scm_pair_p (lines), lines, SCM_ARG1, __FUNCTION__, "list"); - SCM_ASSERT_TYPE (b, book, SCM_ARG2, __FUNCTION__, "Paper_book"); - SCM_ASSERT_TYPE (ly_c_number_p (text), text, SCM_ARG3, __FUNCTION__, "number"); - SCM_ASSERT_TYPE (ly_c_number_p (first), first, SCM_ARG4, __FUNCTION__, "number"); - SCM_ASSERT_TYPE (ly_c_number_p (last), last, SCM_ARG5, __FUNCTION__, "number"); - - return c_ragged_page_breaks (lines, b, - ly_scm2double (text), - ly_scm2double (first), ly_scm2double (last)); -} -#endif - - /****************************************************************/ Score_lines::Score_lines () diff --git a/lily/paper-line.cc b/lily/paper-line.cc deleted file mode 100644 index 75062cc5ac..0000000000 --- a/lily/paper-line.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* - paper-line.cc -- implement Paper_line - - source file of the GNU LilyPond music typesetter - - (c) 2004 Jan Nieuwenhuizen -*/ - -#include "paper-line.hh" -#include "stencil.hh" -#include "string.hh" -#include "virtual-methods.hh" - -#include "ly-smobs.icc" - -IMPLEMENT_SMOBS (Paper_line); -IMPLEMENT_TYPE_P (Paper_line, "ly:paper-line?"); -IMPLEMENT_DEFAULT_EQUAL_P (Paper_line); - - - -Paper_line::Paper_line (Stencil s, bool is_title) -{ - is_title_ = is_title; - number_ = 0; - penalty_ = 0; - smobify_self (); - stencil_ = s; -} - -Paper_line::~Paper_line () -{ -} - -SCM -Paper_line::mark_smob (SCM smob) -{ - Paper_line *line = (Paper_line*) ly_cdr (smob); - return line-> stencil_.expr (); -} - -int -Paper_line::print_smob (SCM smob, SCM port, scm_print_state*) -{ - Paper_line *p = (Paper_line*) ly_cdr (smob); - scm_puts ("#<", port); - scm_puts (classname (p), port); - scm_puts (" ", port); - scm_puts (to_string (p->number_).to_str0 (), port); - scm_puts ("p ", port); - scm_puts (to_string (p->penalty_).to_str0 (), port); - if (p->is_title ()) - scm_puts (" t", port); - scm_puts (" >", port); - return 1; -} - -bool -Paper_line::is_title () const -{ - return is_title_; -} - -Real -Paper_line::penalty () const -{ - return penalty_; -} - -Offset -Paper_line::dim () const -{ - return Offset (stencil_.extent (X_AXIS).length (), - stencil_.extent (Y_AXIS).length ()); -} - -Stencil -Paper_line::to_stencil () const -{ - return stencil_; -} - -LY_DEFINE (ly_paper_line_height, "ly:paper-line-extent", - 2, 0, 0, (SCM line, SCM axis), - "Return the extent of @var{line}.") -{ - Paper_line *pl = unsmob_paper_line (line); - SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line"); - SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); - Axis ax = (Axis)ly_scm2int (axis); - return scm_make_real (pl->dim ()[ax]); -} - - - -LY_DEFINE (ly_paper_line_title_p, "ly:paper-line-title?", - 1, 0, 0, (SCM line), - "Is @var{line} a title line?") -{ - Paper_line *pl = unsmob_paper_line (line); - SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line"); - return SCM_BOOL (pl->is_title ()); -} - -LY_DEFINE (ly_paper_line_number, "ly:paper-line-number", - 1, 0, 0, (SCM line), - "Return the number of @var{line}.") -{ - Paper_line *pl = unsmob_paper_line (line); - SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line"); - return scm_int2num (pl->number_); -} - -LY_DEFINE (ly_paper_line_break_score, "ly:paper-line-break-penalty", - 1, 0, 0, (SCM line), - "Return the score for page break after @var{line}.") -{ - Paper_line *pl = unsmob_paper_line (line); - SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line"); - return scm_int2num (int (pl->penalty ())); -} - -LY_DEFINE (ly_paper_line_stencil, "ly:paper-line-stencil", - 1, 0, 0, (SCM line), - "Return the height of @var{line}.") -{ - Paper_line *pl = unsmob_paper_line (line); - SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-line"); - return pl->to_stencil ().smobbed_copy (); -} - diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 1f91ffd51c..6824f893ca 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -12,24 +12,24 @@ #include "array.hh" #include "dimensions.hh" +#include "file-name.hh" #include "font-metric.hh" #include "input-smob.hh" #include "lily-guile.hh" #include "lily-version.hh" #include "ly-module.hh" #include "main.hh" -#include "paper-book.hh" #include "output-def.hh" -#include "paper-line.hh" +#include "paper-book.hh" #include "paper-outputter.hh" -#include "file-name.hh" +#include "paper-system.hh" #include "scm-hash.hh" #include "stencil.hh" #include "string-convert.hh" #include "warn.hh" -// JUNKME -extern SCM stencil2line (Stencil *stil, bool is_title = false); +#include "ly-smobs.icc" + Paper_outputter::Paper_outputter (String filename, String format) { @@ -49,7 +49,6 @@ Paper_outputter::~Paper_outputter () { } -#include "ly-smobs.icc" IMPLEMENT_SMOBS (Paper_outputter); IMPLEMENT_DEFAULT_EQUAL_P (Paper_outputter); diff --git a/lily/paper-system.cc b/lily/paper-system.cc new file mode 100644 index 0000000000..340667b536 --- /dev/null +++ b/lily/paper-system.cc @@ -0,0 +1,131 @@ +/* + paper-system.cc -- implement Paper_system + + source file of the GNU LilyPond music typesetter + + (c) 2004 Jan Nieuwenhuizen +*/ + +#include "paper-system.hh" +#include "stencil.hh" +#include "string.hh" +#include "virtual-methods.hh" + +#include "ly-smobs.icc" + +IMPLEMENT_SMOBS (Paper_system); +IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?"); +IMPLEMENT_DEFAULT_EQUAL_P (Paper_system); + + + +Paper_system::Paper_system (Stencil s, bool is_title) +{ + is_title_ = is_title; + number_ = 0; + penalty_ = 0; + smobify_self (); + stencil_ = s; +} + +Paper_system::~Paper_system () +{ +} + +SCM +Paper_system::mark_smob (SCM smob) +{ + Paper_system *line = (Paper_system*) ly_cdr (smob); + return line-> stencil_.expr (); +} + +int +Paper_system::print_smob (SCM smob, SCM port, scm_print_state*) +{ + Paper_system *p = (Paper_system*) ly_cdr (smob); + scm_puts ("#<", port); + scm_puts (classname (p), port); + scm_puts (" ", port); + scm_puts (to_string (p->number_).to_str0 (), port); + scm_puts ("p ", port); + scm_puts (to_string (p->penalty_).to_str0 (), port); + if (p->is_title ()) + scm_puts (" t", port); + scm_puts (" >", port); + return 1; +} + +bool +Paper_system::is_title () const +{ + return is_title_; +} + +Real +Paper_system::penalty () const +{ + return penalty_; +} + +Offset +Paper_system::dim () const +{ + return Offset (stencil_.extent (X_AXIS).length (), + stencil_.extent (Y_AXIS).length ()); +} + +Stencil +Paper_system::to_stencil () const +{ + return stencil_; +} + +LY_DEFINE (ly_paper_line_height, "ly:paper-system-extent", + 2, 0, 0, (SCM line, SCM axis), + "Return the extent of @var{line}.") +{ + Paper_system *pl = unsmob_paper_line (line); + SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system"); + SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG2, __FUNCTION__, "axis"); + Axis ax = (Axis)ly_scm2int (axis); + return scm_make_real (pl->dim ()[ax]); +} + + + +LY_DEFINE (ly_paper_line_title_p, "ly:paper-system-title?", + 1, 0, 0, (SCM line), + "Is @var{line} a title line?") +{ + Paper_system *pl = unsmob_paper_line (line); + SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system"); + return SCM_BOOL (pl->is_title ()); +} + +LY_DEFINE (ly_paper_line_number, "ly:paper-system-number", + 1, 0, 0, (SCM line), + "Return the number of @var{line}.") +{ + Paper_system *pl = unsmob_paper_line (line); + SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system"); + return scm_int2num (pl->number_); +} + +LY_DEFINE (ly_paper_line_break_score, "ly:paper-system-break-penalty", + 1, 0, 0, (SCM line), + "Return the score for page break after @var{line}.") +{ + Paper_system *pl = unsmob_paper_line (line); + SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system"); + return scm_int2num (int (pl->penalty ())); +} + +LY_DEFINE (ly_paper_line_stencil, "ly:paper-system-stencil", + 1, 0, 0, (SCM line), + "Return the height of @var{line}.") +{ + Paper_system *pl = unsmob_paper_line (line); + SCM_ASSERT_TYPE (pl, line, SCM_ARG1, __FUNCTION__, "paper-system"); + return pl->to_stencil ().smobbed_copy (); +} + diff --git a/lily/parser.yy b/lily/parser.yy index e2b7bda88b..f5ebfa291c 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -648,8 +648,8 @@ book_body: $$->scores_.push (score); scm_gc_unprotect_object (music->self_scm ()); } - | lilypond_header { - $$->header_ = $1; + | book_body lilypond_header { + $$->header_ = $2; } | book_body error { diff --git a/lily/system.cc b/lily/system.cc index 401cca393a..f8af69c80d 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -23,7 +23,7 @@ #include "spacing-interface.hh" #include "staff-symbol-referencer.hh" #include "paper-book.hh" -#include "paper-line.hh" +#include "paper-system.hh" System::System (SCM s) : Spanner (s) @@ -375,9 +375,7 @@ System::get_line () scm_cons (ly_symbol2scm ("combine-stencil"), exprs)); - Paper_line *pl = new Paper_line (sys_stencil, false); - - + Paper_system *pl = new Paper_system (sys_stencil, false); Item * break_point =this->get_bound(LEFT); pl->penalty_ = diff --git a/ly/book-paper-defaults.ly b/ly/book-paper-defaults.ly index 0158ddeaf1..381d665530 100644 --- a/ly/book-paper-defaults.ly +++ b/ly/book-paper-defaults.ly @@ -36,17 +36,11 @@ (baseline-skip . 2) (word-space . 0.6))) - % #(define page-breaking ly:ragged-page-breaks) #(define page-breaking ly:optimal-page-breaks) #(define page-music-height default-page-music-height ) #(define page-make-stencil default-page-make-stencil ) - - #(define page-to-stencil ly:page-header-lines-footer-stencil) #(define make-header plain-header) #(define make-footer plain-footer) - %%#(define make-footer empty-markup) - #(define make-tagline TAGLINE-or-tagline-from-header) - #(define make-copyright copyright-from-header) } diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 15b0a71a54..8de6a818a1 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -20,7 +20,7 @@ (let* ((systems (ly:score-embedded-format score paper)) (1st (vector-ref systems 0)) - (stencil (ly:paper-line-stencil 1st)) ) + (stencil (ly:paper-system-stencil 1st)) ) (ly:stencil-align-to! stencil Y CENTER) (display (ly:stencil-extent stencil X)) diff --git a/scm/framework-gnome.scm b/scm/framework-gnome.scm index a35f22aa2d..3ad11f4d40 100644 --- a/scm/framework-gnome.scm +++ b/scm/framework-gnome.scm @@ -10,6 +10,10 @@ (guile) (lily)) +;; dump? +(define (dump-page outputter page page-number page-count) + (ly:outputter-dump-stencil outputter page)) + (define-public (output-framework-gnome outputter book scopes fields basename) (let* ((bookpaper (ly:paper-book-book-paper book)) (pages (list->vector (map ly:page-stencil diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 9da75c91cb..6787a0d04c 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -202,12 +202,12 @@ (y 0.0) (scale (* 2.83464 (ly:output-def-lookup bookpaper 'outputscale))) (total-y - (apply + (map (lambda (z) (ly:paper-line-extent z Y)) lines))) + (apply + (map (lambda (z) (ly:paper-system-extent z Y)) lines))) (x-ext '(-8 . 0)) (lineno 0)) (define (dump-line outputter system) - (let ((stil (ly:paper-line-stencil system))) + (let ((stil (ly:paper-system-stencil system))) (ly:outputter-dump-string outputter @@ -215,7 +215,7 @@ " 0.0 " (ly:number->string y) " start-system {\n set-ps-scale-to-lily-scale\n")) - (set! y (+ y (ly:paper-line-extent system Y))) + (set! y (+ y (ly:paper-system-extent system Y))) (ly:outputter-dump-stencil outputter stil) (ly:outputter-dump-string outputter @@ -235,7 +235,7 @@ (for-each (lambda (ell) (set! x-ext (interval-union x-ext - (cons 0.0 (ly:paper-line-extent ell X))))) + (cons 0.0 (ly:paper-system-extent ell X))))) lines) (for-each diff --git a/scm/framework-tex.scm b/scm/framework-tex.scm index 57eaa677cd..5b157a7202 100644 --- a/scm/framework-tex.scm +++ b/scm/framework-tex.scm @@ -171,10 +171,10 @@ (ly:outputter-dump-string putter (string-append "\\leavevmode\n\\lybox{0}{0}{0}{" - (ly:number->string (ly:paper-line-extent line Y)) + (ly:number->string (ly:paper-system-extent line Y)) "}{")) - (ly:outputter-dump-stencil putter (ly:paper-line-stencil line)) + (ly:outputter-dump-stencil putter (ly:paper-system-stencil line)) (ly:outputter-dump-string putter (if last? diff --git a/scm/lily.scm b/scm/lily.scm index e12af1a81e..945f26fb41 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -456,6 +456,7 @@ L1 is copied, L2 not. "define-grobs.scm" "define-grob-interfaces.scm" "page-layout.scm" + "titling.scm" "paper.scm" diff --git a/scm/page-layout.scm b/scm/page-layout.scm index 7eb7298967..6f56886465 100644 --- a/scm/page-layout.scm +++ b/scm/page-layout.scm @@ -33,55 +33,62 @@ ;; TODO: take iso. page-number ;; for all of these functions ? -(define-public (TAGLINE-or-tagline-from-header paper scopes) - (let* ((props (page-properties paper)) - (tagline-var (ly:modules-lookup scopes 'tagline)) - (tagline (if (markup? tagline-var) tagline-var TAGLINE))) +(define-public (plain-header paper scopes page-number last?) + "Standard header for a part: page number --outside-- and instrument--centered." - (cond ((string? tagline) - (if (not (equal? tagline "")) - (interpret-markup paper props - (markup #:fill-line (tagline ""))))) - ((markup? tagline) (interpret-markup paper props tagline))))) + (let* ((props (page-properties paper) ) + (pnum (markup #:bold (number->string page-number))) + (instr (ly:modules-lookup scopes 'instrument)) + (line (list "" (if (markup? instr) instr "") pnum))) -(define-public (copyright-from-header paper scopes) - (let ((props (page-properties paper)) - (copyright (ly:modules-lookup scopes 'copyright))) - - (cond ((string? copyright) - (if (not (equal? copyright "")) - (interpret-markup paper props - (markup #:fill-line (copyright ""))))) - ((markup? copyright) (interpret-markup paper props copyright))))) + (if (even? page-number) + (set! line (reverse line))) + (if (< 1 page-number) + (interpret-markup + paper props (make-fill-line-markup line)) + '()) + )) -;; TODO: add instrument name. -(define-public (plain-header paper scopes page-number) - (let ((props (page-properties paper) )) - (interpret-markup paper props - (markup #:fill-line - ("" #:bold (number->string page-number)))))) +;; TODO: add publisher ID on non-first page. +(define-public (plain-footer paper scopes page-number last?) + "Standard footer. Empty, save for first (copyright) and last (tagline) page." + + (let* + ((props (page-properties paper)) + (copyright (ly:modules-lookup scopes 'copyright)) + (tagline-var (ly:modules-lookup scopes 'tagline)) + (tagline (if (markup? tagline-var) tagline-var TAGLINE)) + (stencil #f)) + + (if last? + (set! stencil + (ly:stencil-combine-at-edge + stencil Y DOWN (interpret-markup paper props tagline) + 0.0 + ))) -; TODO: insert tagline and/or copyright -(define-public (plain-footer paper scopes page-number) - (let ((props (page-properties paper))) + (if (and (= 1 page-number) + (markup? copyright)) + (set! stencil + (ly:stencil-combine-at-edge + stencil Y DOWN (interpret-markup paper props copyright) + 0.0 + ))) - ;; page number already in header. - '() - - )) + stencil)) - -(define (page-headfoot paper scopes number sym sepsym dir) +(define (page-headfoot paper scopes number sym sepsym dir last?) + "Create a stencil including separating space." (let* ((header-proc (ly:output-def-lookup paper sym)) (sep (ly:output-def-lookup paper sepsym)) (stencil (ly:make-stencil "" '(0 . 0) '(0 . 0))) (head-stencil (if (procedure? header-proc) - (header-proc paper scopes number) + (header-proc paper scopes number last?) #f))) (if (and (number? sep) (ly:stencil? head-stencil)) @@ -93,13 +100,13 @@ head-stencil)) (define-public (default-page-music-height paper scopes number last?) + "Printable area for music and titles; matches default-page-make-stencil." (let* ((h (- (ly:output-def-lookup paper 'vsize) (ly:output-def-lookup paper 'top-margin) (ly:output-def-lookup paper 'bottom-margin))) - (head (page-headfoot paper scopes number 'make-header 'head-sep UP)) - (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN)) - ) + (head (page-headfoot paper scopes number 'make-header 'head-sep UP last?)) + (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN last?))) (- h (if (ly:stencil? head) (interval-length (ly:stencil-extent head Y)) 0) @@ -110,29 +117,29 @@ (define-public (default-page-make-stencil lines paper scopes number last? ) + "Construct a stencil representing the page from LINES. " (let* - ( - (top-margin (ly:output-def-lookup paper 'top-margin)) + ((top-margin (ly:output-def-lookup paper 'top-margin)) - ;; TODO: naming vsize/hsize not analogous to TeX. + ;; TODO: naming vsize/hsize not analogous to TeX. (hsize (ly:output-def-lookup paper 'hsize)) - (left-margin (- hsize - (/ (ly:output-def-lookup paper 'linewidth) 2))) + (left-margin (/ (- hsize + (ly:output-def-lookup paper 'linewidth)) 2)) (vsize (ly:output-def-lookup paper 'vsize)) (bottom-edge (- vsize (ly:output-def-lookup paper 'bottom-margin))) - (head (page-headfoot paper scopes number 'make-header 'head-sep UP)) - (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN)) - (line-stencils (map ly:paper-line-stencil lines)) + (head (page-headfoot paper scopes number 'make-header 'head-sep UP last?)) + (foot (page-headfoot paper scopes number 'make-footer 'foot-sep DOWN last?)) + (line-stencils (map ly:paper-system-stencil lines)) (height-proc (ly:output-def-lookup paper 'page-music-height)) (music-height (height-proc paper scopes number last?)) (spc-left (- music-height (apply + (map (lambda (x) (interval-length (ly:stencil-extent x Y))) line-stencils)))) - (stretchable-lines (remove ly:paper-line-title? (cdr lines))) + (stretchable-lines (remove ly:paper-system-title? (cdr lines))) (stretch (if (null? stretchable-lines) 0.0 (/ spc-left (length stretchable-lines)))) @@ -149,13 +156,13 @@ (lambda (l) (set! page-stencil (ly:stencil-combine-at-edge - page-stencil Y DOWN (ly:paper-line-stencil l) + page-stencil Y DOWN (ly:paper-system-stencil l) (if was-title 0.0 stretch) )) - (set! was-title (ly:paper-line-title? l))) + (set! was-title (ly:paper-system-title? l))) lines) (if (ly:stencil? foot) @@ -165,9 +172,10 @@ (ly:stencil-translate foot (cons 0 - (+ bottom-edge (- (car (ly:stencil-extent foot Y))))) + (+ (- bottom-edge) (- (car (ly:stencil-extent foot Y))))) )))) - page-stencil + + (ly:stencil-translate page-stencil (cons left-margin 0)) )) @@ -181,19 +189,13 @@ ; TODO: ; ; - density scoring -; +; - separate function for word-wrap style breaking? +; - raggedbottom? raggedlastbottom? -;; TODO: first-diff and last-diff are slightly arbitrary interface -;; For the future, we might want to invoke a function from PAPER-BOOK to -;; determine available height given (define-public (ly:optimal-page-breaks lines paper-book) "Return pages as a list starting with 1st page. Each page is a list -of lines. - -TEXT-HEIGHT is the height of the printable area, FIRST-DIFF and -LAST-DIFF are decrements for the 1st and last page. PAPER-BOOK is -unused, at the moment." +of lines. " (define (make-node prev lines page-num penalty) (make @@ -206,7 +208,7 @@ unused, at the moment." (define bookpaper (ly:paper-book-book-paper paper-book)) (define scopes (ly:paper-book-scopes paper-book)) (define (line-height line) - (ly:paper-line-extent line Y)) + (ly:paper-system-extent line Y)) ;; FIXME: may need some tweaking: square, cubic (define (height-penalty available used) @@ -225,7 +227,7 @@ unused, at the moment." (define (page-height page-number last?) (let - ((p (ly:output-def-lookup bookpaper 'page-height-function))) + ((p (ly:output-def-lookup bookpaper 'page-music-height))) (if (procedure? p) (p bookpaper scopes page-number last?) @@ -262,7 +264,7 @@ CURRENT-BEST is the best result sofar, or #f." (page-height (page-height this-page-num last?)) (space-used (cumulative-height current-lines)) (this-page-penalty (height-penalty page-height space-used)) - (user-penalty (ly:paper-line-break-penalty (car current-lines))) + (user-penalty (ly:paper-system-break-penalty (car current-lines))) (total-penalty (combine-penalties user-penalty this-page-penalty prev-penalty)) (better? (or @@ -309,7 +311,7 @@ DONE." (cdr todo))))) (define (line-number node) - (ly:paper-line-number (car (node-lines node)))) + (ly:paper-system-number (car (node-lines node)))) (let* ((best-break-node (walk-lines '() '() lines)) (break-nodes (get-path best-break-node '())) @@ -331,3 +333,5 @@ DONE." (node-page-number node) (eq? node best-break-node))) break-nodes))) + + diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm index dc591b523e..f0dbaab503 100644 --- a/scm/safe-lily.scm +++ b/scm/safe-lily.scm @@ -88,18 +88,15 @@ ly:output-def-clone ly:output-def-scope ly:output-description - ly:page-header-lines-footer-stencil - ly:page-paper-lines - ly:page? ly:paper-book? ly:paper-def? ly:paper-get-font ly:paper-get-number - ly:paper-line-break-penalty - ly:paper-line-extent - ly:paper-line-number - ly:paper-line-stencil - ly:paper-line? + ly:paper-system-break-penalty + ly:paper-system-extent + ly:paper-system-number + ly:paper-system-stencil + ly:paper-system? ly:output-def-lookup ly:parse-string ly:parser-parse-string