]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-column.cc
fab25c79ce3142024acdbdcc9e8b9347c6b23258
[lilypond.git] / lily / note-column.cc
1 /*
2   note-column.cc -- implement Note_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 "note-column.hh"
10 #include "debug.hh"
11 #include "script.hh"
12 #include "note-head.hh"
13 #include "stem.hh"
14
15 IMPLEMENT_STATIC_NAME(Note_column);
16 IMPLEMENT_IS_TYPE_B1(Note_column,Script_column);
17
18 void
19 Note_column::add(Stem*stem_l)
20 {
21     stem_l_ = stem_l;
22     add_support(stem_l);
23 }
24
25 void
26 Note_column::add(Note_head* n_l)
27 {
28     assert(!n_l->rest_b_);
29     head_l_arr_.push(n_l);
30     add_support(n_l);
31 }
32
33 Note_column::Note_column()
34 {
35     stem_l_ = 0;
36     h_shift_b_ =false;
37     dir_i_ =0;
38 }
39
40 void
41 Note_column::sort()
42 {
43     head_l_arr_.sort( Note_head::compare);
44 }
45     
46 Interval_t<int>
47 Note_column::head_positions_interval()const
48 {
49     (    (Note_column*)this)->sort();
50     return Interval_t<int> ( head_l_arr_[0]->position_i_, 
51                              head_l_arr_.top()->position_i_);
52
53 }
54
55
56 void
57 Note_column::do_pre_processing()
58 {
59     if (!dir_i_){
60         if (stem_l_)
61             dir_i_ = stem_l_->dir_i_;
62         else 
63             dir_i_ = (head_positions_interval().center() >=  5) ? -1 : 1;
64     }
65     Script_column::do_pre_processing();
66 }
67
68     
69
70 void
71 Note_column::do_substitute_dependency(Score_elem*o,Score_elem*n)
72 {
73     Script_column::do_substitute_dependency(o,n);
74     if (o->name() == Note_head::static_name()) {
75         head_l_arr_.substitute( (Note_head*)o->item(), 
76                                 (n)? (Note_head*)n->item() : 0);
77     }
78     if (stem_l_ == o) {
79         stem_l_ = n ? (Stem*)n->item():0;
80     }
81 }