From: Nicolas Sceaux Date: Wed, 18 Jul 2007 17:32:25 +0000 (+0200) Subject: Vertical spacing: limit space between systems, using paper variables X-Git-Tag: release/2.11.28-1^2~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2d817f0288ab1e90fe6258aeae34d9466043cdbf;p=lilypond.git Vertical spacing: limit space between systems, using paper variables page-limit-inter-system-space and page-limit-inter-system-space-factor. --- diff --git a/Documentation/user/spacing.itely b/Documentation/user/spacing.itely index ca9bb618c5..7531a858e7 100644 --- a/Documentation/user/spacing.itely +++ b/Documentation/user/spacing.itely @@ -1044,6 +1044,42 @@ Space between systems are controlled by four @code{\paper} variables, @} @end example +When only a couple of flat systems are placed on a page, the resulting +vertical spacing may be non-eleguant: one system at the top of the page, +and the other at the bottom, with a huge gap between them. To avoid this +situation, the space added between the systems can be limited. This +feature is activated by setting to @code{#t} the +@code{page-limit-inter-system-space} variable in the @code{\paper} +block. The paper variable @code{page-limit-inter-system-space-factor} +determines how much the space can be increased: for instance, the value +@code{1.3} means that the space can be 30% larger than what it would be +on a ragged-bottom page. + +In the following example, if the inter system space were not limited, +the second system of page 1 would be placed at the page bottom. By +activating the space limitation, the second system is placed closer to +the first one. By setting @code{page-limit-inter-system-space-factor} to +@code{1}, the spacing would the same as on a ragged-bottom page, like +the last one. + +@lilypond[verbatim] +#(set-default-paper-size "a6") +\book { + \paper { + page-limit-inter-system-space = ##t + page-limit-inter-system-space-factor = 1.3 + + oddFooterMarkup = \markup "page bottom" + evenFooterMarkup = \markup "page bottom" + oddHeaderMarkup = \markup \fill-line { + "page top" \fromproperty #'page:page-number-string } + evenHeaderMarkup = \markup \fill-line { + "page top" \fromproperty #'page:page-number-string } + } + \new Staff << \repeat unfold 4 { g'4 g' g' g' \break } + { s1*2 \pageBreak } >> +} +@end lilypond @node Explicit staff and system positioning @subsection Explicit staff and system positioning diff --git a/input/regression/page-limited-space.ly b/input/regression/page-limited-space.ly new file mode 100644 index 0000000000..6d16eeacd8 --- /dev/null +++ b/input/regression/page-limited-space.ly @@ -0,0 +1,26 @@ +\version "2.11.27" +#(set-default-paper-size "a6") + +\header { + texidoc = "The space between systems can be limited when there is too +much space left on the page by setting @code{page-limit-inter-system-space}." +} + +\book { + \paper { + page-limit-inter-system-space = ##t + page-limit-inter-system-space-factor = 1.4 + + ragged-last-bottom = ##f + + oddFooterMarkup = \markup "page bottom" + evenFooterMarkup = \markup "page bottom" + oddHeaderMarkup = \markup \fill-line { + "page top" \fromproperty #'page:page-number-string } + evenHeaderMarkup = \markup \fill-line { + "page top" \fromproperty #'page:page-number-string } + } + \new Staff << \repeat unfold 9 { g'4 g' g' g' \break } + { s1*2 \pageBreak + s1*3 \pageBreak } >> +} diff --git a/ly/paper-defaults.ly b/ly/paper-defaults.ly index 8ea1159204..8eb3a24f20 100644 --- a/ly/paper-defaults.ly +++ b/ly/paper-defaults.ly @@ -82,6 +82,12 @@ blank-last-page-force = 0 blank-page-force = 2 + %% + %% To limit space between systems on a page with a lot of space left + %% + page-limit-inter-system-space = ##f + page-limit-inter-system-space-factor = 1.4 + #(define font-defaults '((font-encoding . fetaMusic))) diff --git a/scm/layout-page-layout.scm b/scm/layout-page-layout.scm index 91742ef315..1c18751edc 100644 --- a/scm/layout-page-layout.scm +++ b/scm/layout-page-layout.scm @@ -21,7 +21,6 @@ line-minimum-distance line-ideal-distance first-line-position line-ideal-relative-position line-minimum-relative-position - line-minimum-position-on-page page-maximum-space-to-fill page-maximum-space-left space-systems)) ; this is for 2-pass spacing. Delete me. @@ -102,21 +101,29 @@ (filter stretchable? systems))) height-left)) - (let* ((lines (map print-system systems)) - (posns (if (null? lines) - (list) - (let* ((paper (ly:paper-book-paper paper-book)) - (space-to-fill (page-maximum-space-to-fill - page lines paper)) - (spacing (space-systems space-to-fill lines ragged paper #f))) - (if (and (> (length lines) 1) - (or (not (car spacing)) (inf? (car spacing)))) - (begin - (ly:warning (_ "Can't fit systems on page -- ignoring between-system-padding")) - (cdr (space-systems space-to-fill lines ragged paper #t))) - (cdr spacing)))))) + (let ((lines (map print-system systems))) (page-set-property! page 'lines lines) - (page-set-property! page 'configuration posns) + (page-set-property! + page 'configuration + (if (null? lines) + (list) + (let* ((paper (ly:paper-book-paper paper-book)) + (max-space-to-fill (page-maximum-space-to-fill page lines paper)) + (space-to-fill (if (ly:output-def-lookup + paper 'page-limit-inter-system-space #f) + (min max-space-to-fill + (* (ly:output-def-lookup + paper 'page-limit-inter-system-space-factor 1.4) + (- max-space-to-fill + (or (page-ideal-space-left page) 0)))) + max-space-to-fill)) + (spacing (space-systems space-to-fill lines ragged paper #f))) + (if (and (> (length lines) 1) + (or (not (car spacing)) (inf? (car spacing)))) + (begin + (ly:warning (_ "Can't fit systems on page -- ignoring between-system-padding")) + (cdr (space-systems space-to-fill lines ragged paper #t))) + (cdr spacing))))) page))) (define (page-breaking-wrapper paper-book) @@ -229,12 +236,12 @@ ;; not the first line on page (line-minimum-distance prev-line line layout ignore-padding))) -(define (line-minimum-position-on-page line prev-line prev-position page) +(define (line-position-on-page line prev-line prev-position page relative-positionning-fn) "If `line' fits on `page' after `prev-line', which position on page is `prev-position', then return the line's postion on page, otherwise #f. `prev-line' can be #f, meaning that `line' is the first line." (let* ((layout (ly:paper-book-paper (page-property page 'paper-book))) - (position (+ (line-minimum-relative-position line prev-line layout #f) + (position (+ (relative-positionning-fn line prev-line layout #f) (if prev-line prev-position 0.0))) (bottom-position (- position (interval-start (line-extent line))))) @@ -253,7 +260,7 @@ 'bottom-space 0.0) (- (interval-start (line-extent last-line)))))) -(define (page-maximum-space-left page) +(define (page-space-left page relative-positionning-fn) (let ((paper (ly:paper-book-paper (page-property page 'paper-book)))) (let bottom-position ((lines (page-property page 'lines)) (prev-line #f) @@ -261,8 +268,8 @@ (if (null? lines) (page-printable-height page) (let* ((line (first lines)) - (position (line-minimum-position-on-page - line prev-line prev-position page))) + (position (line-position-on-page + line prev-line prev-position page relative-positionning-fn))) (if (null? (cdr lines)) (and position (- (page-printable-height page) @@ -270,6 +277,12 @@ (interval-start (line-extent line))))) (bottom-position (cdr lines) line position))))))) +(define (page-maximum-space-left page) + (page-space-left page line-minimum-relative-position)) + +(define (page-ideal-space-left page) + (page-space-left page line-ideal-relative-position)) + ;;; ;;; Utilities for distributing systems on a page ;;;