Use is-last-bookpart and is-bookpart-last-page properties everywhere,
instead of confusing different names.
%% book paper, which is inherited by all children bookparts
\paper {
%% book paper, which is inherited by all children bookparts
\paper {
- id = "\nbook level paper\n"
ragged-last-bottom = ##t
%% Page footer: add a different part-tagline at part last page
oddFooterMarkup = \markup {
ragged-last-bottom = ##t
%% Page footer: add a different part-tagline at part last page
oddFooterMarkup = \markup {
Real
Page_breaking::page_height (int page_num, bool last) const
{
Real
Page_breaking::page_height (int page_num, bool last) const
{
- bool last_part = ly_scm2bool (book_->paper_->c_variable ("part-is-last"));
+ bool last_part = ly_scm2bool (book_->paper_->c_variable ("is-last-bookpart"));
SCM mod = scm_c_resolve_module ("scm page");
SCM calc_height = scm_c_module_lookup (mod, "calc-printable-height");
SCM make_page = scm_c_module_lookup (mod, "make-page");
SCM mod = scm_c_resolve_module ("scm page");
SCM calc_height = scm_c_module_lookup (mod, "calc-printable-height");
SCM make_page = scm_c_module_lookup (mod, "make-page");
SCM page = scm_apply_0 (make_page, scm_list_n (
book_->self_scm (),
ly_symbol2scm ("page-number"), scm_from_int (page_num),
SCM page = scm_apply_0 (make_page, scm_list_n (
book_->self_scm (),
ly_symbol2scm ("page-number"), scm_from_int (page_num),
- ly_symbol2scm ("is-last"), scm_from_bool (last_part && last),
- ly_symbol2scm ("is-part-last"), scm_from_bool (last),
+ ly_symbol2scm ("is-last-bookpart"), scm_from_bool (last_part),
+ ly_symbol2scm ("is-bookpart-last-page"), scm_from_bool (last),
SCM_UNDEFINED));
SCM height = scm_apply_1 (calc_height, page, SCM_EOL);
return scm_to_double (height) - page_top_space_;
SCM_UNDEFINED));
SCM height = scm_apply_1 (calc_height, page, SCM_EOL);
return scm_to_double (height) - page_top_space_;
SCM book = book_->self_scm ();
int first_page_number
= robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1);
SCM book = book_->self_scm ();
int first_page_number
= robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1);
- bool last_part = ly_scm2bool (book_->paper_->c_variable ("part-is-last"));
+ bool last_bookpart = ly_scm2bool (book_->paper_->c_variable ("is-last-bookpart"));
SCM ret = SCM_EOL;
SCM label_page_table = book_->top_paper ()->c_variable ("label-page-table");
if (label_page_table == SCM_UNDEFINED)
SCM ret = SCM_EOL;
SCM label_page_table = book_->top_paper ()->c_variable ("label-page-table");
if (label_page_table == SCM_UNDEFINED)
for (vsize i = 0; i < lines_per_page.size (); i++)
{
SCM page_num = scm_from_int (i + first_page_number);
for (vsize i = 0; i < lines_per_page.size (); i++)
{
SCM page_num = scm_from_int (i + first_page_number);
- bool last_from_part = (i == lines_per_page.size () - 1);
- bool last_from_book = (last_part && last_from_part);
- SCM rag = scm_from_bool (ragged () || (last_from_part && ragged_last ()));
+ bool partbook_last_page = (i == lines_per_page.size () - 1);
+ SCM rag = scm_from_bool (ragged () || ( partbook_last_page && ragged_last ()));
SCM line_count = scm_from_int (lines_per_page[i]);
SCM lines = scm_list_head (systems, line_count);
SCM page = scm_apply_0 (make_page,
scm_list_n (book, lines, page_num, rag,
SCM line_count = scm_from_int (lines_per_page[i]);
SCM lines = scm_list_head (systems, line_count);
SCM page = scm_apply_0 (make_page,
scm_list_n (book, lines, page_num, rag,
- scm_from_bool (last_from_book),
- scm_from_bool (last_from_part),
+ scm_from_bool (last_bookpart),
+ scm_from_bool (partbook_last_page),
SCM_UNDEFINED));
/* collect labels */
for (SCM l = lines ; scm_is_pair (l) ; l = scm_cdr (l))
SCM_UNDEFINED));
/* collect labels */
for (SCM l = lines ; scm_is_pair (l) ; l = scm_cdr (l))
return;
paper_->set_variable (ly_symbol2scm ("first-page-number"),
scm_long2num (*first_page_number));
return;
paper_->set_variable (ly_symbol2scm ("first-page-number"),
scm_long2num (*first_page_number));
- paper_->set_variable (ly_symbol2scm ("part-is-last"),
+ paper_->set_variable (ly_symbol2scm ("is-last-bookpart"),
ly_bool2scm (is_last));
/* Generate all stencils to trigger font loads. */
*first_page_number += scm_ilength (pages ());
ly_bool2scm (is_last));
/* Generate all stencils to trigger font loads. */
*first_page_number += scm_ilength (pages ());
empty-stencil))
#(define (last-page layout props arg)
empty-stencil))
#(define (last-page layout props arg)
- (if (chain-assoc-get 'page:last? props #f)
- (interpret-markup layout props arg)
- empty-stencil))
+ (if (and (chain-assoc-get 'page:is-bookpart-last-page props #f)
+ (chain-assoc-get 'page:is-last-bookpart props #f))
+ (interpret-markup layout props arg)
+ empty-stencil))
+
+#(define (not-first-page layout props arg)
+ (define (ancestor layout)
+ "Return the topmost layout ancestor"
+ (let ((parent (ly:output-def-parent layout)))
+ (if (not (ly:output-def? parent))
+ layout
+ (ancestor parent))))
+ (if (not (= (chain-assoc-get 'page:page-number props -1)
+ (ly:output-def-lookup (ancestor layout) 'first-page-number)))
+ (interpret-markup layout props arg)
+ empty-stencil))
-%% Part first page and last page predicates
+%% Bookpart first page and last page predicates
#(define (part-first-page layout props arg)
(if (= (chain-assoc-get 'page:page-number props -1)
(ly:output-def-lookup layout 'first-page-number))
#(define (part-first-page layout props arg)
(if (= (chain-assoc-get 'page:page-number props -1)
(ly:output-def-lookup layout 'first-page-number))
empty-stencil))
#(define (part-last-page layout props arg)
empty-stencil))
#(define (part-last-page layout props arg)
- (if (chain-assoc-get 'page:part-last? props #f)
- (interpret-markup layout props arg)
- empty-stencil))
-
-#(define (not-first-page layout props arg)
- (if (not (= (chain-assoc-get 'page:page-number props -1)
- (ly:output-def-lookup layout 'first-page-number)))
- (interpret-markup layout props arg)
- empty-stencil))
+ (if (chain-assoc-get 'page:is-bookpart-last-page props #f)
+ (interpret-markup layout props arg)
+ empty-stencil))
%% unused
#(define (not-single-page layout props arg)
%% unused
#(define (not-single-page layout props arg)
(= (interval-start system-extent)
(interval-end system-extent))))))
(= (interval-start system-extent)
(interval-end system-extent))))))
-(define (stretch-and-draw-page paper-book systems page-number ragged book-last part-last)
+(define (stretch-and-draw-page paper-book systems page-number ragged
+ is-last-bookpart is-bookpart-last-page)
(define (max-stretch sys)
(if (ly:grob? sys)
(ly:grob-property sys 'max-stretch)
(define (max-stretch sys)
(if (ly:grob? sys)
(ly:grob-property sys 'max-stretch)
(let* ((page (make-page paper-book
'page-number page-number
(let* ((page (make-page paper-book
'page-number page-number
- 'is-last book-last
- 'is-part-last part-last))
+ 'is-last-bookpart is-last-bookpart
+ 'is-bookpart-last-page is-bookpart-last-page))
(paper (ly:paper-book-paper paper-book))
(height (page-printable-height page))
; there is a certain amount of impreciseness going on here:
(paper (ly:paper-book-paper paper-book))
(height (page-printable-height page))
; there is a certain amount of impreciseness going on here:
inter-system-space))
user)))
inter-system-space))
user)))
-(define (walk-paths done-lines best-paths current-lines is-last-part
- is-last-page current-best paper-book page-alist)
+(define (walk-paths done-lines best-paths current-lines is-last-bookpart
+ is-bookpart-last-page current-best paper-book page-alist)
"Return the best optimal-page-break-node that contains
CURRENT-LINES. DONE-LINES.reversed ++ CURRENT-LINES is a consecutive
ascending range of lines, and BEST-PATHS contains the optimal breaks
"Return the best optimal-page-break-node that contains
CURRENT-LINES. DONE-LINES.reversed ++ CURRENT-LINES is a consecutive
ascending range of lines, and BEST-PATHS contains the optimal breaks
(let* ((paper (ly:paper-book-paper paper-book))
(this-page (make-page
paper-book
(let* ((paper (ly:paper-book-paper paper-book))
(this-page (make-page
paper-book
- 'is-last (and is-last-part is-last-page)
- 'is-part-last is-last-page
+ 'is-last-bookpart is-last-bookpart
+ 'is-bookpart-last-page is-bookpart-last-page
'page-number (if (null? best-paths)
(ly:output-def-lookup paper 'first-page-number)
(1+ (page-page-number (first best-paths))))))
(ragged-all (eq? #t (ly:output-def-lookup paper 'ragged-bottom)))
(ragged-last (eq? #t (ly:output-def-lookup paper 'ragged-last-bottom)))
'page-number (if (null? best-paths)
(ly:output-def-lookup paper 'first-page-number)
(1+ (page-page-number (first best-paths))))))
(ragged-all (eq? #t (ly:output-def-lookup paper 'ragged-bottom)))
(ragged-last (eq? #t (ly:output-def-lookup paper 'ragged-last-bottom)))
- (ragged (or ragged-all (and ragged-last is-last-page)))
+ (ragged (or ragged-all (and ragged-last is-bookpart-last-page)))
(space-to-fill (page-maximum-space-to-fill this-page current-lines paper))
(vertical-spacing (space-systems space-to-fill current-lines ragged paper #f))
(satisfied-constraints (car vertical-spacing))
(force (if satisfied-constraints
(space-to-fill (page-maximum-space-to-fill this-page current-lines paper))
(vertical-spacing (space-systems space-to-fill current-lines ragged paper #f))
(satisfied-constraints (car vertical-spacing))
(force (if satisfied-constraints
- (if (and is-last-page ragged-last)
+ (if (and is-bookpart-last-page ragged-last)
0.0
satisfied-constraints)
10000))
0.0
satisfied-constraints)
10000))
(list
"\nuser pen " user-penalty
"\nsatisfied-constraints" satisfied-constraints
(list
"\nuser pen " user-penalty
"\nsatisfied-constraints" satisfied-constraints
- "\nlast? " is-last-page "ragged?" ragged
+ "\nlast? " is-bookpart-last-page "ragged?" ragged
"\nis-better " is-better " total-penalty " total-penalty "\n"
"\nconfig " positions
"\nforce " force
"\nis-better " is-better " total-penalty " total-penalty "\n"
"\nconfig " positions
"\nforce " force
satisfied-constraints)
(walk-paths (cdr done-lines) (cdr best-paths)
(cons (car done-lines) current-lines)
satisfied-constraints)
(walk-paths (cdr done-lines) (cdr best-paths)
(cons (car done-lines) current-lines)
- is-last-part is-last-page new-best
+ is-last-bookpart is-bookpart-last-page new-best
paper-book page-alist)
new-best)))
paper-book page-alist)
new-best)))
-(define (walk-lines done best-paths todo paper-book page-alist is-last-part)
+(define (walk-lines done best-paths todo paper-book page-alist is-last-bookpart)
"Return the best page breaking as a single
page node for optimally breaking TODO ++
DONE.reversed. BEST-PATHS is a list of break nodes corresponding to
"Return the best page breaking as a single
page node for optimally breaking TODO ++
DONE.reversed. BEST-PATHS is a list of break nodes corresponding to
(if (null? todo)
(car best-paths)
(let* ((this-line (car todo))
(if (null? todo)
(car best-paths)
(let* ((this-line (car todo))
- (is-last-page (null? (cdr todo)))
- (next (walk-paths done best-paths (list this-line) is-last-part
- is-last-page #f paper-book page-alist)))
+ (is-bookpart-last-page (null? (cdr todo)))
+ (next (walk-paths done best-paths (list this-line) is-last-bookpart
+ is-bookpart-last-page #f paper-book page-alist)))
(walk-lines (cons this-line done)
(cons next best-paths)
(cdr todo)
paper-book
page-alist
(walk-lines (cons this-line done)
(cons next best-paths)
(cdr todo)
paper-book
page-alist
(define-public (optimal-page-breaks paper-book)
"Return pages as a list starting with 1st page. Each page is a 'page Prob."
(define-public (optimal-page-breaks paper-book)
"Return pages as a list starting with 1st page. Each page is a 'page Prob."
(page-alist (layout->page-init paper))
(force-equalization-factor (ly:output-def-lookup
paper 'verticalequalizationfactor 0.3))
(page-alist (layout->page-init paper))
(force-equalization-factor (ly:output-def-lookup
paper 'verticalequalizationfactor 0.3))
- (part-is-last (ly:output-def-lookup paper 'part-is-last)))
+ (is-last-bookpart (ly:output-def-lookup paper 'is-last-bookpart)))
(ly:message (_ "Calculating page breaks..."))
(ly:message (_ "Calculating page breaks..."))
- (let* ((best-break-node (walk-lines '() '() lines paper-book page-alist part-is-last))
+ (let* ((best-break-node (walk-lines '() '() lines paper-book page-alist is-last-bookpart))
(break-nodes (get-path best-break-node '())))
(break-nodes (get-path best-break-node '())))
- ;(page-set-property! (car (last-pair break-nodes)) 'is-last part-is-last)
- ;(page-set-property! (car (last-pair break-nodes)) 'is-part-last #t)
(if #f; (ly:get-option 'verbose)
(begin
(display (list
(if #f; (ly:get-option 'verbose)
(begin
(display (list
(define (page-headfoot layout scopes number sym separation-symbol dir
(define (page-headfoot layout scopes number sym separation-symbol dir
- is-book-last-page is-part-last-page)
+ is-last-bookpart is-bookpart-last-page)
"Create a stencil including separating space."
"Create a stencil including separating space."
(stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
(head-stencil
(if (procedure? header-proc)
(stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
(head-stencil
(if (procedure? header-proc)
- (header-proc layout scopes number is-book-last-page is-part-last-page)
+ (header-proc layout scopes number is-last-bookpart is-bookpart-last-page)
#f)))
(if (and (number? sep)
#f)))
(if (and (number? sep)
(layout (ly:paper-book-paper paper-book))
(scopes (ly:paper-book-scopes paper-book))
(number (page-page-number page))
(layout (ly:paper-book-paper paper-book))
(scopes (ly:paper-book-scopes paper-book))
(number (page-page-number page))
- (is-book-last-page (page-property page 'is-last))
- (is-part-last-page (page-property page 'is-part-last)))
+ (is-last-bookpart (page-property page 'is-last-bookpart))
+ (is-bookpart-last-page (page-property page 'is-bookpart-last-page)))
(page-headfoot layout scopes number
(if (= dir UP)
(page-headfoot layout scopes number
(if (= dir UP)
(if (= dir UP)
'head-separation
'foot-separation)
(if (= dir UP)
'head-separation
'foot-separation)
- dir is-book-last-page is-part-last-page)))
+ dir is-last-bookpart is-bookpart-last-page)))
(define (page-header page)
(page-header-or-footer page UP))
(define (page-header page)
(page-header-or-footer page UP))
;;;;;;;;;;;;;;;;;;
(define-public ((marked-up-headfoot what-odd what-even)
;;;;;;;;;;;;;;;;;;
(define-public ((marked-up-headfoot what-odd what-even)
- layout scopes page-number is-book-last-page is-part-last-page)
+ layout scopes page-number is-last-bookpart is-bookpart-last-page)
"Read variables WHAT-ODD, WHAT-EVEN from LAYOUT, and interpret them
as markup. The PROPS argument will include variables set in SCOPES and
"Read variables WHAT-ODD, WHAT-EVEN from LAYOUT, and interpret them
as markup. The PROPS argument will include variables set in SCOPES and
-page:last?, page:page-number-string and page:page-number
-"
+page:is-bookpart-last-page, page:is-last-bookpart, page:page-number-string
+and page:page-number"
(define (get sym)
(ly:output-def-lookup layout sym))
(define (get sym)
(ly:output-def-lookup layout sym))
(cons 'header:tagline
(ly:modules-lookup scopes 'tagline
(ly:output-def-lookup layout 'tagline)))
(cons 'header:tagline
(ly:modules-lookup scopes 'tagline
(ly:output-def-lookup layout 'tagline)))
- (cons 'page:last? is-book-last-page)
- (cons 'page:part-last? is-part-last-page)
+ (cons 'page:is-last-bookpart is-last-bookpart)
+ (cons 'page:is-bookpart-last-page is-bookpart-last-page)
(cons 'page:page-number-string
(number->string page-number))
(cons 'page:page-number page-number)))
(cons 'page:page-number-string
(number->string page-number))
(cons 'page:page-number page-number)))
(list pgnum-alist)
prefixed-alists
(layout-extract-page-properties layout))))
(list pgnum-alist)
prefixed-alists
(layout-extract-page-properties layout))))
(interpret-markup layout props potential-markup))
empty-stencil))
(interpret-markup layout props potential-markup))
empty-stencil))