]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/system.cc
*** empty log message ***
[lilypond.git] / lily / system.cc
index 48f7034236bc3d26adb732d4eb5015d073cd6461..75c7a9555100f276ea2939b4fba9d9ba93f70465 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <math.h>
 
+#include "align-interface.hh"
 #include "axis-group-interface.hh"
 #include "warn.hh"
 #include "system.hh"
@@ -23,7 +24,7 @@
 #include "spacing-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "paper-book.hh"
-#include "paper-line.hh"
+#include "paper-system.hh"
 
 System::System (SCM s)
   : Spanner (s)
@@ -89,7 +90,7 @@ System::get_lines ()
            }
          g->suicide ();
        }
-      else if (g->live ())
+      else if (g->is_live ())
        g->do_break_processing ();
     }
 
@@ -133,9 +134,9 @@ System::get_lines ()
     progress_indication (_f ("Element count %d.",  count + element_count ()));
 
   int line_count = broken_intos_.size ();
-  SCM lines = scm_c_make_vector (line_count, SCM_UNDEFINED);
+  SCM lines = scm_c_make_vector (line_count, SCM_EOL);
   
-   for (int i = 0; i < line_count; i++)
+  for (int i = 0; i < line_count; i++)
     {
       if (verbose_global_b)
        progress_indication ("[");
@@ -147,7 +148,7 @@ System::get_lines ()
       if (verbose_global_b)
        progress_indication (to_string (i) + "]");
     }
-   return lines;
+  return lines;
 }
 
 /* Find the loose columns in POSNS, and drape them around the columns
@@ -269,7 +270,6 @@ System::pre_processing ()
 
   if (verbose_global_b)
     progress_indication (_f ("Grob count %d", element_count ()));
-
   
   for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s))
     unsmob_grob (ly_car (s))->handle_prebroken_dependencies ();
@@ -278,11 +278,13 @@ System::pre_processing ()
   
   for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s))
     {
-      Grobsc = unsmob_grob (ly_car (s));
+      Grob *sc = unsmob_grob (ly_car (s));
       sc->calculate_dependencies (PRECALCED, PRECALCING, ly_symbol2scm ("before-line-breaking-callback"));
     }
   
-  progress_indication ("\n" + _ ("Calculating line breaks...") + " ");
+  progress_indication ("\n");
+  progress_indication (_ ("Calculating line breaks..."));
+  progress_indication (" ");
   for (SCM s = get_property ("all-elements"); ly_c_pair_p (s); s = ly_cdr (s))
     {
       Grob *e = unsmob_grob (ly_car (s));
@@ -307,7 +309,7 @@ System::post_processing ()
     programming_error ("System with zero extent.");
   else
     translate_axis (-iv[MAX], Y_AXIS);
-
+  
   /* Generate all stencils to trigger font loads.
      This might seem inefficient, but Stencils are cached per grob
      anyway. */
@@ -327,22 +329,30 @@ System::get_line ()
 {  
   static int const LAYER_COUNT = 3;
 
-  SCM stencils = SCM_EOL;
-  if (Stencil *me = get_stencil ())
-    stencils = scm_cons (me->smobbed_copy (), stencils);
+  SCM exprs = SCM_EOL;
+  SCM *tail = &exprs;
 
   /* Output stencils in three layers: 0, 1, 2.  Default layer: 1.
 
      Start with layer 3, since scm_cons prepends to list.  */
   SCM all = get_property ("all-elements");
-
-  Real penalty = 0;
+  Interval staff_refpoints;
+  staff_refpoints.set_empty();
+  
   for (int i = LAYER_COUNT; i--;)
     for (SCM s = all; ly_c_pair_p (s); s = ly_cdr (s))
       {
        Grob *g = unsmob_grob (ly_car (s));
        Stencil *stil = g->get_stencil ();
 
+       if (i == 0
+           && Axis_group_interface::has_interface (g)
+           && !Align_interface::has_interface (g)
+           && dynamic_cast<Spanner*> (g))
+         {
+           staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS));
+         }
+  
        /* Skip empty stencils and grobs that are not in this layer.  */
        if (!stil
            || robust_scm2int (g->get_property ("layer"), 1) != i)
@@ -357,28 +367,28 @@ System::get_line ()
 
        /* Must copy the stencil, for we cannot change the stencil
           cached in G.  */
-       SCM my_stencil = stil->smobbed_copy ();
-       unsmob_stencil (my_stencil)->translate (o + extra);
-       stencils = scm_cons (my_stencil, stencils);
 
-       if (g->original_)
-         {
-           if (Item *it = dynamic_cast <Item*> (g))
-             {
-               Grob *col = it->get_column ();
-               SCM s = col->get_property ("page-penalty");
-               // FIXME; page breaking is not discrete at +-10000
-               if (ly_c_number_p (s)) // && fabs (ly_scm2double (s)) < 10000)
-                 penalty += ly_scm2double (s);
-             }
-         }
+       Stencil st = *stil;
+       st.translate (o + extra);
+       *tail = scm_cons (st.expr (), SCM_EOL);
+       tail = SCM_CDRLOC(*tail);
       }
 
+  if (Stencil *me = get_stencil ())
+    exprs = scm_cons (me->expr (), exprs);
+
   Interval x (extent (this, X_AXIS));
   Interval y (extent (this, Y_AXIS));
-  Paper_line *pl = new Paper_line (Offset (x.length (), y.length ()),
-                                  stencils, (bool) penalty); // FIXME.
-
+  Stencil sys_stencil (Box (x,y),
+                      scm_cons (ly_symbol2scm ("combine-stencil"),
+                                exprs));
+  
+  Paper_system *pl = new Paper_system (sys_stencil, false);
+  pl->staff_refpoints_ = staff_refpoints;
+  Item * break_point =this->get_bound(LEFT);
+  pl->penalty_ =
+    robust_scm2double (break_point->get_property ("page-penalty"), 0.0);
+  
   return scm_gc_unprotect_object (pl->self_scm ());
 }