-/*
- Remove columns that are not tightly fitting from COLS. In the
- removed columns, set 'between-cols to the columns where it is in
- between.
-*/
-void
-Spacing_spanner::prune_loose_columns (Grob*me,Link_array<Grob> *cols, Rational shortest)
-{
- Link_array<Grob> newcols;
- Real increment = robust_scm2double (me->get_property ("spacing-increment"), 1.2);
- for (int i=0; i < cols->size (); i++)
- {
- if (Item::is_breakable (cols->elem (i)) || Paper_column::is_musical (cols->elem (i)))
- {
- newcols.push (cols->elem (i));
- continue;
- }
-
- Grob *c = cols->elem (i);
- if (loose_column (cols->elem (i-1), c, cols->elem (i+1)))
- {
- SCM lns = c->get_property ("left-neighbors");
- lns = scm_is_pair (lns) ? ly_car (lns) : SCM_BOOL_F;
-
- SCM rns = c->get_property ("right-neighbors");
- rns = scm_is_pair (rns) ? ly_car (rns) : SCM_BOOL_F;
-
- /*
- Either object can be non existent, if the score ends
- prematurely.
- */
- rns = ly_car (unsmob_grob (rns)->get_property ("right-items"));
- c->set_property ("between-cols", scm_cons (lns,
- rns));
-
- /*
- Set distance constraints for loose columns
- */
- Drul_array<Grob*> next_door;
- next_door[LEFT] =cols->elem (i - 1);
- next_door[RIGHT] =cols->elem (i + 1);
- Direction d = LEFT;
- Drul_array<Real> dists (0,0);
-
- do
- {
- dists[d] = 0.0;
- Item *lc = dynamic_cast<Item*> ((d == LEFT) ? next_door[LEFT] : c);
- Item *rc = dynamic_cast<Item*> (d == LEFT ? c : next_door[RIGHT]);
-
- for (SCM s = lc->get_property ("spacing-wishes");
- scm_is_pair (s); s = ly_cdr (s))
- {
- Grob *sp = unsmob_grob (ly_car (s));
- if (Note_spacing::left_column (sp) != lc
- || Note_spacing::right_column (sp) != rc)
- continue;
-
- Real space, fixed;
- fixed = 0.0;
- bool dummy;
-
- if (d == LEFT)
- {
- /*
- The note spacing should be taken from the musical
- columns.
-
- */
- Real base = note_spacing (me, lc, rc, shortest, &dummy);
- Note_spacing::get_spacing (sp, rc, base, increment, &space, &fixed);
-
- space -= increment;
-
- dists[d] = dists[d] >? space;
- }
- else
- {
- Real space, fixed_space;
- Staff_spacing::get_spacing_params (sp,
- &space, &fixed_space);
-
- dists[d] = dists[d] >? fixed_space;
- }
-
- }
- }
- while (flip (&d) != LEFT);
-
- Rod r;
- r.distance_ = dists[LEFT] + dists[RIGHT];
- r.item_l_drul_[LEFT] = dynamic_cast<Item*> (cols->elem (i-1));
- r.item_l_drul_[RIGHT] = dynamic_cast<Item*> (cols->elem (i+1));
-
- r.add_to_cols ();
- }
- else
- {
- newcols.push (c);
- }
- }
-
- *cols = newcols;
-}
-
-/*
- Set neighboring columns determined by the spacing-wishes grob property.
-*/
-void
-Spacing_spanner::set_explicit_neighbor_columns (Link_array<Grob> cols)
-{
- for (int i=0; i < cols.size (); i++)
- {
- SCM right_neighbors = SCM_EOL;
- int min_rank = 100000; // inf.
-
-
- SCM wishes= cols[i]->get_property ("spacing-wishes");
- for (SCM s =wishes; scm_is_pair (s); s = ly_cdr (s))
- {
- Item * wish = dynamic_cast<Item*> (unsmob_grob (ly_car (s)));
-
- Item * lc = wish->get_column ();
- Grob * right = Note_spacing::right_column (wish);
-
- if (!right)
- continue;
-
- Item * rc = dynamic_cast<Item*> (right);
-
- int right_rank = Paper_column::get_rank (rc);
- int left_rank = Paper_column::get_rank (lc);
-
- /*
- update the left column.
- */
- if (right_rank <= min_rank)
- {
- if (right_rank < min_rank)
- right_neighbors =SCM_EOL;
-
- min_rank = right_rank;
- right_neighbors = scm_cons (wish->self_scm (), right_neighbors);
- }
-
- /*
- update the right column of the wish.
- */
- int maxrank = 0;
- SCM left_neighs = rc->get_property ("left-neighbors");
- if (scm_is_pair (left_neighs)
- && unsmob_grob (ly_car (left_neighs)))
- {
- Item * it = dynamic_cast<Item*> (unsmob_grob (ly_car (left_neighs)));
- maxrank = Paper_column::get_rank (it->get_column ());
- }
-
- if (left_rank >= maxrank)
- {
- if (left_rank > maxrank)
- left_neighs = SCM_EOL;
-
- left_neighs = scm_cons (wish->self_scm (), left_neighs);
- rc->set_property ("left-neighbors", right_neighbors);
- }
- }
-
- if (scm_is_pair (right_neighbors))
- {
- cols[i]->set_property ("right-neighbors", right_neighbors);
- }
- }
-}
-
-/*
- Set neighboring columns that have no left/right-neighbor set
- yet. Only do breakable non-musical columns, and musical columns.
-*/
-void
-Spacing_spanner::set_implicit_neighbor_columns (Link_array<Grob> cols)
-{
- for (int i = 0; i < cols.size (); i++)
- {
- Item * it = dynamic_cast<Item*>(cols[i]);
- if (!Item::is_breakable (it) && !Paper_column::is_musical (it))
- continue;
-
- // it->breakable || it->musical
-
- /*
- sloppy with typnig left/right-neighbors should take list, but paper-column found instead.
- */
- SCM ln = cols[i] ->get_property ("left-neighbors");
- if (!scm_is_pair (ln) && i )
- {
- cols[i]->set_property ("left-neighbors", scm_cons (cols[i-1]->self_scm (), SCM_EOL));
- }
-
- SCM rn = cols[i] ->get_property ("right-neighbors");
- if (!scm_is_pair (rn) && i < cols.size () - 1)
- {
- cols[i]->set_property ("right-neighbors", scm_cons (cols[i + 1]->self_scm (), SCM_EOL));
- }
- }
-}
-
-
-MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs,1);