]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-column.cc
2e045df7bef556ed5591f2418d0aa304b586cc48
[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::do_print() const
21 {
22 #ifndef NPRINT
23   DOUT << "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   Paper_column::do_print();
29 #endif
30 }
31
32 int
33 Moment_compare (Moment const &m1, Moment const &m2)
34 {
35   return sign (m1-m2);
36 }
37
38 void
39 Score_column::preprocess()
40 {
41   durations.sort (Moment_compare);
42 }
43
44 void
45 Score_column::add_duration (Moment d)
46 {
47   if (!d)
48     {
49       warning (_("Ignoring zero duration added to column at ")
50                + String (when_)
51                );
52       return;
53     }
54   
55   for (int i = 0; i< durations.size(); i++) 
56     {
57       if (d == durations[i])
58         return ;
59     }
60   durations.push (d);
61 }
62
63 IMPLEMENT_IS_TYPE_B1(Score_column, Paper_column);