void
Staff::clean_cols()
{
- iter_top(cols,i);
+ iter_top(cols_,i);
for(; i.ok(); ){
- if (!i->musical_column_l_->used())
+ if (!i->musical_column_l_->used_b())
i->musical_column_l_ = 0;
- if (!i->command_column_l_->used())
+ if (!i->command_column_l_->used_b())
i->command_column_l_ =0;
if (!i->command_column_l_&& !i->musical_column_l_)
}
}
-// Midi_track*
-// Staff::midi_track_p()
-// {
-// Midi_track_p midi_track_p = new Midi_track;
-// Midi_walker( *this );
-// }
-
Staff_column *
Staff::get_col(Moment w, PCursor<Staff_column*> *last)
{
- iter_top(cols,i);
+ iter_top(cols_,i);
if (last && last->ok() && (*last)->when() <= w)
i = *last;
PCursor<Score_column*> sccols(score_l_->find_col(w, false));
- Staff_column* stcol_p = create_col();
-
+ Staff_column* stcol_p = new Staff_column;
+ stcol_p->staff_l_ = this;
Score_column* comcol_l = sccols++;
stcol_p->set_cols(comcol_l, sccols);
if (!i.ok()) {
- cols.bottom().add( stcol_p);
- i = cols.bottom();
+ cols_.bottom().add( stcol_p);
+ i = cols_.bottom();
} else {
i.insert(stcol_p);
i--;
Staff::setup_staffcols()
{
for (iter_top(voice_list_,i); i.ok(); i++) {
- PCursor<Staff_column*> last(cols);
+ PCursor<Staff_column*> last(cols_);
Moment now = i->start;
for (iter_top(i->elts,j); j.ok(); j++) {
s_l->add(j);
now += j->duration;
}
-// get_col(now,last);
+
}
OK();
}
Staff::OK() const
{
#ifndef NDEBUG
- cols.OK();
+ cols_.OK();
voice_list_.OK();
- iter_top(cols, i);
- iter_top(cols, j);
+ iter_top(cols_, i);
+ iter_top(cols_, j);
i++;
for (; i.ok(); j++,i++) {
assert(j->when () < i->when() );
Staff::Staff()
{
score_l_ =0;
- pscore_l_ =0;
+ pscore_l_ =0;
+ pstaff_l_ =0;
}
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-
+#include "staff.hh"
#include "voice.hh"
#include "timedescription.hh"
#include "sccol.hh"
#include "stcol.hh"
#include "commandrequest.hh"
#include "musicalrequest.hh"
+#include "interval.hh"
+#include "pscore.hh"
+#include "item.hh"
+#include "pcol.hh"
void
Staff_column::OK() const
{
for (iter_top(ve->reqs,j); j.ok(); j++) {
if (j->nonmus()) {
- if (j->nonmus()->timing()) {
+ Nonmusical_req * c_l = j->nonmus();
+ if (c_l->timing()) {
timing_req_l_arr_.push(j->nonmus()->timing());
}
- if (!j->barcheck() && !j->nonmus()->measuregrouping())
+ if (!c_l->barcheck() && !c_l->partial() &&
+ !c_l->measuregrouping())
setup_one_request(j); // no need to bother children
} else {
if (j->rhythmic()) {
musical_column_l_->add_duration(j->rhythmic()->duration());
}
- setup_one_request(j);
+ if (!j->musical()->skip())
+ setup_one_request(j);
}
}
}
{
musical_column_l_ = 0;
command_column_l_ = 0;
+ staff_l_ = 0;
}
command_column_l_ = c1;
musical_column_l_ = c2;
}
+
+void
+Staff_column::setup_one_request(Request * j)
+{
+ if (j->nonmus()) // ugh
+ commandreq_l_arr_.push(j);
+ else if (j->musical())
+ musicalreq_l_arr_.push(j);
+}
+
+void
+Staff_column::typeset_musical_item(Item*i)
+{
+ assert(i);
+ Score_column * sccol_l = musical_column_l_;
+ musical_column_l_->pcol_l_->pscore_l_->typeset_item(i, sccol_l->pcol_l_,
+ staff_l_->pstaff_l_);
+}
+
+/**
+ align items in #item_l_arr#, return the width.
+ */
+Interval
+align_items(Array<Item*> item_l_arr)
+{
+ Interval wid(0,0);
+ for (int i =0; i < item_l_arr.size(); i++) {
+ Interval item_width= item_l_arr[i]->width();
+ item_l_arr[i]->translate(Offset( wid.right - item_width.left ,0));
+ wid.unite(item_width);
+ }
+ return wid;
+}
+
+void
+translate_items(Real x, Array<Item*> item_l_arr)
+{
+ for (int i =0; i < item_l_arr.size(); i++)
+ item_l_arr[i]->translate(Offset(x, 0));
+}
+/*
+ UGR
+ This still sux
+ */
+void
+Staff_column::typeset_breakable_items(Array<Item *> &pre_p_arr,
+ Array<Item *> &nobreak_p_arr,
+ Array<Item *> &post_p_arr)
+{
+ PCol * c= command_column_l_->pcol_l_;
+ PScore *ps_l=command_column_l_->pcol_l_->pscore_l_;
+
+ if (!c->breakable_b()) {
+ for (int i =0; i < pre_p_arr.size(); i++)
+ delete pre_p_arr[i];
+ pre_p_arr.set_size(0);
+ for (int i =0; i < post_p_arr.size(); i++)
+ delete post_p_arr[i];
+ post_p_arr.set_size(0);
+ }
+
+
+ for (int i =0; i < pre_p_arr.size(); i++) {
+ ps_l->typeset_item(pre_p_arr[i], c, staff_l_->pstaff_l_,0);
+ }
+ for (int i =0; i < nobreak_p_arr.size(); i++) {
+ ps_l->typeset_item(nobreak_p_arr[i], c, staff_l_->pstaff_l_,1);
+ }
+ for (int i =0; i < post_p_arr.size(); i++) {
+ ps_l->typeset_item(post_p_arr[i], c, staff_l_->pstaff_l_,2);
+ }
+
+ Interval pre_wid= align_items(pre_p_arr);
+ translate_items( -pre_wid.right, pre_p_arr);
+ align_items(nobreak_p_arr);
+ Interval post_wid =align_items(post_p_arr);
+ translate_items (-post_wid.left , post_p_arr);
+
+ pre_p_arr.set_size(0);
+ post_p_arr.set_size(0);
+ nobreak_p_arr.set_size(0);
+}