2 staff-column.cc -- implement Staff_column
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "time-description.hh"
11 #include "score-column.hh"
12 #include "staff-column.hh"
13 #include "commandrequest.hh"
14 #include "musicalrequest.hh"
15 #include "interval.hh"
19 #include "voice-element.hh"
22 Staff_column::OK() const
25 assert (command_column_l_->when() == musical_column_l_->when());
30 Staff_column::when() const
32 return (command_column_l_)?
33 command_column_l_->when():
34 musical_column_l_->when();
38 Staff_column::add(Voice_element*ve)
40 for (iter_top(ve->reqs,j); j.ok(); j++) {
42 Command_req * c_l = j->command();
44 timing_req_l_arr_.push(j->command()->timing());
46 if (c_l->groupchange())
47 creationreq_l_arr_.push(c_l);
48 else if (!c_l->barcheck() && !c_l->partial() &&
49 !c_l->measuregrouping())
50 setup_one_request(j); // no need to bother children
53 musical_column_l_->add_duration(j->rhythmic()->duration());
55 if (!j->musical()->skip())
61 Staff_column::Staff_column()
63 musical_column_l_ = 0;
64 command_column_l_ = 0;
71 Staff_column::~Staff_column()
76 Staff_column::set_cols(Score_column*c1, Score_column*c2)
78 command_column_l_ = c1;
79 musical_column_l_ = c2;
83 Staff_column::setup_one_request(Request * j)
85 if (j->command()) // ugh
86 commandreq_l_arr_.push(j);
87 else if (j->musical())
88 musicalreq_l_arr_.push(j);
92 Staff_column::typeset_musical_item(Item*i)
95 Score_column * scorecolumn_l = musical_column_l_;
96 musical_column_l_->pcol_l_->pscore_l_->typeset_item(i, scorecolumn_l->pcol_l_,
101 align items in #item_l_arr#,
103 @return the width of the items after aligning.
106 align_items(Array<Item*> item_l_arr)
109 for (int i =0; i < item_l_arr.size(); i++) {
110 Interval item_width= item_l_arr[i]->width();
111 Real dx =wid.right - item_width.left;
113 item_l_arr[i]->translate(Offset(dx ,0));
114 wid.unite(item_width);
120 translate_items(Real x, Array<Item*> item_l_arr)
122 for (int i =0; i < item_l_arr.size(); i++)
123 item_l_arr[i]->translate(Offset(x, 0));
130 Staff_column::typeset_breakable_items(Array<Item *> &pre_p_arr,
131 Array<Item *> &nobreak_p_arr,
132 Array<Item *> &post_p_arr)
134 PCol * c= command_column_l_->pcol_l_;
135 PScore *ps_l=command_column_l_->pcol_l_->pscore_l_;
137 if (!c->breakable_b()) {
138 for (int i =0; i < pre_p_arr.size(); i++)
140 pre_p_arr.set_size(0);
141 for (int i =0; i < post_p_arr.size(); i++)
142 delete post_p_arr[i];
143 post_p_arr.set_size(0);
147 for (int i =0; i < pre_p_arr.size(); i++) {
148 ps_l->typeset_item(pre_p_arr[i], c, staff_l_->pstaff_l_,0);
150 for (int i =0; i < nobreak_p_arr.size(); i++) {
151 ps_l->typeset_item(nobreak_p_arr[i], c, staff_l_->pstaff_l_,1);
153 for (int i =0; i < post_p_arr.size(); i++) {
154 ps_l->typeset_item(post_p_arr[i], c, staff_l_->pstaff_l_,2);
157 Interval pre_wid= align_items(pre_p_arr);
158 translate_items( -pre_wid.right, pre_p_arr);
159 align_items(nobreak_p_arr);
160 Interval post_wid =align_items(post_p_arr);
161 translate_items (-post_wid.left , post_p_arr);
163 pre_p_arr.set_size(0);
164 post_p_arr.set_size(0);
165 nobreak_p_arr.set_size(0);