]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.5
authorfred <fred>
Fri, 25 Oct 1996 12:57:12 +0000 (12:57 +0000)
committerfred <fred>
Fri, 25 Oct 1996 12:57:12 +0000 (12:57 +0000)
pcol.cc
pscore.cc

diff --git a/pcol.cc b/pcol.cc
index 44c82a938ddf67ff316bbb82c0663638c2a4c32c..1ae06519ac55c90f4ae61c2904788e130651699a 100644 (file)
--- a/pcol.cc
+++ b/pcol.cc
@@ -5,10 +5,10 @@
 void
 Idealspacing::print() const
 {
-    #ifndef NPRINT
+#ifndef NPRINT
     mtor << "idealspacing {" ;
     mtor << "distance "<<space<< " strength " << hooke << "}\n";
-    #endif
+#endif
 }
 
 Idealspacing::Idealspacing(const PCol * l,const PCol * r)
@@ -18,6 +18,7 @@ Idealspacing::Idealspacing(const PCol * l,const PCol * r)
     left = l;
     right = r;
 }
+
 void
 Idealspacing::OK() const
 {
@@ -46,7 +47,11 @@ PCol::print() const
     #ifndef NPRINT
     mtor << "PCol {";
     mtor << "# symbols: " << its.size() ;
-    mtor << "breakable: " << breakable<<"\n";
+    if (breakable()){
+       mtor << "pre,post: ";
+       prebreak->print();
+       postbreak->print();
+    }
     mtor << "extent: " << width().min << ", " << width().max << "\n";
     mtor << "}\n";
     #endif 
@@ -63,7 +68,9 @@ void
 PCol::OK () const
 {
     if (prebreak || postbreak ) {
-       assert(breakable);
+       assert(prebreak&&postbreak);
+       assert(prebreak->daddy == this);
+       assert(postbreak->daddy == this);
     }
     
 }
@@ -71,29 +78,33 @@ PCol::OK () const
 void
 PCol::set_breakable()
 {
-    if (breakable)
+    if (breakable())
        return;
 
     prebreak = new PCol(this);
     postbreak = new PCol(this);
-    breakable = true;
     used = true;
 }
 
+bool
+PCol::breakable() const
+{
+    return prebreak||postbreak;
+}
+
 PCol::PCol(PCol *parent) {
     daddy = parent;
     prebreak=0;
     postbreak=0;
-    breakable=false;
     line=0;
     used  = false;
 }
 
 PCol::~PCol()
 {
-    if (prebreak)
-       delete prebreak;        // no recursion!
-    if (postbreak)
+
+       delete prebreak;        
+
        delete postbreak;       
 }
 
index 44a87c0dd4d4416ca4912e06f6283b00a2093f16..773554375c8e2d280f1337c07575352531a58d68 100644 (file)
--- a/pscore.cc
+++ b/pscore.cc
@@ -1,5 +1,6 @@
 // utility functions for PScore
 #include "debug.hh"
+#include "molecule.hh"
 #include "dimen.hh"
 #include "line.hh"
 #include "pscore.hh"
@@ -11,7 +12,6 @@ PScore::clean_cols()
     for (PCursor<PCol *> c(cols); c.ok(); )
        if (!c->used) {
            c.del();
-           mtor << "removing pcol\n";
        } else
            c++;
 }
@@ -27,15 +27,28 @@ void
 PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
 {
     assert(c && i && s);
-    if (breakstat == 1 ) {
-       typeset_item(i, c->prebreak, s, 0);
-    } if (breakstat == 3) 
-       typeset_item(i, c->prebreak, s, 0 );
-    else{
-       its.bottom().add(i);
-       s->add(i);
-       c->add(i);
+//    assert(!breakstat != 4 || c->breakable() );
+    if (breakstat == 0) {
+       typeset_item(i, c->prebreak, s);
+       return;
     }
+
+    if (breakstat == 2) {
+       typeset_item(i, c->postbreak, s);
+       return;
+    }
+    if (c->daddy && c == c->daddy->prebreak) { // makeshift.
+       Interval iv (i->width());
+       if (!iv.empty()) {
+           svec<Item*> col_its (select_items(s, c));
+           for (int j =0; j < col_its.sz(); j++)
+               col_its[j]->output->translate(Offset(-iv.length(),0));
+           i->output->translate (Offset(-iv.max, 0));
+       }
+    }
+    its.bottom().add(i);
+    s->add(i);
+    c->add(i);
 }
 
 void
@@ -70,7 +83,7 @@ PScore::find_breaks() const
 {
     svec<const PCol *> retval;
     for (PCursor<PCol *> c(cols); c.ok(); c++)
-       if (c->breakable)
+       if (c->breakable())
            retval.add(c);
            
     return retval;
@@ -84,7 +97,7 @@ PScore::add(PCol *p)
 
 PScore::PScore()
 {
-    linewidth = convert_dimen(15,"cm");
+    linewidth = convert_dimen(15,"cm");        // default
 }
 
 void
@@ -115,18 +128,18 @@ PScore::select_items(PStaff*ps , PCol*pc)
 void
 PScore::OK()const
 {
+#ifdef NDEBUG
     for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
        cc->OK();
     for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
        ic->OK();
-    
+#endif
 }
 void
 PScore::print() const
-{
-    
-     #ifndef NPRINT
-   mtor << "PScore { width "<<print_dimen(linewidth);
+{    
+#ifndef NPRINT
+    mtor << "PScore { width "<<print_dimen(linewidth);
     mtor << "\ncolumns: ";
     for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
        cc->print();
@@ -135,6 +148,6 @@ PScore::print() const
     for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
        ic->print();
     mtor << "}\n";
-   #endif 
+#endif 
 }