2 calcideal.cc -- implement Score::calc_idealspacing()
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "idealspacing.hh"
12 #include "paper-def.hh"
13 #include "score-column.hh"
18 generate springs between columns.
20 TODO: This needs A LOT of rethinking. Spacing should take optical
21 effects into account, should be local (measure wide), should check
24 plus, calc_idealspacing() should be called per line.
27 Score::calc_idealspacing()
35 PCursor<Score_column*> j(i+1);
39 for (int n=0; n < i->durations.size(); n++) {
40 Moment d = i->durations[n];
41 Real dist = paper_p_->duration_to_dist(d);
42 Real strength = i->durations[0]/i->durations[n];
43 assert(strength <= 1.0);
46 if (j->used_b() && j->when() >= d + i->when() )
50 Moment delta_desired = j->when() - (d+i->when());
51 dist += paper_p_->duration_to_dist(delta_desired);
54 pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, strength);
60 /* attach i to the next column in use. This exists, since
61 the last col is breakable, and therefore in use
64 Moment d = j->when() - i->when();
65 Real dist = (d) ? paper_p_->duration_to_dist(d) : 2 PT; // todo
67 pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, (d) ? 1.0:1.0);
69 // !j.ok() might hold if we're at the last col.