]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/gourlay-breaking.cc
* scm/page.scm (make-page): make it friendlier to call (esp. from C++)
[lilypond.git] / lily / gourlay-breaking.cc
index dfbd0b0f5c3ae714058939b81f0a5e2a637c54af..f5e29ad18d662463d796070a6a81cae7537f5206 100644 (file)
@@ -75,19 +75,19 @@ print_break_nodes (vector<Break_node> const &arr)
    inspiration.
 */
 vector<Column_x_positions>
-Gourlay_breaking::do_solve () const
+Gourlay_breaking::solve () 
 {
   vector<Break_node> optimal_paths;
   vector<Grob*> all
     = pscore_->root_system ()->columns ();
 
-  vector<int> breaks = find_break_indices ();
+  vector<vsize> breaks = pscore_->find_break_indices ();
 
   Break_node first_node;
   optimal_paths.push_back (first_node);
 
   bool ragged_right = to_boolean (pscore_->layout ()->c_variable ("ragged-right"));
-  bool ragged_last = to_boolean (pscore_->layout ()->c_variable ("raggedlast"));
+  bool ragged_last = to_boolean (pscore_->layout ()->c_variable ("ragged-last"));
 
   Real worst_force = 0.0;
   for (vsize break_idx = 1; break_idx < breaks.size (); break_idx++)
@@ -105,27 +105,18 @@ Gourlay_breaking::do_solve () const
       for (vsize start_idx = break_idx; start_idx--;)
        {
          vector<Grob*> line (all.begin () + breaks[start_idx],
-                                 all.begin () + breaks[break_idx] + 1);
-
-         line[0] = dynamic_cast<Item *> (line[0])->find_prebroken_piece (RIGHT);
-         line.back () = dynamic_cast<Item *> (line.back ())->find_prebroken_piece (LEFT);
-
-         Column_x_positions cp;
-         cp.cols_ = line;
+                             all.begin () + breaks[break_idx] + 1);
 
          Interval line_dims
            = line_dimensions_int (pscore_->layout (), optimal_paths[start_idx].line_);
-         Simple_spacer_wrapper *sp = generate_spacing_problem (line, line_dims);
          bool last_line = break_idx == breaks.size () - 1;
-         bool ragged = ragged_right
-           || (last_line && ragged_last);
-
-         sp->solve (&cp, ragged);
+         bool ragged = ragged_right || (last_line && ragged_last);
 
-         delete sp;
+         Column_x_positions cp = get_line_configuration (line, line_dims[RIGHT] - line_dims[LEFT],
+                                                         line_dims[LEFT], ragged);
 
          if (ragged && last_line)
-           cp.force_ = 0.0;
+           cp.force_ = min (cp.force_, 0.0);
 
          if (fabs (cp.force_) > worst_force)
            worst_force = fabs (cp.force_);
@@ -236,7 +227,7 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
   Grob *pc = this_one.cols_.back ();
   if (pc->original ())
     {
-      SCM pen = pc->get_property ("penalty");
+      SCM pen = pc->get_property ("line-break-penalty");
       if (scm_is_number (pen) && fabs (scm_to_double (pen)) < 10000)
        break_penalties += scm_to_double (pen);
     }