]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/word-wrap.cc
patch::: 1.2.12.jcn2
[lilypond.git] / lily / word-wrap.cc
index 49eeb41efd2d083c49f7d066a64c7f82a4575c09..cf6a95e9febcba39e3280f8608ce2b27a1a7ed6b 100644 (file)
@@ -8,10 +8,10 @@
 
 #include "word-wrap.hh"
 #include "paper-def.hh"
-#include "p-score.hh"
+#include "paper-score.hh"
 #include "debug.hh"
-#include "p-col.hh"
-#include "spring-spacer.hh"
+#include "paper-column.hh"
+#include "line-spacer.hh"
 
 
 /** El stupido.  Add a measure until we're past the optimum.
@@ -20,7 +20,6 @@
    A Dynamic Programming type of algorithm
    similar to TeX's is in Gourlay_breaking
 
-
    UGH.  Should think about pre/post break columns.
    */
 Array<Column_x_positions>
@@ -36,7 +35,6 @@ Word_wrap::do_solve () const
   assert (breakpoints.size ()>=2);
 
   int break_idx=0;
-  int line_no = 0;
   while (break_idx < breakpoints.size () -1)
     {
       Column_x_positions minimum;
@@ -44,8 +42,8 @@ Word_wrap::do_solve () const
 
 
       // do  another line
-      line_no ++;
-      Item *post = breakpoints[break_idx]->find_prebroken_piece (RIGHT);
+
+      Item *post = breakpoints[break_idx]->find_broken_piece (RIGHT);
       Paper_column *postcol =dynamic_cast<Paper_column*>(post);
       
       int start_break_idx = break_idx;
@@ -62,21 +60,21 @@ Word_wrap::do_solve () const
              curcol_idx++;
            }
 
-         Item * pre = breakpoints[break_idx]->find_prebroken_piece (LEFT);
+         Item * pre = breakpoints[break_idx]->find_broken_piece (LEFT);
          Paper_column* precol = dynamic_cast<Paper_column*>(pre);
          current.add_paper_column (precol);
 
-         current.spacer_l_ = generate_spacing_problem (current.cols, 
-           pscore_l_->paper_l_->line_dimensions_int (line_no));
+         current.spacer_l_ = generate_spacing_problem (current.cols_
+           pscore_l_->paper_l_->line_dimensions_int (breaking.size ()));
 
          // try to solve
-         if (!feasible (current.cols))
+         if (!feasible (current.cols_))
            {
-             if (!minimum.cols.size ())
+             if (!minimum.cols_.size ())
                {
-                 warning (_ ("ugh, this measure is too long") 
-                   + ", " + _f ("breakpoint: %d", break_idx) 
-                   + "(" + _ ("generating stupido solution") + ")");
+                 warning (_f ("Ugh, this measure is too long, breakpoint: %d",
+                   break_idx));
+                 warning (_ ("Generating stupido solution"));
                  current.stupid_solution ();
                  current.energy_f_ = - 1; // make sure we break out.
                }
@@ -99,20 +97,24 @@ Word_wrap::do_solve () const
              break;
            }
 
+         /*
+           UGR! bug! 
+          */
          if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0)
            {
              minimum = current;
            }
-         else {                // we're one col too far.
-           break_idx--;
-           while (allcols[curcol_idx] != breakpoints[break_idx])
-             curcol_idx --;
-           break;              // do the next line.
-         }
+         else
+           {           // we're one col too far.
+             break_idx--;
+             while (allcols[curcol_idx] != breakpoints[break_idx])
+               curcol_idx --;
+             break;            // do the next line.
+           }
 
 
          // add nobreak version of breakable column
-         current.cols.top ()=breakpoints[break_idx];
+         current.cols_.top ()=breakpoints[break_idx];
          curcol_idx ++;
          break_idx++;
        }
@@ -120,10 +122,7 @@ Word_wrap::do_solve () const
       *mlog << "[" << break_idx << "]" << flush;
       breaking.push (minimum);
     }
+  *mlog << endl;
   return breaking;
 }
 
-Word_wrap::Word_wrap ()
-{
-  get_line_spacer = Spring_spacer::constructor;
-}