]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.2
authorfred <fred>
Thu, 10 Oct 1996 14:05:31 +0000 (14:05 +0000)
committerfred <fred>
Thu, 10 Oct 1996 14:05:31 +0000 (14:05 +0000)
break.cc
line.cc
misc.cc
score.cc

index 8f76d13fdca6e3cc7a5a144f556ab36bacf730b5..0647d5f3e20c27b24e02b6e3dce99d17b4a124a7 100644 (file)
--- a/break.cc
+++ b/break.cc
@@ -57,7 +57,11 @@ struct Col_configuration {
 };
 
 /// wordwrap type algorithm
-/* el stupido. This should be optimised...
+/* el stupido. This should be optimised:
+
+   It would be nice to have a Dynamic Programming type of algorithm
+   similar to TeX's
+   
     */
 
 void
@@ -87,7 +91,7 @@ PScore::calc_breaking()
            }
            current.add(breakpoints[i]->prebreak );
            current.setsol(solve_line(current.line));
-
+           mtor << "energy : " << current.energy << '\n';
            
            if (current.energy < minimum.energy) {
                minimum = current;
@@ -99,7 +103,7 @@ PScore::calc_breaking()
            curcol ++;
            i++;
        }
-
+       mtor << "Adding line, next breakpoint " << i << '\n';
        add_line(minimum.line, minimum.config); 
     }
 }
diff --git a/line.cc b/line.cc
index 9311aeb22d726cc819e1976b03c0f8990d27b18f..88e2f3eb28463badf9ddfbd45e98113345618e6a 100644 (file)
--- a/line.cc
+++ b/line.cc
@@ -1,4 +1,5 @@
 #include "line.hh"
+#include "symbol.hh"
 #include "cols.hh"
 #include "pscore.hh"
 
@@ -6,7 +7,7 @@ String
 Line_of_staff::TeXstring() const
 {
     String s("%line_of_staff\n\\vbox to ");
-    s += String(height * VERT_TO_PT) +"pt{";
+    s += String(maxheight() * VERT_TO_PT) +"pt{";
 
     //make some room
     s += vstrut(base* VERT_TO_PT);
@@ -92,3 +93,31 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
            brokenspans.bottom().add(sp->broken_at(brokenstop, brokenstart));
     }
 }
+
+
+Real
+Line_of_staff::maxheight() const
+{
+    Interval y;
+    y = pstaff_->stafsym->height(scor->score->linewidth);
+    PCursor<const PCol *> cc(scor->cols);
+    
+    // all items in the current line & staff.
+    for (; cc.ok(); cc++) {
+
+               
+       for (PCursor<const Item *> ic(cc->its); ic.ok(); ic++) {
+           if (ic->pstaff_ == pstaff_) {
+               y.unite(ic->height());
+       }
+           
+       // spanners.
+       for (PCursor<const Spanner *> sc(cc->starters); sc.ok(); sc++)
+           if (sc->pstaff_ == pstaff_)
+               assert(false);          
+       }
+    }
+    return y.max;
+}
+
+
diff --git a/misc.cc b/misc.cc
index d07c358d1a05c37c3be7d90ea87cb09895183aa3..effab35896fee3a3cfbb8a0a006e2d958ec847b4 100644 (file)
--- a/misc.cc
+++ b/misc.cc
@@ -21,7 +21,8 @@ double log2(double x) {
  
 const Real PHI = (1+sqrt(5))/2;
 const double ENGRAVERS_SPACE = PHI;
-const double WHOLE_SPACE = 10.0;
+const double WHOLE_SPACE = 5.0; // should be settable from input
+
 
   
 Real
@@ -30,3 +31,7 @@ duration_to_idealspace(Mtime d)
     // see  Roelofs, p. 57
     return WHOLE_SPACE * pow(ENGRAVERS_SPACE, log2(d));
 }
+
+
+
+
index 543aca0d5ad2cbd085d3a4d91f8f380fb5dfb0c9..b2b520c4433da53043a42a0853bbc299d2ca1e91 100644 (file)
--- a/score.cc
+++ b/score.cc
@@ -9,7 +9,30 @@
 void
 Score::add(Command *c)
 {
-    commands_.bottom().add(new Command(*c));
+    if (c->code == TYPESET && c->args[0] == "BAR") {
+       /* should be encapsulated in BREAKs
+
+          THIS SUX.
+
+        */
+       Command k;
+       
+       k.when = c->when;
+       k.code = BREAK_PRE;
+       commands_.bottom().add(new Command(k));
+       commands_.bottom().add(new Command(*c));
+       k.code = BREAK_MIDDLE;
+       commands_.bottom().add(new Command(k));
+       commands_.bottom().add(new Command(*c));
+       k.code = BREAK_POST;
+       commands_.bottom().add(new Command(k));
+       k.code = BREAK_END;
+       commands_.bottom().add(new Command(k));
+    }
+    else
+       commands_.bottom().add(new Command(*c));
+    
+    
 }
 
 void
@@ -103,12 +126,16 @@ Score::process()
        sc->set_output(pscore_);
        sc->process();
     }
+
+    // do this after processing, staffs first have to generate PCols.
     do_pcols();
     calc_idealspacing();
     clean_cols();
     OK();
     //    print();
     pscore_->calc_breaking();
+    // TODO: calculate vertical structs
+    // TODO: calculate mixed structs.
 }
 
 // remove empty cols with no spacing attached.