2 note-column.cc -- implement Note_column
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "note-column.hh"
12 #include "notehead.hh"
15 IMPLEMENT_STATIC_NAME(Note_column);
19 Note_column::add(Stem*stem_l)
23 add_dependency(stem_l);
27 Note_column::add(Notehead* n_l)
29 head_l_arr_.push(n_l);
34 Note_column::add(Script*s_l)
36 script_l_arr_.push(s_l);
41 Note_column::translate(Offset o)
43 for (int i=0; i < head_l_arr_.size(); i++)
44 head_l_arr_[i]->translate(o);
45 for (int i=0; i < script_l_arr_.size(); i++)
46 script_l_arr_[i]->translate(o);
48 stem_l_->translate(o);
53 Note_column::do_print()const
55 mtor << "heads: " << head_l_arr_.size() << '\n';
56 mtor << "scripts: " << script_l_arr_.size() << '\n';
60 Note_column::do_height()const return r
63 r.unite(stem_l_->height());
64 for (int i=0; i < head_l_arr_.size(); i++)
65 r.unite(head_l_arr_[i]->height());
66 for (int i=0; i < script_l_arr_.size(); i++)
67 r.unite(script_l_arr_[i]->height());
71 Note_column::do_width()const return r;
74 r.unite(stem_l_->width());
75 for (int i=0; i < head_l_arr_.size(); i++)
76 r.unite(head_l_arr_[i]->width());
77 for (int i=0; i < script_l_arr_.size(); i++)
78 r.unite(script_l_arr_[i]->width());
82 Note_column::do_pre_processing()
84 if (!script_l_arr_.size())
87 Array<Script*> placed_l_arr_a[4];
88 for (int i=0; i < script_l_arr_.size(); i++) {
89 Script*s_l = script_l_arr_[i];
90 int j = (s_l->dir_i_ >0) ? 0 : 2;
91 if (!s_l->inside_staff_b_)
94 placed_l_arr_a[j].push(s_l);
96 for (int j =0; j <4; j++) {
97 placed_l_arr_a[j].sort( Script::compare);
100 Notehead *top_head_l=0;
101 Notehead *bot_head_l=0;
102 for (int i=0; i< head_l_arr_.size(); i++) {
103 if (head_l_arr_[i]->extremal == -1)
104 bot_head_l = head_l_arr_[i];
105 else if (head_l_arr_[i]->extremal == 1)
106 top_head_l = head_l_arr_[i];
108 /* argh. This sux. */
110 top_head_l = bot_head_l;
112 bot_head_l = top_head_l;
113 assert(bot_head_l && top_head_l);
114 Item *support_l=top_head_l;
116 for (j = 0; j < 2; j++ ) {
117 for (int i=0; i < placed_l_arr_a[j].size(); i++) {
118 placed_l_arr_a[j][i]->add_support(support_l);
119 support_l = placed_l_arr_a[j][i];
123 support_l=bot_head_l;
124 for (; j < 4; j++ ) {
125 for (int i=0; i < placed_l_arr_a[j].size(); i++) {
126 placed_l_arr_a[j][i]->add_support(support_l);
127 support_l = placed_l_arr_a[j][i];
131 Note_column::Note_column()