]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-column.cc
release: 0.0.76
[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     mtor << "Score_column { mus "<< musical_b_ <<" at " <<  when_<<'\n';
24     mtor << "durations: [";
25     for (int i=0; i < durations.size(); i++)
26         mtor << durations[i] << " ";
27     mtor << "]\n";
28     PCol::print();
29     mtor << "}\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         if (d == durations[i])
51             return ;
52     }
53     durations.push(d);
54 }
55
56 void
57 Score_column::do_set_breakable()
58 {
59     Score_column *c1 = new Score_column(when_);
60     Score_column *c2 = new Score_column(when_);
61     prebreak_p_ =c1;
62     postbreak_p_ = c2;
63     c1->durations = durations;
64     c2->durations = durations;
65     c1->musical_b_ 
66         = c2->musical_b_ = musical_b_;
67 }