]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-column.cc
release: 0.0.65
[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 int
14 Score_column::compare(Score_column & c1, Score_column &c2)
15 {
16         return sign(c1.when_ - c2.when_);
17 }
18
19 void
20 Score_column::set_breakable()
21 {
22     pcol_l_->set_breakable();
23 }
24
25 Score_column::Score_column(Moment w)
26 {
27     when_ = w;
28     pcol_l_ = new PCol(0);
29     musical_b_ = false;
30 }
31
32 bool
33 Score_column::used_b() {
34     return pcol_l_->used_b();
35 }
36
37 void
38 Score_column::print() const
39 {
40 #ifndef NPRINT
41     mtor << "Score_column { mus "<< musical_b_ <<" at " <<  when_<<'\n';
42     mtor << "durations: [";
43     for (int i=0; i < durations.size(); i++)
44         mtor << durations[i] << " ";
45     mtor << "]\n";
46     pcol_l_->print();
47     mtor << "}\n";
48 #endif
49 }
50
51 int
52 Moment_compare(Moment &a , Moment& b)
53 {
54     return sign(a-b);
55 }
56
57 void
58 Score_column::preprocess()
59 {
60     durations.sort(Moment_compare);
61 }
62 void
63 Score_column::add_duration(Moment d)
64 {
65     assert(d);
66     for (int i = 0; i< durations.size(); i++) {
67         if (d == durations[i])
68             return ;
69     }
70     durations.push(d);
71 }
72
73 bool
74 Score_column::breakable_b()
75 {
76     return pcol_l_->breakable_b();
77 }