]> 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 13:22:19 +0000 (13:22 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 5 Nov 2006 13:22:19 +0000 (13:22 +0000)
formatting cleanup

ChangeLog
input/regression/note-head-harmonic-whole.ly [new file with mode: 0644]
input/regression/note-head-harmonic.ly
lily/dynamic-engraver.cc
lily/stem.cc

index 421c7e322c9de9acc36feac43134169ea8780326..7e8a3d28d50d86d8872a7613bf87f31e095878e0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2006-11-05  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * lily/dynamic-engraver.cc: 
+       formatting cleanup
+
+       * input/regression/note-head-harmonic.ly: 
+       * lily/stem.cc: 
+       * input/regression/note-head-harmonic-whole.ly: 
+       Center harmonic heads if stem is invisible. Fixes #140
+
        * lily/input.cc: 
        end context snippet with '\n'
 
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 a0e99ad0479b308915bc88b4cef09c18b154f217..50cde13ea3b2833a26c290a5851e09570c70eb65 100644 (file)
@@ -484,6 +484,11 @@ ADD_TRANSLATOR (Dynamic_engraver,
                "alignments.  The symbols are collected onto a DynamicLineSpanner grob\n"
                "which takes care of vertical positioning.  ",
 
-               /* create */ "DynamicLineSpanner DynamicText Hairpin TextSpanner",
+               /* create */
+               "DynamicLineSpanner "
+               "DynamicText "
+               "Hairpin "
+               "TextSpanner ",
+
                /* read */ "",
                /* write */ "");
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++)