]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/p-score.cc
patch::: 0.0.75.jcn4: midi op
[lilypond.git] / lily / p-score.cc
index bf91890d77dee78491daf405623a6000e9e3104c..2c841887298f24c522fb045881f03b47f1851967 100644 (file)
@@ -1,7 +1,7 @@
 /*
   p-score.cc -- implement PScore
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 #include "lookup.hh"
 #include "spanner.hh"
 #include "paper-def.hh"
-#include "molecule.hh"
-#include "dimen.hh"
 #include "scoreline.hh"
 #include "p-score.hh"
 #include "tex-stream.hh"
-#include "item.hh"
 #include "break.hh"
 #include "p-col.hh"
 
+PScore::PScore(Paper_def*p)
+{
+    paper_l_ = p;
+    super_elem_l_   = new Super_elem;
+    typeset_element(super_elem_l_);
+}
+
+PScore::~PScore()
+{
+    super_elem_l_->unlink_all();
+}
+
 void
 PScore::typeset_element(Score_elem * elem_p)
 {
     elem_p_list_.bottom().add(elem_p);
     elem_p->pscore_l_ = this;
+
     elem_p->add_processing();
 }
 
@@ -34,12 +44,12 @@ PScore::typeset_item(Item *i, PCol *c, int breakstat)
 {
     assert(c && i);
 
-    if (breakstat == 0) {
+    if (breakstat == -1) {
        typeset_item(i, c->prebreak_p_);
        return;
     }
 
-    if (breakstat == 2) {
+    if (breakstat == 1) {
        typeset_item(i, c->postbreak_p_);
        return;
     }
@@ -64,6 +74,12 @@ PScore::typeset_unbroken_spanner(Spanner*span_p)
 {
     spanners.bottom().add(span_p);
     span_p->pscore_l_=this;
+
+    if (     span_p->left_col_l_) 
+       span_p->left_col_l_->used_b_ = true;
+    if ( span_p->right_col_l_)
+       span_p->right_col_l_->used_b_ = true;
+    
     // do not init start/stop fields. These are for broken spans only.
     span_p->add_processing();
 }
@@ -125,13 +141,6 @@ PScore::add(PCol *p)
     cols.bottom().add(p);
 }
 
-PScore::PScore(Paper_def*p)
-{
-    paper_l_ = p;
-    super_elem_l_   = new Super_elem;
-    typeset_element(super_elem_l_);
-}
-
 void
 PScore::output(Tex_stream &ts)
 {
@@ -141,11 +150,6 @@ PScore::output(Tex_stream &ts)
 }
 
 
-PScore::~PScore()
-{
-    super_elem_l_->unlink_all();
-}
-
 void
 PScore::OK()const
 {
@@ -166,6 +170,9 @@ PScore::print() const
     mtor << "\n elements: ";
     for (iter_top(elem_p_list_,cc); cc.ok(); cc++)     
        cc->print();
+    mtor << "\n unbroken spanners: ";
+    for (iter(spanners.top(), i); i.ok(); i++)
+       i->print();
     mtor << "\ncolumns: ";
      for (iter_top(cols,cc); cc.ok(); cc++)
        cc->print();
@@ -180,6 +187,7 @@ PScore::print() const
 void
 PScore::preprocess()
 {
+    super_elem_l_->breakable_col_processing();
     super_elem_l_->pre_processing();
 }
 
@@ -208,7 +216,7 @@ PScore::set_breaking(Array<Col_hpositions> const &breaking)
     super_elem_l_->break_processing();
 
 
-    for (iter_top(spanners,i); i.ok(); ) {
+    for (iter(spanners.top(),i); i.ok(); ) {
        Spanner *span_p = i.remove_p();
        if (span_p->broken_b()) {
            span_p->unlink();
@@ -217,6 +225,17 @@ PScore::set_breaking(Array<Col_hpositions> const &breaking)
            typeset_broken_spanner(span_p);
        }
     }
+    for (iter(elem_p_list_.top(),i ); i.ok() ;) {
+       Item *i_l =i->item();
+       if ( i_l && !i_l->pcol_l_->line_l_) {
+           i_l->unlink();
+           delete i.remove_p();
+       } else
+           i++;
+    }
+
+    for (iter_top(cols, i); i.ok(); i++)
+       i->clean_breakable_items();
 }
 
 void
@@ -239,6 +258,26 @@ PScore::process()
     postprocess();
 }
 
+/** Get all breakable columns between l and r, (not counting l and r).  */
+Link_array<PCol>
+PScore::breakable_col_range(PCol*l,PCol*r)const
+{
+    Link_array<PCol> ret;
+
+    PCursor<PCol*> start(l ? find_col(l)+1 : cols.top() );
+    PCursor<PCol*> stop(r ? find_col(r) : cols.bottom());
+
+    /*
+      ugh! windows-suck-suck-suck.
+     */
+    while ( PCursor<PCol*>::compare(start,stop) < 0 ) {
+       if (start->breakable_b())
+           ret.push(start);
+       start++;
+    }
+
+    return ret;
+}
 Link_array<PCol>
 PScore::col_range(PCol*l,PCol*r)const
 {
@@ -247,8 +286,32 @@ PScore::col_range(PCol*l,PCol*r)const
     PCursor<PCol*> start(l ? find_col(l)+1 : cols.top() );
     PCursor<PCol*> stop(r ? find_col(r) : cols.bottom());
     ret.push(l);
-    while ( start < stop )
+    
+    /*
+      ugh! windows-suck-suck-suck.
+     */
+    while ( PCursor<PCol*>::compare(start,stop) < 0 )
        ret.push(start++);
     ret.push(r);
     return ret;
 }
+
+Link_array<PCol>
+PScore::broken_col_range(PCol*l,PCol*r)const
+{
+    Link_array<PCol> ret;
+
+    PCursor<PCol*> start(l ? find_col(l)+1 : cols.top() );
+    PCursor<PCol*> stop(r ? find_col(r) : cols.bottom());
+  
+    /*
+      ugh! windows-suck-suck-suck.
+      */
+    while ( PCursor<PCol*>::compare(start,stop) < 0 ) {
+       if (start->breakable_b() && !start->line_l_ )
+           ret.push(start);
+       start++;
+    }
+
+    return ret;
+}