]> git.donarmstrong.com Git - lilypond.git/commitdiff
Vertical spacing: limit space between systems, using paper variables
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Wed, 18 Jul 2007 17:32:25 +0000 (19:32 +0200)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Wed, 18 Jul 2007 17:32:25 +0000 (19:32 +0200)
page-limit-inter-system-space and
page-limit-inter-system-space-factor.

Documentation/user/spacing.itely
input/regression/page-limited-space.ly [new file with mode: 0644]
ly/paper-defaults.ly
scm/layout-page-layout.scm

index ca9bb618c51796aea84ce52a98f067707331e43a..7531a858e739261dfdeaa9ab7cb9dcebee2a57b5 100644 (file)
@@ -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 (file)
index 0000000..6d16eea
--- /dev/null
@@ -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 } >>
+}
index 8ea1159204f405341fc84ce6487680f28fa1c8fe..8eb3a24f200eb7aa3f4cc61cdbecb81b6ae932a5 100644 (file)
     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)))
 
index 91742ef315f98319e9d017aa4a1021af2ed79539..1c18751edc6650eadccb9af7505291e47f44119e 100644 (file)
@@ -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.
                                         (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)
       ;; 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)))))
                         '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)
       (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)
                            (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
 ;;;