]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-column.cc
d6f4e739a5da518cbf77194882aba931e78121fb
[lilypond.git] / lily / score-column.cc
1 /*
2   score-column.cc -- implement Score_column
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "debug.hh"
10 #include "p-col.hh"
11 #include "score-column.hh"
12
13 Score_column::Score_column (Moment w)
14 {
15   when_ = w;
16   musical_b_ = false;
17 }
18
19 void
20 Score_column::print() const
21 {
22 #ifndef NPRINT
23   DOUT << "Score_column { mus "<< musical_b_ <<" at " <<  when_<<'\n';
24   DOUT << "durations: [";
25   for (int i=0; i < durations.size(); i++)
26         DOUT << durations[i] << " ";
27   DOUT << "]\n";
28   PCol::print();
29   DOUT << "}\n";
30 #endif
31 }
32
33 int
34 Moment_compare (Moment const &m1, Moment const &m2)
35 {
36   return sign (m1-m2);
37 }
38
39 void
40 Score_column::preprocess()
41 {
42   durations.sort (Moment_compare);
43 }
44
45 void
46 Score_column::add_duration (Moment d)
47 {
48   assert (d);
49   for (int i = 0; i< durations.size(); i++) 
50     {
51         if (d == durations[i])
52             return ;
53     }
54   durations.push (d);
55 }
56
57 void
58 Score_column::do_set_breakable()
59 {
60   Score_column *c1 = new Score_column (when_);
61   Score_column *c2 = new Score_column (when_);
62   prebreak_p_ =c1;
63   postbreak_p_ = c2;
64   c1->durations = durations;
65   c2->durations = durations;
66   c1->musical_b_ 
67         = c2->musical_b_ = musical_b_;
68 }