summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@xs4all.nl>2007-01-01 16:14:47 +0100
committerHan-Wen Nienhuys <hanwen@xs4all.nl>2007-01-01 16:14:47 +0100
commitbfeffe647f9dbb6fc9e32769223fe2b02a072d74 (patch)
tree8378961928dda09cb66bb5bbdeabe6362f969736
parentf5b3d5c2d4181615c3e50671e9827c712ca3ccb8 (diff)
Fix #136.
Take original offset into account when returning new shift in rest-beam collision callback.
-rw-r--r--input/regression/rest-collision-beam-quantized.ly19
-rw-r--r--input/regression/rest-collision-beam-restdir.ly18
-rw-r--r--input/regression/rest-collision-beam.ly44
-rw-r--r--lily/beam-engraver.cc1
-rw-r--r--lily/beam.cc17
5 files changed, 57 insertions, 42 deletions
diff --git a/input/regression/rest-collision-beam-quantized.ly b/input/regression/rest-collision-beam-quantized.ly
new file mode 100644
index 0000000000..95f1e851fe
--- /dev/null
+++ b/input/regression/rest-collision-beam-quantized.ly
@@ -0,0 +1,19 @@
+\header {
+ texidoc = "Rests under beams moved by whole staff spaces."
+}
+
+\layout {
+ ragged-right = ##t
+}
+
+\version "2.10.0"
+
+fig = \relative c' {
+ <a c e>8[
+ r <c e a> r <e a c> r <a c e>]
+ r |
+}
+
+\relative c' \new Staff {
+ \transpose c c, \fig
+}
diff --git a/input/regression/rest-collision-beam-restdir.ly b/input/regression/rest-collision-beam-restdir.ly
new file mode 100644
index 0000000000..cd595d865d
--- /dev/null
+++ b/input/regression/rest-collision-beam-restdir.ly
@@ -0,0 +1,18 @@
+\header {
+ texidoc = "Beam/rest collision takes offset due to @code{Rest #'direction} into
+account properly."
+}
+
+\version "2.10.7"
+\paper {
+ ragged-right = ##t
+}
+
+
+\relative c''' {
+ \override Rest #'direction = #UP
+ \stemDown b8[ r b]
+ \override Rest #'direction = #DOWN
+ \stemDown b8[ r b]
+}
+
diff --git a/input/regression/rest-collision-beam.ly b/input/regression/rest-collision-beam.ly
index 7e0e2f5fff..6a38e581bd 100644
--- a/input/regression/rest-collision-beam.ly
+++ b/input/regression/rest-collision-beam.ly
@@ -1,40 +1,16 @@
\header {
- texidoc = "Rests under beams are only moved if necessary."
-}
-
-\layout {
- ragged-right = ##t
-}
-\version "2.10.0"
+ texidoc = "Rests under beams are shifted upon
+collision."
-fig = \relative c' {
- <a c e>8[ r <c e a> r <e a c> r <a c e>]
- r |
}
-
+\version "2.10.7"
+\paper {
+ ragged-right = ##t
+}
-
- \relative c' \new Staff {
- \fig
- \transpose c c, \fig
- \new Voice { \stemUp \transpose c f \fig }
- <<
- \\
- \transpose f c \fig
- >>
-
- <<
- { \transpose c c' \fig }
- \\
- {}
- >>
-
- << \transpose c c' \fig \\
- \transpose f c \fig
- >>
- }
-
-
-
+\relative c''' {
+ \stemDown b8[ r b]
+ \stemUp b,,8[ r b]
+}
diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc
index 53d1234547..b0d640a62b 100644
--- a/lily/beam-engraver.cc
+++ b/lily/beam-engraver.cc
@@ -27,6 +27,7 @@ class Beam_engraver : public Engraver
public:
DECLARE_ACKNOWLEDGER (stem);
DECLARE_ACKNOWLEDGER (rest);
+
protected:
Stream_event *start_ev_;
diff --git a/lily/beam.cc b/lily/beam.cc
index 77953070c9..58fd432493 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -1336,12 +1336,8 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset)
|| !Beam::visible_stem_count (beam))
return scm_from_double (0.0);
- Drul_array<Real> pos (0, 0);
- SCM s = beam->get_property ("positions");
- if (scm_is_pair (s) && scm_is_number (scm_car (s)))
- pos = ly_scm2interval (s);
- else
- programming_error ("positions property should always be pair of numbers.");
+ Drul_array<Real> pos (robust_scm2drul (beam->get_property ("positions"),
+ Drul_array<Real> (0,0)));
Real staff_space = Staff_symbol_referencer::staff_space (rest);
@@ -1377,6 +1373,11 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset)
Real beam_y = stem_y - d * height_of_my_beams;
Grob *common_y = rest->common_refpoint (beam, Y_AXIS);
+
+ /*
+ TODO: this is dubious, because this call needs the info we're
+ computing right now.
+ */
Interval rest_extent = rest->extent (common_y, Y_AXIS);
rest_extent.translate (offset);
@@ -1385,7 +1386,7 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset)
= staff_space * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0)
+ robust_scm2double (rest->get_property ("minimum-distance"), 0.0));
- Real shift = d * min (((beam_y - d * minimum_distance) - rest_dim) * d, 0.0);
+ Real shift = d * min (d * (beam_y - d * minimum_distance - rest_dim), 0.0);
shift /= staff_space;
Real rad = Staff_symbol_referencer::line_count (rest) * staff_space / 2;
@@ -1400,7 +1401,7 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset)
< rad)
shift = ceil (fabs (shift)) * sign (shift);
- return scm_from_double (staff_space * shift);
+ return scm_from_double (offset + staff_space * shift);
}
bool