X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fseparating-group-spanner.cc;h=f4471530bf217091788c94b30925299ff52d3d84;hb=ce62ceaa3f635693b541a97de1eced86fab4c0f7;hp=f989389674047ee63cfbe12071bb4df9f1c40e4a;hpb=635827994d372f4bd0e9c719238380337bae9477;p=lilypond.git diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index f989389674..f4471530bf 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--2001 Han-Wen Nienhuys + (c) 1998--2002 Han-Wen Nienhuys */ @@ -17,9 +17,6 @@ void Separating_group_spanner::find_rods (Item * r, SCM next) { - Interval ri (Separation_item::my_width (r)); - if (ri.empty_b ()) - return; /* This is an inner loop, however, in most cases, the interesting L @@ -32,9 +29,9 @@ Separating_group_spanner::find_rods (Item * r, SCM next) if (lb) { - Interval li (Separation_item::my_width (lb)); - - if (!li.empty_b ()) + Interval li (Separation_item::width (lb)); + Interval ri (Separation_item::conditional_width (r, lb)); + if (!li.empty_b () && !ri.empty_b()) { Rod rod; @@ -48,8 +45,9 @@ Separating_group_spanner::find_rods (Item * r, SCM next) } } - Interval li (Separation_item::my_width (l)); - if (!li.empty_b ()) + Interval li (Separation_item::width (l)); + Interval ri (Separation_item::conditional_width (r, l)); + if (!li.empty_b () && !ri.empty_b()) { Rod rod; @@ -71,6 +69,15 @@ Separating_group_spanner::find_rods (Item * r, SCM next) } } +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) @@ -83,7 +90,7 @@ Separating_group_spanner::set_spacing_rods (SCM smob) Order of elements is reversed! */ SCM elt = ly_car (s); - Item *r = dynamic_cast (unsmob_grob (elt)); + Item *r = unsmob_item (elt); if (!r) continue; @@ -95,122 +102,21 @@ Separating_group_spanner::set_spacing_rods (SCM smob) if (rb) find_rods (rb, ly_cdr (s)); } - find_musical_sequences (me); -#if 0 - /* - TODO; restore this. - */ - /* - We've done our job, so we get lost. - */ - for (SCM s = me->get_grob_property ("elements"); gh_pair_p (s); s = ly_cdr (s)) - { - Item * it =dynamic_cast (unsmob_grob (ly_car (s))); - if (it && it->broken_b ()) - { - it->find_prebroken_piece (LEFT) ->suicide (); - it->find_prebroken_piece (RIGHT)->suicide (); - } - it->suicide (); - } - me->suicide (); -#endif + return SCM_UNSPECIFIED ; } void Separating_group_spanner::add_spacing_unit (Grob* me ,Item*i) { - Pointer_group_interface::add_element (me, "elements",i); + Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), i); me->add_dependency (i); } -void -Separating_group_spanner::find_musical_sequences (Grob *me) -{ - Item *last = 0; - Item *llast = 0; - for (SCM s = me->get_grob_property ("elements"); - gh_pair_p (s); s = ly_cdr (s)) - { - Item *it = dynamic_cast (unsmob_grob (ly_car (s))); - if (last) - { - Item *lcol = last->column_l (); - Item *col = it->column_l (); - - int lrank = Paper_column::rank_i (lcol); - int rank = Paper_column ::rank_i (col); - - bool mus = Paper_column::musical_b (col); - bool lmus = Paper_column::musical_b (lcol); - if ((lrank - rank == 2) && lmus && mus) - { - SCM seq = col->get_grob_property ("spacing-sequence"); - col->set_grob_property ("spacing-sequence", - gh_cons (gh_cons (it->self_scm (), last->self_scm ()), seq)); - } - - if (llast && !Paper_column::breakable_b (last)) - { - Item *llcol = llast->column_l (); - int llrank = Paper_column::rank_i (llcol); - bool llmus= Paper_column::musical_b (llcol); - if (llrank - lrank == 1 - && lrank - rank == 1 - && llmus && !lmus && mus) - { - SCM seq = col->get_grob_property ("spacing-sequence"); - col->set_grob_property ("spacing-sequence", - gh_cons (gh_cons (it->self_scm (), last->self_scm ()), seq)); - } - else if (!lmus) - { - SCM between = lcol->get_grob_property ("between-cols"); - - if (!gh_pair_p (between)) - { - between = gh_cons (it->self_scm (), llast->self_scm ()); - lcol ->set_grob_property ("between-cols", between); - } - - Item * left - = dynamic_cast (unsmob_grob (ly_car (between))); - if(Paper_column::rank_i (left->column_l ()) < rank) - gh_set_car_x (between, col->self_scm()); - - Item * right - = dynamic_cast (unsmob_grob (ly_cdr (between))); - if (Paper_column::rank_i (right->column_l ()) > llrank ) - gh_set_cdr_x (between, llcol->self_scm ()); - } - } - } - - llast = last; - last = it; - } -} -#if 0 -void -Separating_group_spanner::set_loose_rods () -{ - // loose columns should also generate minimum distances. - // TODO -} -#endif - -void -Separating_group_spanner::set_interface (Grob*) -{ -} - -bool -Separating_group_spanner::has_interface (Grob*) -{//todo - assert (false); -} +ADD_INTERFACE (Separating_group_spanner,"separation-spanner-interface", + "Spanner that containing @code{separation-item-interface} grobs to calculate rods", + "");