[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] zero-spacing problem fix
From: |
Nicolas Sceaux |
Subject: |
[patch] zero-spacing problem fix |
Date: |
Sat, 09 Jun 2007 16:47:00 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
Hi,
Here is a patch that fixes the zero spacing issue that can be
demonstrated by the following snippet:
\version "2.11.25"
#(set-default-paper-size "a6")
\paper {
between-system-padding = 0
between-title-space = 0
ragged-bottom = ##f
ragged-last-bottom = ##f
}
\markup hello
\markup world
\markup !
I'm asking for permission because it modifies an interface:
ly:solve-spring-rod-problem.
nicolas
diff --git a/lily/simple-spacer-scheme.cc b/lily/simple-spacer-scheme.cc
index 6f76106..db32670 100644
--- a/lily/simple-spacer-scheme.cc
+++ b/lily/simple-spacer-scheme.cc
@@ -17,7 +17,7 @@ LY_DEFINE (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,
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))
diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc
index 3f4e678..04c35dd 100644
--- a/lily/simple-spacer.cc
+++ b/lily/simple-spacer.cc
@@ -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 ();
diff --git a/scm/layout-page-layout.scm b/scm/layout-page-layout.scm
index 6c1f605..91742ef 100644
--- a/scm/layout-page-layout.scm
+++ b/scm/layout-page-layout.scm
@@ -156,16 +156,13 @@
`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'.
@@ -198,10 +195,11 @@
"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"
@@ -287,7 +285,7 @@
'())))
(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))
- [patch] zero-spacing problem fix,
Nicolas Sceaux <=