]> git.donarmstrong.com Git - lilypond.git/blob - lily/score-column.cc
abe35406c0fbd2c5a174a8bb024f3f6fd145e44d
[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--1998 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "debug.hh"
10 #include "p-col.hh"
11 #include "score-column.hh"
12 #include "command-request.hh"
13
14 Score_column::Score_column (Moment w)
15 {
16   break_penalty_i_ = 0;
17   when_ = w;
18   musical_b_ = false;
19 }
20
21 void
22 Score_column::do_print() const
23 {
24 #ifndef NPRINT
25   DOUT << "mus "<< musical_b_ <<" at " <<  when_<< '\n';
26   if (break_penalty_i_ >= Break_req::FORCE)
27     DOUT << "Break forced";
28       
29   DOUT << "durations: [";
30   for (int i=0; i < durations.size(); i++)
31     DOUT << durations[i] << " ";
32   DOUT << "]\n";
33   Paper_column::do_print();
34 #endif
35 }
36
37 int
38 Moment_compare (Moment const &m1, Moment const &m2)
39 {
40   return sign (m1-m2);
41 }
42
43 void
44 Score_column::preprocess()
45 {
46   Paper_column ::preprocess ();
47   durations.sort (Moment_compare);
48 }
49
50 void
51 Score_column::add_duration (Moment d)
52 {
53   if (!d)
54     {
55       warning (_("Ignoring zero duration added to column at ")
56                + when_.str ());
57       return;
58     }
59   
60   for (int i = 0; i< durations.size(); i++) 
61     {
62       if (d == durations[i])
63         return ;
64     }
65   durations.push (d);
66 }
67
68 IMPLEMENT_IS_TYPE_B1(Score_column, Paper_column);