X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fhairpin.cc;h=9fcf79df88766483c13af02bd553ba2e4d28dfe6;hb=754d360118e26e2e48ec080849d9c0f94d1c7416;hp=d5c17d720949a9182aa911a93d00563e52bece48;hpb=c033fdc08e24aa0663b1847fffafe605f03a7440;p=lilypond.git diff --git a/lily/hairpin.cc b/lily/hairpin.cc index d5c17d7209..9fcf79df88 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -17,6 +17,7 @@ #include "warn.hh" #include "paper-column.hh" #include "lookup.hh" +#include "text-item.hh" MAKE_SCHEME_CALLBACK (Hairpin, print, 1); @@ -34,9 +35,8 @@ Hairpin::print (SCM smob) } Direction grow_dir = to_dir (s); + Real padding = robust_scm2double (me->get_property ("bound-padding"), 0.5); - Real padding = ly_scm2double (me->get_property ("bound-padding")); - Drul_array broken; Drul_array bounds ; Direction d = LEFT; @@ -61,24 +61,39 @@ Hairpin::print (SCM smob) } else { - if (dynamic_cast (b)) + if (Text_interface::has_interface (b)) { + Interval e = b->extent (common, X_AXIS); + if (!e.is_empty ()) + x_points[d] = e[-d] - d*padding; + } + else + { + bool neighbor_found = false; + for (SCM adj = me->get_property ("adjacent-hairpins"); + scm_is_pair (adj); adj = scm_cdr (adj)) + { + /* + FIXME: this will fuck up in case of polyphonic + notes in other voices. Need to look at note-columns + in the current staff/voice. + */ + + Spanner *pin = unsmob_spanner (scm_car (adj)); + if (pin + && (pin->get_bound (LEFT)->get_column() == b->get_column () + || pin->get_bound (RIGHT)->get_column() == b->get_column() )) + neighbor_found = true; + } + /* If we're hung on a paper column, that means we're not adjacent to a text-dynamic, and we may move closer. We make the padding a little smaller, here. */ - Interval e = b->extent (common, X_AXIS); - if (e.is_empty ()) - e = Interval (0,0) + b->relative_coordinate (common, X_AXIS); - - x_points[d] = e.center () - d * padding / 3; // ugh. - } - else - { - Interval e = b->extent (common, X_AXIS); - if (!e.is_empty ()) - x_points[d] = e[-d] - d*padding; + Interval e = robust_relative_extent (b, common, X_AXIS); + x_points[d] = + neighbor_found ? e.center() - d * padding / 3 : e[d]; } } } @@ -86,11 +101,10 @@ Hairpin::print (SCM smob) Real width = x_points[RIGHT] - x_points[LEFT]; - if (width < 0) { me->warning (_ ((grow_dir < 0) ? "decrescendo too small" - : "crescendo too small")); + : "crescendo too small")); width = 0; } @@ -130,5 +144,5 @@ Hairpin::print (SCM smob) ADD_INTERFACE (Hairpin, "hairpin-interface", "A hairpin (de)crescendo.", - "grow-direction height bound-padding"); + "grow-direction height bound-padding adjacent-hairpins");