]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.34
authorfred <fred>
Sun, 24 Mar 2002 19:33:05 +0000 (19:33 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:33:05 +0000 (19:33 +0000)
hdr/pcol.hh
hdr/sccol.hh
hdr/scorewalker.hh
input/twinkle.ly
src/calcideal.cc
src/pcol.cc
src/pscore.cc
src/sccol.cc
src/staff.cc
src/stcol.cc

index 21fdb698d9c2b9935d0b74e27f79889165faed38..4fac246e49a0e40aef7a9497d423071184cfcc9d 100644 (file)
@@ -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);
     
 
index 8237822219d4d58197454df845f9b3c551029c7f..e961d0492016418b425631ef34a4ba235030aebd 100644 (file)
@@ -44,7 +44,7 @@ public:
     void preprocess();
     bool breakable_b();
     bool musical_b() { return musical_b_; }
-    bool used();
+    bool used_b();
     void print() const;
 
 
index 0bfc99137416a4b9e0905cb026d0aa2d264fde65..fdbad24faef973a73d4c9a3f16cac05fb94a3351 100644 (file)
@@ -19,6 +19,7 @@
   */
 class Score_walker : public PCursor<Score_column *>
 {
+    Score* score_l_;
     /// walkers for the individual staves.
     Array<Staff_walker *> walker_p_arr_;
     Array<Staff_walker *> disallow_break_walk_l_arr;
index a356386099a97ecee73492ba95dd9ac12fe40a12..035854e84676b2efaeb41e76ab3e945ec6e90ddf 100644 (file)
@@ -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 
        }
index a656482e7dca39507df33c16aa3a760da04ec3e6..08180c64fbc7e4f6f780f298378c13c3beb687d7 100644 (file)
@@ -18,7 +18,7 @@ Score::calc_idealspacing()
     iter_top(cols_,i);
 
     for (; i.ok(); i++) {
-       assert(i->used());
+       assert(i->used_b());
        PCursor<Score_column*> j(i+1);
        if (i->musical_b()) {
            assert(j.ok());
index 5256947ce77c33fdb1eeb46d15d9595dbae9f595..4f1b65dcd716fe74d2a312475ab8671e3386a685 100644 (file)
@@ -115,7 +115,7 @@ PCol::add( Item *i)
 }
 
 bool
-PCol::used()const
+PCol::used_b()const
 {
     return breakable_b() || its.size();
 }
index c18fe83e01434433f6fba4610b236eae74d302dd..cebeb86f4cd4a576a65e988c64c3d187153938ba 100644 (file)
@@ -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++;
index 1722599b210ef089f4de69b5433468b6ec0ab0de..43d549b1756d8bdc43c66281bd7af78348e161d5 100644 (file)
@@ -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
index c93ca997cc87b285de6fb4b11a366408abad7935..a99696466125b5b3884762f5b92770c270206910 100644 (file)
@@ -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<Staff_column*> *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<Staff_column*> *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--;
@@ -90,7 +83,7 @@ void
 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++) {
            
@@ -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;
 }
index f3498db0e181d7a9e303ad003cab35cd7a2d1085..c12a0d898f0eec117d2b37a46decb37672032bb5 100644 (file)
@@ -5,13 +5,17 @@
 
   (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
@@ -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*> 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);
+}