X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fseparating-group-spanner.cc;h=bc5e030994bd1404c465ac22bd4b2ee433a40fc3;hb=6bf1606d827527f02953add0988a4fbbf0dc0c4e;hp=0610762f2d4fbec0287be76d27c2ad0942ea4077;hpb=07a5ed85c189a97d04c550679826dfc5eca2eb18;p=lilypond.git diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index 0610762f2d..bc5e030994 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2000 Han-Wen Nienhuys + (c) 1998--2001 Han-Wen Nienhuys */ @@ -14,27 +14,64 @@ #include "dimensions.hh" #include "group-interface.hh" -static void -do_rod (Item *l, Item *r) +void +Separating_group_spanner::find_rods (Item * r, SCM next) { - Rod rod; - - Interval li (Separation_item::my_width (l)); Interval ri (Separation_item::my_width (r)); + if (ri.empty_b ()) + return; + + /* + This is an inner loop, however, in most cases, the interesting L + will just be the first entry of NEXT, making it linear in most of + the cases. */ + for(; gh_pair_p (next); next = gh_cdr (next)) + { + Item *l = dynamic_cast (unsmob_grob (gh_car( next))); + Item *lb = l->find_prebroken_piece (RIGHT); + + if (lb) + { + Interval li (Separation_item::my_width (lb)); - rod.item_l_drul_[LEFT] =l; - rod.item_l_drul_[RIGHT]=r; + if (!li.empty_b ()) + { + Rod rod; - if (li.empty_b () || ri.empty_b ()) - rod.distance_f_ = 0; - else - rod.distance_f_ = li[RIGHT] - ri[LEFT]; + rod.item_l_drul_[LEFT] = lb; + rod.item_l_drul_[RIGHT] = r; - rod.columnize (); - rod.add_to_cols (); + rod.distance_f_ = li[RIGHT] - ri[LEFT]; + + rod.columnize (); + rod.add_to_cols (); + } + } + + Interval li (Separation_item::my_width (l)); + if (!li.empty_b ()) + { + Rod rod; + + rod.item_l_drul_[LEFT] =l; + rod.item_l_drul_[RIGHT]=r; + + rod.distance_f_ = li[RIGHT] - ri[LEFT]; + + rod.columnize (); + rod.add_to_cols (); + + break; + } + else + /* + this grob doesn't cause a constraint. We look further until we + find one that does. */ + ; + } } - -MAKE_SCHEME_CALLBACK(Separating_group_spanner,set_spacing_rods,1); + +MAKE_SCHEME_CALLBACK (Separating_group_spanner,set_spacing_rods,1); SCM Separating_group_spanner::set_spacing_rods (SCM smob) { @@ -45,37 +82,18 @@ Separating_group_spanner::set_spacing_rods (SCM smob) /* Order of elements is reversed! */ - SCM elt = gh_cadr (s); - SCM next_elt = gh_car (s); + SCM elt = gh_car (s); + Item *r = dynamic_cast (unsmob_grob (elt)); - Item *l = dynamic_cast (unsmob_grob (elt)); - Item *r = dynamic_cast (unsmob_grob ( next_elt)); - - if (!r || !l) + if (!r) continue; - - Item *lb - = dynamic_cast(l->find_prebroken_piece (RIGHT)); Item *rb - = dynamic_cast(r->find_prebroken_piece (LEFT)); - - do_rod(l, r); - if (lb) - { - do_rod (lb, r); - } + = dynamic_cast (r->find_prebroken_piece (LEFT)); + find_rods (r, gh_cdr (s)); if (rb) - { - do_rod (l, rb); - } - - if (lb && rb) - { - do_rod (lb, rb); - - } + find_rods (rb, gh_cdr (s)); } /* @@ -83,7 +101,7 @@ Separating_group_spanner::set_spacing_rods (SCM smob) */ for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) { - Item * it =dynamic_cast(unsmob_grob (gh_car (s))); + Item * it =dynamic_cast (unsmob_grob (gh_car (s))); if (it && it->broken_b ()) { it->find_prebroken_piece (LEFT) ->suicide (); @@ -106,5 +124,10 @@ Separating_group_spanner::add_spacing_unit (Grob* me ,Item*i) void Separating_group_spanner::set_interface (Grob*) { +} +bool +Separating_group_spanner::has_interface (Grob*) +{//todo + assert (false); }