From: hanwen <hanwen>
Date: Sun, 10 Oct 2004 18:12:36 +0000 (+0000)
Subject: * scm/page-layout.scm (ly:optimal-page-breaks): don't compute
X-Git-Tag: release/2.3.24^2~59
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=28ff660bd13e38d08b53c66633fc1d68951281c7;p=lilypond.git

* scm/page-layout.scm (ly:optimal-page-breaks): don't compute
force twice.

* lily/simple-spacer.cc (LY_DEFINE): if line too long in ragged
mode, return #f.

* scm/page-layout.scm (ly:optimal-page-breaks): set force = 0.0
for last page if raggedlast.
---

diff --git a/ChangeLog b/ChangeLog
index 85599b4530..b656158af1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2004-10-10  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+	* scm/page-layout.scm (ly:optimal-page-breaks): don't compute
+	force twice.
+
+	* lily/simple-spacer.cc (LY_DEFINE): if line too long in ragged
+	mode, return #f.	
+
+	* scm/page-layout.scm (ly:optimal-page-breaks): set force = 0.0
+	for last page if raggedlast. 
+
 	* lily/parser.yy (Prefix_composite_music): untransposable is for
 	FiguredBass, not ChordNames
 
diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi
index 4e3b05d4c5..238d845fb1 100644
--- a/Documentation/topdocs/NEWS.texi
+++ b/Documentation/topdocs/NEWS.texi
@@ -7,6 +7,10 @@
 @unnumbered New features in 2.3 since 2.2
 
 @itemize @bullet
+@item @code{\bookpaper} and @code{\paper} have been renamed to
+@code{\paper} and @code{\layout} respectively, to better match their
+function.
+
 @item Parts that use @code{\quote} can now be transposed.
 
 @item LilyPond does not try to produce output for files that
@@ -63,7 +67,7 @@ string that is dumped as verbatim PostScript in the output.
 melody by setting the @code{associatedVoice} property.
 
 @item The @code{\lyricsto} keyword now automatically switches on
-@code{\lyrics} mode.
+lyrics mode.
 
 @item The LilyPond binary  now supports output options
 @code{--dvi} @code{--png} @code{--ps} @code{--pdf} and
diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc
index 74ed5f0fb2..7ad8eb3795 100644
--- a/lily/simple-spacer.cc
+++ b/lily/simple-spacer.cc
@@ -56,6 +56,12 @@
    Perhaps this is not a bad thing, because the 1st looks better anyway.  */
 
 
