lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] inter system space limitation


From: Nicolas Sceaux
Subject: [patch] inter system space limitation
Date: Tue, 17 Jul 2007 19:46:05 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (darwin)

Hi,

An issue arises with the ly:minimal-breaking function, when there is only
two systems for instance before a page break: there is too much space
between the two systems.

  ________
 | /===== |
 | \===== |
 |        |
 |        | <-- all the space left is between the 2 systems
 |        |
 | /===== |
 | \===== |
  --------

The following patch introduces a limitation of the space used to
distribute the systems:

  ________
 | /===== |
 | \===== |
 |        | <-- the space between the two systems is limited
 | /===== |
 | \===== |
 |        |
 |        |
  --------

This limitation is not activated by default. Also the factor used to
determine how much the space can be increased is parametrized.

Are there objections against me commiting the change (together with doc
and regression test)?

nicolas

diff --git a/ly/paper-defaults.ly b/ly/paper-defaults.ly
index 8ea1159..8eb3a24 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 91742ef..702043d 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
+                                                (page-ideal-space-left page))))
+                                     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
 ;;;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]