From 7d56e485171cb7a575bcf8c64fb9cbb2493109b5 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 5 Nov 2006 13:22:19 +0000 Subject: [PATCH] Center harmonic heads if stem is invisible. Fixes #140 formatting cleanup --- ChangeLog | 8 ++++++++ input/regression/note-head-harmonic-whole.ly | 19 +++++++++++++++++++ input/regression/note-head-harmonic.ly | 3 ++- lily/dynamic-engraver.cc | 7 ++++++- lily/stem.cc | 19 ++++++++++++++++--- 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 input/regression/note-head-harmonic-whole.ly diff --git a/ChangeLog b/ChangeLog index 421c7e322c..7e8a3d28d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2006-11-05 Han-Wen Nienhuys + * 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 index 0000000000..259608ac07 --- /dev/null +++ b/input/regression/note-head-harmonic-whole.ly @@ -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' { + 1 + 1 +} + diff --git a/input/regression/note-head-harmonic.ly b/input/regression/note-head-harmonic.ly index b76d29687e..ae49e1bfd3 100644 --- a/input/regression/note-head-harmonic.ly +++ b/input/regression/note-head-harmonic.ly @@ -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." } diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index a0e99ad047..50cde13ea3 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -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 */ ""); diff --git a/lily/stem.cc b/lily/stem.cc index 6a0fb43485..69e7a15ce6 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -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++) -- 2.39.2