]> git.donarmstrong.com Git - lilypond.git/commitdiff
Take padding into account while doing stretching
authorJoe Neeman <joeneeman@gmail.com>
Sat, 24 Feb 2007 00:07:30 +0000 (11:07 +1100)
committerJoe Neeman <joeneeman@gmail.com>
Sat, 24 Feb 2007 00:07:30 +0000 (11:07 +1100)
scm/layout-page-layout.scm

index 02583858e49015e5f027167df5ebe62315d4cc98..6c1f605b0d7d0bc80c8161c6636e24711602e06f 100644 (file)
                                 rest-height)
                             (- space-left stretch)))))
 
+  (define (total-padding systems)
+    (let ((layout (ly:paper-book-paper paper-book)))
+      (if (or (null? systems)
+             (null? (cdr systems)))
+         0.0
+         (+ (line-next-padding (car systems) (cadr systems) layout)
+            (total-padding (cdr systems))))))
+
   (let* ((page (make-page paper-book
                          'page-number page-number
                          'is-last last))
         ; yet, etc. If we overstretch because of underestimation, the result
         ; is very bad. So we stick in some extra space, just to be sure.
         (buffer (/ height 10.0))
-        (total-system-height (apply + (map height-estimate systems)))
+        (total-system-height (+ (apply + (map height-estimate systems))
+                                (total-padding systems)))
         (height-left (- height total-system-height buffer)))
 
-    (if (not ragged)
+    (if (and
+        (not ragged)
+        (> height-left 0))
        (set-line-stretch! (sort systems
                                 (lambda (s1 s2)
                                   (< (height-estimate s1)
                                      (height-estimate s2))))
                           (apply + (map height-estimate
                                         (filter stretchable? systems)))
-                          (- (page-printable-height page)
-                             total-system-height)))
+                          height-left))
 
     (let* ((lines (map print-system systems))
           (posns (if (null? lines)
 (define (line-next-padding line next-line layout)
   "Return padding to use between `line' and `next-line'.
   `next-line' can be #f, meaning that `line' is the last line."
-  (ly:prob-property
-   line 'next-padding
-   (ly:output-def-lookup layout 'between-system-padding)))
+  (let ((default (ly:output-def-lookup layout 'between-system-padding)))
+    (if (ly:grob? line)
+       (let* ((details (ly:grob-property line 'line-break-system-details))
+              (padding (assq 'next-padding details)))
+         (if padding
+             (cdr padding)
+             default))
+       (ly:prob-property line 'next-padding default))))
 
 
 (define (line-minimum-distance line next-line layout ignore-padding)