From: Mike Solomon Date: Thu, 28 Jul 2011 07:56:26 +0000 (+0200) Subject: Ignores rests in tuplet bracket calculations. X-Git-Tag: release/2.15.7-1~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=eed6f105c0b478572ec2b8fa93e1f96c0c5869ba;p=lilypond.git Ignores rests in tuplet bracket calculations. Where there is a tie in directions, tuplets are typeset closer to the staff. While this does not fix the problem of tuplets colliding with extreme noteheads reported in issue 992, it makes it less likely that this type of problem will occur. --- diff --git a/input/regression/tuplet-bracket-direction.ly b/input/regression/tuplet-bracket-direction.ly new file mode 100644 index 0000000000..e7614620b3 --- /dev/null +++ b/input/regression/tuplet-bracket-direction.ly @@ -0,0 +1,20 @@ +\version "2.14.0" + +\header { + texidoc = "The direction of tuplet brackets is the direction +of the majority of the stems under the bracket, with ties going +to UP. +" +} + +\relative c'' { + \times 2/3 { r r r } + \times 2/3 { r c r } + \times 2/3 { r a r } + \times 2/3 { c' f,, r } + \times 2/3 { f, c'' r } + \times 2/3 { a a c } + \times 2/3 { c c a } + \times 2/3 { a a a } + \times 2/3 { c c c } +} diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index 3bf2d1b49e..a7e1c6c2ba 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -730,12 +730,37 @@ Tuplet_bracket::get_default_dir (Grob *me) for (vsize i = 0; i < columns.size (); i++) { Grob *nc = columns[i]; + if (Note_column::has_rests (nc)) + continue; Direction d = Note_column::dir (nc); if (d) dirs[d]++; } - return dirs[UP] >= dirs[DOWN] ? UP : DOWN; + if (dirs[UP] == dirs[DOWN]) + { + if (dirs[UP] == 0) + return UP; + Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); + if (!staff) + return UP; + Interval staff_extent = staff->extent (staff, Y_AXIS); + Interval extremal_positions; + extremal_positions.set_empty (); + for (vsize i = 0; i < columns.size (); i++) + { + Direction d = Note_column::dir (columns[i]); + extremal_positions[d] = minmax (d, 1.0*Note_column::head_positions_interval (columns[i])[d], extremal_positions[d]); + } + Direction d = LEFT; + do + extremal_positions[d] = -d * (staff_extent[d] - extremal_positions[d]); + while (flip (&d) != LEFT); + + return extremal_positions[UP] <= extremal_positions[DOWN] ? UP : DOWN; + } + + return dirs[UP] > dirs[DOWN] ? UP : DOWN; } void diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 8d828db869..c313600199 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -411,7 +411,8 @@ in @var{grob}." Slur Stem TextScript - Tie)) + Tie + TupletBracket)) (define-safe-public (make-voice-props-set n) (make-sequential-music