X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fseparating-group-spanner.cc;h=567371967a4e3d42eaffe5c89ac5bea46e5e82f7;hb=7aabfb20c46e0a1de41698ddc6859ccd3a6dea85;hp=644366f5a9917a01065329a68bc7834f0295bbd4;hpb=e0833e924a7b626154c66170d98335c6c4985dfe;p=lilypond.git diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index 644366f5a9..567371967a 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--2003 Han-Wen Nienhuys */ @@ -14,97 +14,111 @@ #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)); + /* + This is an inner loop: look for the first normal (unbroken) Left + grob. This looks like an inner loop (ie. quadratic total), but in + most cases, the interesting L will just be the first entry of + NEXT, making it linear in most of the cases. + */ + if (Separation_item::width (r).empty_b ()) + return; + + for(; gh_pair_p (next); next = ly_cdr (next)) + { + Item *l = dynamic_cast (unsmob_grob (ly_car( next))); + Item *lb = l->find_prebroken_piece (RIGHT); + + if (lb) + { + Interval li (Separation_item::width (lb)); + Interval ri (Separation_item::conditional_width (r, lb)); + if (!li.empty_b () && !ri.empty_b()) + { + Rod rod; + + rod.item_l_drul_[LEFT] = lb; + rod.item_l_drul_[RIGHT] = r; + + rod.distance_ = li[RIGHT] - ri[LEFT]; + rod.add_to_cols (); + } + } - rod.item_l_drul_[LEFT] =l; - rod.item_l_drul_[RIGHT]=r; + Interval li (Separation_item::width (l)); + Interval ri (Separation_item::conditional_width (r, l)); + if (!li.empty_b () && !ri.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] =l; + rod.item_l_drul_[RIGHT]=r; - rod.columnize (); - rod.add_to_cols (); + rod.distance_ = li[RIGHT] - ri[LEFT]; + + rod.add_to_cols (); + break; + } + + /* + 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_and_seqs,1); +SCM +Separating_group_spanner::set_spacing_rods_and_seqs (SCM smob) +{ + set_spacing_rods (smob); + + return SCM_UNSPECIFIED; +} + +MAKE_SCHEME_CALLBACK (Separating_group_spanner,set_spacing_rods,1); SCM Separating_group_spanner::set_spacing_rods (SCM smob) { - Score_element*me = unsmob_element (smob); + Grob*me = unsmob_grob (smob); - for (SCM s = me->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 (ly_cdr (s)); s = ly_cdr (s)) { /* Order of elements is reversed! */ - SCM elt = gh_cadr (s); - SCM next_elt = gh_car (s); + SCM elt = ly_car (s); + Item *r = unsmob_item (elt); - Item *l = dynamic_cast (unsmob_element (elt)); - Item *r = dynamic_cast (unsmob_element ( 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, ly_cdr (s)); if (rb) - { - do_rod (l, rb); - } - - if (lb && rb) - { - do_rod (lb, rb); - - } + find_rods (rb, ly_cdr (s)); } - /* - We've done our job, so we get lost. - */ - for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s)) - { - Item * it =dynamic_cast(unsmob_element (gh_car (s))); - if (it && it->broken_b ()) - { - it->find_prebroken_piece (LEFT) ->suicide (); - it->find_prebroken_piece (RIGHT)->suicide (); - } - it->suicide (); - } - me->suicide (); return SCM_UNSPECIFIED ; } void -Separating_group_spanner::add_spacing_unit (Score_element* me ,Item*i) +Separating_group_spanner::add_spacing_unit (Grob* me ,Item*i) { - Pointer_group_interface (me, "elements").add_element (i); + Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), i); me->add_dependency (i); } -void -Separating_group_spanner::set_interface (Score_element*me) -{ -} + + +ADD_INTERFACE (Separating_group_spanner,"separation-spanner-interface", + "Spanner that containing @code{separation-item-interface} grobs to calculate rods", + "");