2 stcol.cc -- implement Staff_column
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "timedescription.hh"
13 #include "commandrequest.hh"
14 #include "musicalrequest.hh"
15 #include "interval.hh"
21 Staff_column::OK() const
24 assert (command_column_l_
->when() == musical_column_l_
->when());
29 Staff_column::when() const
31 return (command_column_l_
)?
32 command_column_l_
->when():
33 musical_column_l_
->when();
37 Staff_column::add(Voice_element
*ve
)
39 for (iter_top(ve
->reqs
,j
); j
.ok(); j
++) {
41 Nonmusical_req
* c_l
= j
->nonmus();
43 timing_req_l_arr_
.push(j
->nonmus()->timing());
45 if (!c_l
->barcheck() && !c_l
->partial() &&
46 !c_l
->measuregrouping())
47 setup_one_request(j
); // no need to bother children
50 musical_column_l_
->add_duration(j
->rhythmic()->duration());
52 if (!j
->musical()->skip())
58 Staff_column::Staff_column()
60 musical_column_l_
= 0;
61 command_column_l_
= 0;
68 Staff_column::~Staff_column()
73 Staff_column::set_cols(Score_column
*c1
, Score_column
*c2
)
75 command_column_l_
= c1
;
76 musical_column_l_
= c2
;
80 Staff_column::setup_one_request(Request
* j
)
82 if (j
->nonmus()) // ugh
83 commandreq_l_arr_
.push(j
);
84 else if (j
->musical())
85 musicalreq_l_arr_
.push(j
);
89 Staff_column::typeset_musical_item(Item
*i
)
92 Score_column
* sccol_l
= musical_column_l_
;
93 musical_column_l_
->pcol_l_
->pscore_l_
->typeset_item(i
, sccol_l
->pcol_l_
,
98 align items in #item_l_arr#, return the width.
101 align_items(Array
<Item
*> item_l_arr
)
104 for (int i
=0; i
< item_l_arr
.size(); i
++) {
105 Interval item_width
= item_l_arr
[i
]->width();
106 item_l_arr
[i
]->translate(Offset( wid
.right
- item_width
.left
,0));
107 wid
.unite(item_width
);
113 translate_items(Real x
, Array
<Item
*> item_l_arr
)
115 for (int i
=0; i
< item_l_arr
.size(); i
++)
116 item_l_arr
[i
]->translate(Offset(x
, 0));
123 Staff_column::typeset_breakable_items(Array
<Item
*> &pre_p_arr
,
124 Array
<Item
*> &nobreak_p_arr
,
125 Array
<Item
*> &post_p_arr
)
127 PCol
* c
= command_column_l_
->pcol_l_
;
128 PScore
*ps_l
=command_column_l_
->pcol_l_
->pscore_l_
;
130 if (!c
->breakable_b()) {
131 for (int i
=0; i
< pre_p_arr
.size(); i
++)
133 pre_p_arr
.set_size(0);
134 for (int i
=0; i
< post_p_arr
.size(); i
++)
135 delete post_p_arr
[i
];
136 post_p_arr
.set_size(0);
140 for (int i
=0; i
< pre_p_arr
.size(); i
++) {
141 ps_l
->typeset_item(pre_p_arr
[i
], c
, staff_l_
->pstaff_l_
,0);
143 for (int i
=0; i
< nobreak_p_arr
.size(); i
++) {
144 ps_l
->typeset_item(nobreak_p_arr
[i
], c
, staff_l_
->pstaff_l_
,1);
146 for (int i
=0; i
< post_p_arr
.size(); i
++) {
147 ps_l
->typeset_item(post_p_arr
[i
], c
, staff_l_
->pstaff_l_
,2);
150 Interval pre_wid
= align_items(pre_p_arr
);
151 translate_items( -pre_wid
.right
, pre_p_arr
);
152 align_items(nobreak_p_arr
);
153 Interval post_wid
=align_items(post_p_arr
);
154 translate_items (-post_wid
.left
, post_p_arr
);
156 pre_p_arr
.set_size(0);
157 post_p_arr
.set_size(0);
158 nobreak_p_arr
.set_size(0);