From: fred Date: Sun, 24 Mar 2002 19:33:05 +0000 (+0000) Subject: lilypond-0.0.34 X-Git-Tag: release/1.5.59~5313 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=720facdfd85aa0c4457cd17a876b2326101c4b52;p=lilypond.git lilypond-0.0.34 --- diff --git a/hdr/pcol.hh b/hdr/pcol.hh index 21fdb698d9..4fac246e49 100644 --- a/hdr/pcol.hh +++ b/hdr/pcol.hh @@ -51,8 +51,8 @@ struct PCol { /// which one (left =0) int rank() const; - /// does this column have items, does it have spacings attached? - bool used() const; + /// does this column have items + bool used_b() const; void add(Item *i); @@ -64,10 +64,10 @@ struct PCol { PCol(PCol * parent); /** - which col comes first?. - signed compare on columns. + which col comes first?. + signed compare on columns. - @return < 0 if c1 < c2. + @return < 0 if c1 < c2. */static int compare(const PCol &c1, const PCol &c2); diff --git a/hdr/sccol.hh b/hdr/sccol.hh index 8237822219..e961d04920 100644 --- a/hdr/sccol.hh +++ b/hdr/sccol.hh @@ -44,7 +44,7 @@ public: void preprocess(); bool breakable_b(); bool musical_b() { return musical_b_; } - bool used(); + bool used_b(); void print() const; diff --git a/hdr/scorewalker.hh b/hdr/scorewalker.hh index 0bfc991374..fdbad24fae 100644 --- a/hdr/scorewalker.hh +++ b/hdr/scorewalker.hh @@ -19,6 +19,7 @@ */ class Score_walker : public PCursor { + Score* score_l_; /// walkers for the individual staves. Array walker_p_arr_; Array disallow_break_walk_l_arr; diff --git a/input/twinkle.ly b/input/twinkle.ly index a356386099..035854e846 100644 --- a/input/twinkle.ly +++ b/input/twinkle.ly @@ -152,11 +152,9 @@ score { } commands { meter {2 * 4} -% skip 24*2 + skip {24*2} % bar "||" } - staff { midi_track music { melodie } } - staff { midi_track music { begeleiding } } midi { tempo 4:120 } diff --git a/src/calcideal.cc b/src/calcideal.cc index a656482e7d..08180c64fb 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -18,7 +18,7 @@ Score::calc_idealspacing() iter_top(cols_,i); for (; i.ok(); i++) { - assert(i->used()); + assert(i->used_b()); PCursor j(i+1); if (i->musical_b()) { assert(j.ok()); diff --git a/src/pcol.cc b/src/pcol.cc index 5256947ce7..4f1b65dcd7 100644 --- a/src/pcol.cc +++ b/src/pcol.cc @@ -115,7 +115,7 @@ PCol::add( Item *i) } bool -PCol::used()const +PCol::used_b()const { return breakable_b() || its.size(); } diff --git a/src/pscore.cc b/src/pscore.cc index c18fe83e01..cebeb86f4c 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -27,7 +27,7 @@ void PScore::clean_cols() { for (iter_top(cols,c); c.ok(); ) - if (!c->used()) { + if (!c->used_b()) { delete c.get(); } else c++; diff --git a/src/sccol.cc b/src/sccol.cc index 1722599b21..43d549b175 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -30,8 +30,8 @@ Score_column::Score_column(Moment w) } bool -Score_column::used() { - return pcol_l_->used(); +Score_column::used_b() { + return pcol_l_->used_b(); } void diff --git a/src/staff.cc b/src/staff.cc index c93ca997cc..a996964661 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -26,11 +26,11 @@ Staff::paper() const 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_) @@ -40,17 +40,10 @@ Staff::clean_cols() } } -// 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 *last) { - iter_top(cols,i); + iter_top(cols_,i); if (last && last->ok() && (*last)->when() <= w) i = *last; @@ -65,14 +58,14 @@ Staff::get_col(Moment w, PCursor *last) PCursor 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--; @@ -90,7 +83,7 @@ void Staff::setup_staffcols() { for (iter_top(voice_list_,i); i.ok(); i++) { - PCursor last(cols); + PCursor last(cols_); Moment now = i->start; for (iter_top(i->elts,j); j.ok(); j++) { @@ -99,7 +92,7 @@ Staff::setup_staffcols() s_l->add(j); now += j->duration; } -// get_col(now,last); + } OK(); } @@ -108,10 +101,10 @@ void 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() ); @@ -146,5 +139,6 @@ Staff::print() const Staff::Staff() { score_l_ =0; - pscore_l_ =0; + pscore_l_ =0; + pstaff_l_ =0; } diff --git a/src/stcol.cc b/src/stcol.cc index f3498db0e1..c12a0d898f 100644 --- a/src/stcol.cc +++ b/src/stcol.cc @@ -5,13 +5,17 @@ (c) 1997 Han-Wen Nienhuys */ - +#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 @@ -34,16 +38,19 @@ Staff_column::add(Voice_element*ve) { 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); } } } @@ -52,6 +59,7 @@ Staff_column::Staff_column() { musical_column_l_ = 0; command_column_l_ = 0; + staff_l_ = 0; } @@ -67,3 +75,85 @@ Staff_column::set_cols(Score_column*c1, Score_column*c2) 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_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_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 &pre_p_arr, + Array &nobreak_p_arr, + Array &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); +}