]> git.donarmstrong.com Git - lilypond.git/commitdiff
Center harmonic heads if stem is invisible. Fixes #140
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 5 Nov 2006 12:45:00 +0000 (13:45 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 5 Nov 2006 12:45:00 +0000 (13:45 +0100)
input/regression/note-head-harmonic-whole.ly [new file with mode: 0644]
input/regression/note-head-harmonic.ly
lily/stem.cc

diff --git a/input/regression/note-head-harmonic-whole.ly b/input/regression/note-head-harmonic-whole.ly
new file mode 100644 (file)
index 0000000..259608a
--- /dev/null
@@ -0,0 +1,19 @@
+\header {
+
+  texidoc = "A harmonic note head must be centered if the base note
+  is a whole note."
+
+}
+
+
+\version "2.9.29"
+
+\paper {
+  ragged-right = ##t
+}
+
+\relative c' {
+  <e a\harmonic>1
+  <e'' a\harmonic>1
+}
+
index b76d29687ee227e0d54b3519bd7022b1eb1af6cf..ae49e1bfd31a569dc0c43fb96a93749b8e9e7d9c 100644 (file)
@@ -3,7 +3,8 @@
   texidoc = "  The handling of stems for harmonic notes must be
    completely identical to normal note heads.
 
-  Harmonic heads do not get  dots. If @code{harmonicAccidentals} is unset, they also don't get accidentals."
+  Harmonic heads do not get dots. If @code{harmonicAccidentals} is
+  unset, they also don't get accidentals."
 
   
 }
index 6a0fb43485b42cde4af7e0c79d9e3cec368a79d0..69e7a15ce6328f59d356daed30c4c77cf303afe1 100644 (file)
@@ -419,12 +419,25 @@ Stem::calc_positioning_done (SCM smob)
       dir = UP;
       set_grob_direction (me, dir);
     }
-  
+
+  bool is_harmonic_centered = false;
+  for (vsize i = 0; i < heads.size (); i++)
+    is_harmonic_centered = is_harmonic_centered 
+      || heads[i]->get_property ("style") == ly_symbol2scm ("harmonic");
+  is_harmonic_centered = is_harmonic_centered && is_invisible (me);
+
   Real w = hed->extent (hed, X_AXIS)[dir];
   for (vsize i = 0; i < heads.size (); i++)
-    heads[i]->translate_axis (w - heads[i]->extent (heads[i], X_AXIS)[dir],
-                             X_AXIS);
+    {
+      Real amount = w - heads[i]->extent (heads[i], X_AXIS)[dir];
 
+      if (is_harmonic_centered)
+       amount =
+         hed->extent (hed, X_AXIS).linear_combination (CENTER)
+         - heads[i]->extent (heads[i], X_AXIS).linear_combination (CENTER);
+      
+      heads[i]->translate_axis (amount, X_AXIS);
+    }
   bool parity = true;
   Real lastpos = Real (Staff_symbol_referencer::get_position (heads[0]));
   for (vsize i = 1; i < heads.size (); i++)