From 32bbd3a473244d255f8b713516c008a5d3ec6cb4 Mon Sep 17 00:00:00 2001 From: Mike Solomon Date: Wed, 5 Sep 2012 00:48:43 +0200 Subject: [PATCH] Dynamics do not avoid extremal cross-staff stems in extremal directions. If a cross-staff stem is pointing down and a dynamic is attached below the stem, for example, it will not be horizontally shifted. --- .../dynamics-avoid-cross-staff-stem-2.ly | 23 +++++++++++++++++++ lily/self-alignment-interface.cc | 19 ++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 input/regression/dynamics-avoid-cross-staff-stem-2.ly diff --git a/input/regression/dynamics-avoid-cross-staff-stem-2.ly b/input/regression/dynamics-avoid-cross-staff-stem-2.ly new file mode 100644 index 0000000000..e549646f75 --- /dev/null +++ b/input/regression/dynamics-avoid-cross-staff-stem-2.ly @@ -0,0 +1,23 @@ +\version "2.17.2" + +\header { + texidoc = "Dynamics do not horizontally shift when attached to +an axis-group extremal cross staff grob that's extremal side +(UP or DOWN) is the same as its direction. +" +} + +\new PianoStaff << + \new Staff = "up" { + s1 | + } + \new Staff = "down" { + \clef bass + \stemDown + % keep staff alive + 8 [ 8_\f + \change Staff = "up" + g' g' ] + r2 | + } +>> diff --git a/lily/self-alignment-interface.cc b/lily/self-alignment-interface.cc index a37b587100..ff2b5bfd59 100644 --- a/lily/self-alignment-interface.cc +++ b/lily/self-alignment-interface.cc @@ -199,7 +199,24 @@ Self_alignment_interface::avoid_colliding_grobs (Grob *me, Axis a, Real offset) Interval iv = me->extent (me, a) + offset; for (vsize i = 0; i < colls.size (); i++) - ivs.push_back (colls[i]->extent (refp, a)); + { + int my_vai = Grob::get_vertical_axis_group_index (colls[i]); + Direction dir = get_grob_direction (colls[i]); + // if coll is cross staff but extremal and pointing in the + // direction of the extrema, we don't take it into consideration + if (Grob *beam = unsmob_grob (colls[i]->get_object ("beam"))) + { + Interval_t vais; + extract_grob_set (beam, "normal-stems", stems); + for (vsize j = 0; j < stems.size (); j++) + vais.add_point (Grob::get_vertical_axis_group_index (stems[j])); + // ugh...up and down are different for VerticalAxisGroup order... + if ((my_vai == vais[DOWN] && dir == UP) + || (my_vai == vais[UP] && dir == DOWN)) + continue; + } + ivs.push_back (colls[i]->extent (refp, a)); + } Interval_minefield minefield (Interval (iv.center (), iv.center ()), iv.length ()); for (vsize i = 0; i < ivs.size (); i++) -- 2.39.2