- We want the space before barline to be like the note
- spacing in the measure.
- */
- SCM sfac =lc->get_elt_property ("space-factor");
- if (Item::breakable_b (lc) || lc->original_l_)
- {
- s.strength_f_ =
- gh_scm2double (lc->get_elt_property ("column-space-strength"));
- }
- else if (gh_number_p (sfac))
- left_distance *= gh_scm2double (sfac);
+ // it->breakable || it->musical
+
+ /*
+ sloppy with typnig left/right-neighbors should take list, but paper-column found instead.
+ */
+ SCM ln = cols[i] ->get_grob_property ("left-neighbors");
+ if (!gh_pair_p (ln) && i )
+ {
+ cols[i]->set_grob_property ("left-neighbors", gh_cons (cols[i-1]->self_scm(), SCM_EOL));
+ }
+
+ SCM rn = cols[i] ->get_grob_property ("right-neighbors");
+ if (!gh_pair_p (rn) && i < cols.size () - 1)
+ {
+ cols[i]->set_grob_property ("right-neighbors", gh_cons (cols[i + 1]->self_scm(), SCM_EOL));
+ }
+ }
+}
+
+
+MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs,1);
+SCM
+Spacing_spanner::set_springs (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+
+ Link_array<Grob> all (me->pscore_l_->line_l_->column_l_arr ()) ;
+
+ set_explicit_neighbor_columns (all);
+
+ Rational global_shortest = find_shortest (all);
+ prune_loose_colunms (me, &all, global_shortest);
+ set_implicit_neighbor_columns (all);
+
+
+ int j = 0;
+ for (int i = 1; i < all.size (); i++)
+ {
+ Grob *sc = all[i];
+ if (Item::breakable_b (sc))
+ {
+ Link_array<Grob> measure (all.slice (j, i+1));
+ do_measure (global_shortest, me, &measure);
+ j = i;
+ }
+ }
+
+ return SCM_UNSPECIFIED;
+}
+
+
+/*
+ We want the shortest note that is also "common" in the piece, so we
+ find the shortest in each measure, and take the most frequently
+ found duration.
+
+ This probably gives weird effects with modern music, where every
+ note has a different duration, but hey, don't write that kind of
+ stuff, then.
+
+*/
+Rational
+Spacing_spanner::find_shortest (Link_array<Grob> const &cols)
+{
+ /*
+ ascending in duration
+ */
+ Array<Rational> durations;
+ Array<int> counts;
+
+ Rational shortest_in_measure;
+ shortest_in_measure.set_infinite (1);
+
+ for (int i =0 ; i < cols.size (); i++)
+ {
+ if (Paper_column::musical_b (cols[i]))
+ {
+ Moment *when = unsmob_moment (cols[i]->get_grob_property ("when"));