X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fstem.cc;h=69e7a15ce6328f59d356daed30c4c77cf303afe1;hb=779ec2a483583d44f002f65fae54aa93bd3c2c88;hp=d95ff4be3951c8ac7b6403a76fa0e09e09f2225e;hpb=d3060eee305bf1cc660ccca7a6f4c97179ef0cf4;p=lilypond.git diff --git a/lily/stem.cc b/lily/stem.cc index d95ff4be39..69e7a15ce6 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -180,12 +180,6 @@ Stem::extremal_heads (Grob *me) return exthead; } -static int -integer_compare (int const &a, int const &b) -{ - return a - b; -} - /* The positions, in ascending order. */ vector Stem::note_head_positions (Grob *me) @@ -201,7 +195,7 @@ Stem::note_head_positions (Grob *me) ps.push_back (p); } - vector_sort (ps, integer_compare); + vector_sort (ps, less ()); return ps; } @@ -410,7 +404,7 @@ Stem::calc_positioning_done (SCM smob) extract_grob_set (me, "note-heads", ro_heads); vector heads (ro_heads); - vector_sort (heads, compare_position); + vector_sort (heads, position_less); Direction dir = get_grob_direction (me); if (dir < 0) @@ -425,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++)