From b6e2716b04e6bee4c1cc62461ab39624377416d0 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 24 Jan 2007 12:48:12 +0100 Subject: [PATCH] Fix #255. Require delta-time before breaking out of separation item loop. Add time_spanned_interval(Item*, Item*) --- .../spacing-horizontal-skyline-grace.ly | 32 +++++++++++++++++++ lily/include/item.hh | 2 ++ lily/item.cc | 30 +++++++++++++++++ lily/separating-group-spanner.cc | 9 +++++- lily/spanner.cc | 23 ++----------- 5 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 input/regression/spacing-horizontal-skyline-grace.ly diff --git a/input/regression/spacing-horizontal-skyline-grace.ly b/input/regression/spacing-horizontal-skyline-grace.ly new file mode 100644 index 0000000000..391d516678 --- /dev/null +++ b/input/regression/spacing-horizontal-skyline-grace.ly @@ -0,0 +1,32 @@ +\header{ + + texidoc = "Skyline horizontal spacing may fold non-adjacent columns +together, but they still do not collide. In this case, the arpeggio +and the barline do not collide." + +} + +\version "2.11.13" + +\paper +{ + ragged-right = ##t +} + +\new Staff +\relative c +{ + \override Score.NonMusicalPaperColumn #'stencil = #ly:paper-column::print + \time 6/8 + \clef bass + s2. | + \relative c << + { + 4\arpeggio + } + \\ + { + \acciaccatura ges,8 \voiceTwo ges4 + } + >> +} diff --git a/lily/include/item.hh b/lily/include/item.hh index a23cab577c..fa5092e27a 100644 --- a/lily/include/item.hh +++ b/lily/include/item.hh @@ -46,4 +46,6 @@ protected: virtual void derived_mark () const; }; +Interval_t spanned_time_interval (Item *l, Item *r); + #endif diff --git a/lily/item.cc b/lily/item.cc index 9d6a517d3b..521b285d52 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -16,6 +16,9 @@ #include "system.hh" #include "pointer-group-interface.hh" +#include "moment.hh" + + Grob * Item::clone () const { @@ -180,6 +183,33 @@ Item::spanned_rank_iv () const return Interval_t (c, c); } +Interval_t +spanned_time_interval (Item *l, Item *r) +{ + Drul_array bounds (l, r); + Interval_t iv; + + Direction d = LEFT; + do + { + if (bounds[d] && bounds[d]->get_column ()) + iv[d] = robust_scm2moment (bounds[d]->get_column ()->get_property ("when"), + iv[d]); + } + while (flip (&d) != LEFT); + + do + { + if (!bounds[d] || !bounds[d]->get_column ()) + iv[d] = iv[-d]; + } + while (flip (&d) != LEFT); + + + return iv; +} + + void Item::derived_mark () const { diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index f8975cd515..7de9341e39 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -13,6 +13,7 @@ #include "output-def.hh" #include "dimensions.hh" #include "pointer-group-interface.hh" +#include "moment.hh" void Separating_group_spanner::find_rods (Item *r, @@ -37,7 +38,13 @@ Separating_group_spanner::find_rods (Item *r, Separation_item::set_distance (Drul_array (lb, r), padding); } - if (Separation_item::set_distance (Drul_array (l, r), padding)) + if (Separation_item::set_distance (Drul_array (l, r), padding) + /* + This check is because grace notes are set very tight, and + the accidentals of main note may stick out so far to cover + a barline preceding the grace note. + */ + && spanned_time_interval (l, r).length ().main_part_ > Rational (0)) break; /* diff --git a/lily/spanner.cc b/lily/spanner.cc index 8a1e9e62c9..14ab378668 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -160,28 +160,11 @@ Spanner::spanned_rank_iv () const Interval_t Spanner::spanned_time () const { - Interval_t iv; - - Direction d = LEFT; - do - { - if (spanned_drul_[d] && spanned_drul_[d]->get_column ()) - iv[d] = robust_scm2moment (spanned_drul_[d]->get_column ()->get_property ("when"), - iv[d]); - } - while (flip (&d) != LEFT); - - do - { - if (!spanned_drul_[d] || !spanned_drul_[d]->get_column ()) - iv[d] = iv[-d]; - } - while (flip (&d) != LEFT); - - - return iv; + return spanned_time_interval (spanned_drul_[LEFT], + spanned_drul_[RIGHT]); } + Item * Spanner::get_bound (Direction d) const { -- 2.39.5