]> git.donarmstrong.com Git - lilypond.git/commitdiff
Allow null spacing and padding in vertical spacing:
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Sat, 9 Jun 2007 22:11:00 +0000 (00:11 +0200)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Sat, 9 Jun 2007 22:11:00 +0000 (00:11 +0200)
 - the `spring' argument of ly:solve-spring-and-rod-problem now is a
   list of (ideal-distance inverse-hooke) elements, instead of
   (ideal-distance hooke), to avoid infinite value when space=0;
 - do not try to expand the spacing when all inter line spaces are
   null.

lily/simple-spacer-scheme.cc
lily/simple-spacer.cc
scm/layout-page-layout.scm

index 6f7610670670be53853887ddd0818cafbef02a11..db326704fcde0a6783452a7f1fe4cade3f9b0627 100644 (file)
@@ -17,7 +17,7 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
           4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged),
           "Solve a spring and rod problem for @var{count} objects, that "
           "are connected by @var{count-1} springs, and an arbitrary number of rods "
-          "Springs have the format (ideal, hooke) and rods (idx1, idx2, distance) "
+          "Springs have the format (ideal, inverse_hooke) and rods (idx1, idx2, distance) "
           "@var{length} is a number, @var{ragged} a boolean "
           "Return: a list containing the force (positive for stretching, "
           "negative for compressing and #f for non-satisfied constraints) "
@@ -36,9 +36,9 @@ LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
   for (SCM s = springs; scm_is_pair (s); s = scm_cdr (s))
     {
       Real ideal = scm_to_double (scm_caar (s));
-      Real hooke = scm_to_double (scm_cadar (s));
+      Real inv_hooke = scm_to_double (scm_cadar (s));
 
-      spacer.add_spring (ideal, 1 / hooke);
+      spacer.add_spring (ideal, inv_hooke);
     }
 
   for (SCM s = rods; scm_is_pair (s); s = scm_cdr (s))
index 3f4e678cd6d4ddf1c60f56ea69cc085eaba4999a..04c35dd4e597f13a813301d61af4f4dafdba97c2 100644 (file)
@@ -144,10 +144,13 @@ void
 Simple_spacer::solve (Real line_len, bool ragged)
 {
   Real conf = configuration_length (force_);
+  double inv_hooke = 0;
+  for (vsize i=0; i < springs_.size (); i++)
+    inv_hooke += springs_[i].inverse_hooke_;
 
   ragged_ = ragged;
   line_len_ = line_len;
-  if (conf < line_len_)
+  if ((inv_hooke > 0) && (conf < line_len_))
     force_ = expand_line ();
   else if (conf > line_len_)
     force_ = compress_line ();
index 6c1f605b0d7d0bc80c8161c6636e24711602e06f..91742ef315f98319e9d017aa4a1021af2ed79539 100644 (file)
   `next-line' can be #f, meaning that `line' is the last line."
   (let* ((title (paper-system-title? line))
         (next-title (and next-line (paper-system-title? next-line))))
-    (cond ((and title next-title)
-          (ly:output-def-lookup layout 'between-title-space))
-         (title
-          (ly:output-def-lookup layout 'after-title-space))
-         (next-title
-          (ly:output-def-lookup layout 'before-title-space))
-         (else
-          (ly:prob-property
-           line 'next-space
-           (ly:output-def-lookup layout 'between-system-space))))))
+    (ly:prob-property
+     line 'next-space
+     (ly:output-def-lookup layout 
+                          (cond ((and title next-title) 'between-title-space)
+                                (title 'after-title-space)
+                                (next-title 'before-title-space)
+                                (else 'between-system-space))))))
 
 (define (line-next-padding line next-line layout)
   "Return padding to use between `line' and `next-line'.
   "Ideal distance between `line' reference position and `next-line'
  reference position. If next-line is #f, return #f."
   (and next-line
-       (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
-                      (if ignore-padding 0 (line-next-padding line next-line layout)))
-                   (interval-start (paper-system-staff-extents line))))
-         (line-next-space line next-line layout))))
+       (max (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
+                           (if ignore-padding 0 (line-next-padding line next-line layout)))
+                        (interval-start (paper-system-staff-extents line))))
+              (line-next-space line next-line layout))
+           (line-minimum-distance line next-line layout ignore-padding))))
 
 (define (first-line-position line layout)
   "Position of the first line on page"
                                '())))
         (springs (map (lambda (prev-line line)
                         (list (line-ideal-distance prev-line line paper ignore-padding)
-                              (/ 1.0 (line-next-space prev-line line paper))))
+                              (line-next-space prev-line line paper)))
                       lines
                       cdr-lines))
         (rods (map (let ((i -1))