X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fseparating-group-spanner.cc;h=bc5e030994bd1404c465ac22bd4b2ee433a40fc3;hb=50cb93642631297394c1d1e108ecc42cfbadd644;hp=c00bfd8e13368ee3a3e2c46d60c5bfd90aace86c;hpb=bb36bac02a64770871780231ecc709cb18b20932;p=lilypond.git diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index c00bfd8e13..bc5e030994 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -3,93 +3,131 @@ source file of the GNU LilyPond music typesetter - (c) 1998--2000 Han-Wen Nienhuys + (c) 1998--2001 Han-Wen Nienhuys */ #include "separating-group-spanner.hh" -#include "single-malt-grouping-item.hh" +#include "separation-item.hh" #include "paper-column.hh" #include "paper-def.hh" #include "dimensions.hh" +#include "group-interface.hh" -static Rod -make_rod (Single_malt_grouping_item *l, Single_malt_grouping_item *r) +void +Separating_group_spanner::find_rods (Item * r, SCM next) { - Rod rod; - rod.item_l_drul_[LEFT] =l; - rod.item_l_drul_[RIGHT]=r; + Interval ri (Separation_item::my_width (r)); + if (ri.empty_b ()) + return; - Interval li (l->my_width ()); - Interval ri (r->my_width ()); - - if (li.empty_b () || ri.empty_b ()) - rod.distance_f_ = 0; - else - rod.distance_f_ = li[RIGHT] - ri[LEFT]; + /* + 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); - return rod; + if (lb) + { + Interval li (Separation_item::my_width (lb)); + + if (!li.empty_b ()) + { + Rod rod; + + rod.item_l_drul_[LEFT] = lb; + rod.item_l_drul_[RIGHT] = r; + + 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. */ + ; + } } - -Array -Separating_group_spanner::get_rods () const +MAKE_SCHEME_CALLBACK (Separating_group_spanner,set_spacing_rods,1); +SCM +Separating_group_spanner::set_spacing_rods (SCM smob) { - Array a; + Grob*me = unsmob_grob (smob); - for (SCM s = get_elt_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s)) + for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s)) { /* 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)); - Single_malt_grouping_item *l = dynamic_cast (unsmob_element (elt)); - Single_malt_grouping_item *r = dynamic_cast (unsmob_element ( next_elt)); - - if (!r || !l) + if (!r) continue; - - Single_malt_grouping_item *lb - = dynamic_cast(l->find_broken_piece (RIGHT)); - Single_malt_grouping_item *rb - = dynamic_cast(r->find_broken_piece (LEFT)); - - a.push (make_rod(l, r)); - if (lb) - { - Rod rod(make_rod (lb, r)); - a.push (rod); - } + Item *rb + = dynamic_cast (r->find_prebroken_piece (LEFT)); + find_rods (r, gh_cdr (s)); if (rb) + find_rods (rb, gh_cdr (s)); + } + + /* + We've done our job, so we get lost. + */ + 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))); + if (it && it->broken_b ()) { - a.push (make_rod (l, rb)); - } - - if (lb && rb) - { - Rod rod(make_rod (lb, rb)); - a.push (rod); + it->find_prebroken_piece (LEFT) ->suicide (); + it->find_prebroken_piece (RIGHT)->suicide (); } + it->suicide (); } - - return a; + me->suicide (); + return SCM_UNSPECIFIED ; } void -Separating_group_spanner::add_spacing_unit (Single_malt_grouping_item*i) +Separating_group_spanner::add_spacing_unit (Grob* me ,Item*i) { - set_elt_property ("elements", - gh_cons (i->self_scm_, - get_elt_property ("elements"))); - add_dependency (i); + Pointer_group_interface::add_element (me, "elements",i); + me->add_dependency (i); } -Separating_group_spanner::Separating_group_spanner () +void +Separating_group_spanner::set_interface (Grob*) { - set_elt_property ("elements", SCM_EOL); +} + +bool +Separating_group_spanner::has_interface (Grob*) +{//todo + assert (false); }