+/*
+
+  positive force = expanding, negative force = compressing.
+  
+*/
+
 Simple_spacer::Simple_spacer ()
 {
   /*
@@ -297,13 +303,21 @@ LY_DEFINE(ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem",
       posns.push (posns.top() + l);
     }
 
+
+    
   SCM force_return = SCM_BOOL_F;
   if (!isinf (spacer.force_)
       && spacer.is_active ())
     {
       force_return = scm_from_double (spacer.force_);
     }
-  
+
+  if (is_ragged
+      && posns.top () > spacer.line_len_)
+    {
+      force_return = SCM_BOOL_F;
+    }
+
   SCM retval= SCM_EOL;
   for (int i = posns.size(); i--;)
     {
diff --git a/scm/page-layout.scm b/scm/page-layout.scm
index 90a02c838c..7c7ec3ff4f 100644
--- a/scm/page-layout.scm
+++ b/scm/page-layout.scm
@@ -112,15 +112,17 @@
 	     (ly:output-def-lookup layout 'topmargin)
 	     (ly:output-def-lookup layout 'bottommargin)))
        (head (page-headfoot layout scopes number 'make-header 'headsep UP last?))
-       (foot (page-headfoot layout scopes number 'make-footer 'footsep DOWN last?)))
-    (- h (if (ly:stencil? head)
-	     (interval-length (ly:stencil-extent head Y))
-	     0)
-       (if (ly:stencil? foot)
-	   (interval-length (ly:stencil-extent foot Y))
-	   0))
-    ))
-
+       (foot (page-headfoot layout scopes number 'make-footer 'footsep DOWN last?))
+       (available 
+	(- h (if (ly:stencil? head)
+		 (interval-length (ly:stencil-extent head Y))
+		 0)
+	   (if (ly:stencil? foot)
+	       (interval-length (ly:stencil-extent foot Y))
+	       0))))
+    
+;    (display (list "\n available" available head foot))
+    available))
 
 (define-public (default-page-make-stencil
 		 lines offsets layout scopes number last? )
@@ -283,7 +285,7 @@ is what have collected so far, and has ascending page numbers."
 			'()) 
 		    )))
 	 (no-systems (vector-length real-extents))
-	 (topskip (cdr (vector-ref real-extents 0)))
+	 (topskip (interval-end (vector-ref real-extents 0)))
 	 (space-left (- page-height
 			(apply + (map interval-length (vector->list real-extents)))
 
@@ -291,7 +293,7 @@ is what have collected so far, and has ascending page numbers."
 		     
 	 (space (- page-height
 		   topskip
-		   (-  (car (vector-ref real-extents (1- no-systems))))
+		   (-  (interval-start (vector-ref real-extents (1- no-systems))))
 		   ))
 
 	 (fixed-dist (ly:output-def-lookup paper 'betweensystempadding))
@@ -300,9 +302,9 @@ is what have collected so far, and has ascending page numbers."
 	    (let*
 		((this-system-ext (vector-ref staff-extents idx))
 		 (next-system-ext (vector-ref staff-extents (1+ idx)))
-		 (fixed (max 0  (- (+ (cdr next-system-ext)
+		 (fixed (max 0  (- (+ (interval-end next-system-ext)
 				      fixed-dist)
-				   (car this-system-ext))))
+				   (interval-start this-system-ext))))
 		 (title1? (and (vector-ref system-vector idx)
 			       (ly:paper-system-title? (vector-ref system-vector idx))))
 		 (title2? (and
@@ -329,9 +331,9 @@ is what have collected so far, and has ascending page numbers."
 	    (let*
 		((this-system-ext (vector-ref real-extents idx))
 		 (next-system-ext (vector-ref real-extents (1+ idx)))
-		 (distance (max  (- (+ (cdr next-system-ext)
+		 (distance (max  (- (+ (interval-end next-system-ext)
 				 fixed-dist)
-				    (car this-system-ext)
+				    (interval-start this-system-ext)
 				    ) 0)) 
 		 (entry (list idx (1+ idx) distance)))
 	      entry)))
@@ -343,8 +345,7 @@ is what have collected so far, and has ascending page numbers."
 		  springs rods space
 		  ragged?))
 
-	 (force (car (ly:solve-spring-rod-problem
-		      springs rods space #f)))
+	 (force (car result))
 	 (positions
 	  (map (lambda (y)
 		       (+ y topskip)) 
@@ -357,7 +358,6 @@ is what have collected so far, and has ascending page numbers."
 			  "\nreal-ext" real-extents "\nstaff-ext" staff-extents
 			  "\ninterscore" inter-system-space
 			  "\nspace-letf" space-left
-			  "\npage empty" page-very-empty?
 			  "\nspring,rod" springs rods
 			  "\ntopskip " topskip
 			  " space " space
@@ -381,14 +381,19 @@ CURRENT-BEST is the best result sofar, or #f."
                               (ly:output-def-lookup paper 'firstpagenumber)
                               (1+ (node-page-number (car best-paths)))))
 
-	   
-	   (ragged? (or (eq? #t (ly:output-def-lookup paper 'raggedbottom))
-			(and (eq? #t (ly:output-def-lookup paper 'raggedlastbottom))
+	   (ragged-all? (eq? #t (ly:output-def-lookup paper 'raggedbottom)))
+	   (ragged-last? (eq? #t (ly:output-def-lookup paper 'raggedlastbottom)))
+	   (ragged? (or ragged-all? 
+			(and ragged-last?
 			     last?)))
            (page-height (page-height this-page-num last?))
 	   (vertical-spacing (space-systems page-height current-lines ragged?))
 	   (satisfied-constraints (car vertical-spacing))
-           (force (if satisfied-constraints satisfied-constraints 10000))
+           (force (if satisfied-constraints
+		      (if (and last? ragged-last?)
+			  0.0
+			  satisfied-constraints)
+		      10000))
 	   (positions (cdr vertical-spacing))
            (user-penalty (ly:paper-system-break-penalty (car current-lines)))
            (total-penalty (combine-penalties