From: hanwen Date: Fri, 17 Feb 2006 01:15:52 +0000 (+0000) Subject: * lily/beam.cc (get_default_dir): take extreme note head as input X-Git-Tag: release/2.7.38^2~122 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=32bc695fcd67c02f772f6888b9c70df148163b25;p=lilypond.git * lily/beam.cc (get_default_dir): take extreme note head as input for stem direction. * lily/tie.cc (get_default_dir): only look directions for visible stems. * lily/side-position-interface.cc (aligned_side): oops. Don't mutiply with direction. This fixes quantized (staccato, tenuto) scripts below notes. --- diff --git a/ChangeLog b/ChangeLog index 0709a4f69b..50490729a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2006-02-17 Han-Wen Nienhuys + * lily/beam.cc (get_default_dir): take extreme note head as input + for stem direction. + + * lily/tie.cc (get_default_dir): only look directions for visible + stems. + * lily/side-position-interface.cc (aligned_side): oops. Don't mutiply with direction. This fixes quantized (staccato, tenuto) scripts below notes. diff --git a/lily/beam.cc b/lily/beam.cc index 49acbbd541..d47efc5a78 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -100,12 +100,6 @@ Beam::get_beam_count (Grob *me) } -/* After pre-processing all directions should be set. - Several post-processing routines (stem, slur, script) need stem/beam - direction. - Currenly, this means that beam has set all stem's directions. - [Alternatively, stems could set its own directions, according to - their beam, during 'final-pre-processing'.] */ MAKE_SCHEME_CALLBACK (Beam, calc_direction, 1); SCM Beam::calc_direction (SCM smob) @@ -522,16 +516,34 @@ Beam::print (SCM grob) return the_beam.smobbed_copy (); } +#define iterof(i,s) typeof((s).begin()) i((s).begin()) + Direction Beam::get_default_dir (Grob *me) { - Drul_array total; - total[UP] = total[DOWN] = 0; - Drul_array count; - count[UP] = count[DOWN] = 0; - extract_grob_set (me, "stems", stems); + Drul_array extremes (0.0, 0.0); + for (iterof (s, stems); s != stems.end (); s++) + { + Interval positions = Stem::head_positions (*s); + Direction d = DOWN; + do + { + if (sign (positions[d]) == d) + extremes[d] = d * max (d * positions[d], d * extremes[d]); + } + while (flip (&d) != DOWN); + } + + if (extremes[UP] > extremes[DOWN]) + return DOWN; + else if (extremes[UP] < extremes[DOWN]) + return UP; + + Drul_array total (0, 0); + Drul_array count (0, 0); + for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 2352c116d0..72dfbb8380 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -240,10 +240,10 @@ ADD_INTERFACE (Side_position_interface, "side-position-interface", "direction-source " "minimum-space " "padding " + "quantize-position " "side-axis " "side-relative-direction " "side-support-elements " "slur-padding " "staff-padding " - "quantize-position " ); diff --git a/lily/tie.cc b/lily/tie.cc index 4b0404d690..e0c17aa912 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -96,17 +96,27 @@ Tie::get_position (Grob *me) Direction Tie::get_default_dir (Grob *me) { - Item *sl = head (me, LEFT) ? Rhythmic_head::get_stem (head (me, LEFT)) : 0; - Item *sr = head (me, RIGHT) ? Rhythmic_head::get_stem (head (me, RIGHT)) : 0; - if (sl && sr) + Drul_array stems; + Direction d = LEFT; + do + { + Grob *stem = head (me, d) ? Rhythmic_head::get_stem (head (me, d)) : 0; + if (stem) + stem = Stem::is_invisible (stem) ? 0 : stem; + + stems[d] = stem; + } + while (flip (&d)!= LEFT); + + if (stems[LEFT] && stems[RIGHT]) { - if (get_grob_direction (sl) == UP - && get_grob_direction (sr) == UP) + if (get_grob_direction (stems[LEFT]) == UP + && get_grob_direction (stems[RIGHT]) == UP) return DOWN; } - else if (sl || sr) + else if (stems[LEFT] || stems[RIGHT]) { - Item *s = sl ? sl : sr; + Grob *s = stems[LEFT] ? stems[LEFT] : stems[RIGHT]; return -get_grob_direction (s); }