]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/system.cc
* configure.in: Test for and accept lmodern if EC fonts not found.
[lilypond.git] / lily / system.cc
index b72720756833186f1b452087cc43bd92efd3bb4c..041a133a3fb7a22ca29f8a0b6975ae1648ad5bde 100644 (file)
@@ -6,32 +6,47 @@
   (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include <math.h>
+#include "system.hh"
+
+#include <cmath>
 
 #include "align-interface.hh"
 #include "axis-group-interface.hh"
 #include "warn.hh"
-#include "system.hh"
 #include "main.hh"
 #include "paper-column.hh"
 #include "output-def.hh"
 #include "paper-outputter.hh"
 #include "paper-score.hh"
-#include "string.hh"
 #include "warn.hh"
-#include "stencil.hh"
 #include "all-font-metrics.hh"
 #include "spacing-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "paper-book.hh"
 #include "paper-system.hh"
+#include "tweak-registration.hh"
 
-System::System (SCM s)
-  : Spanner (s)
+
+System::System (System const &src, int count)
+  : Spanner (src, count)
 {
   rank_ = 0;
 }
 
+System::System (SCM s, Object_key const*key)
+  : Spanner (s, key)
+{
+  rank_ = 0;
+}
+
+
+Grob * 
+System::clone (int count) const
+{
+  return new System (*this, count);
+}
+
+
 int
 System::element_count () const
 {
@@ -230,7 +245,7 @@ System::break_into_pieces (Array<Column_x_positions> const &breaking)
 {
   for (int i = 0; i < breaking.size (); i++)
     {
-      System *system = dynamic_cast <System*> (clone ());
+      System *system = dynamic_cast <System*> (clone (i));
       system->rank_ = i;
 
       Link_array<Grob> c (breaking[i].cols_);
@@ -262,6 +277,21 @@ System::add_column (Paper_column*p)
   Axis_group_interface::add_element (me, p);
 }
 
+void
+apply_tweaks (Grob *g, bool broken)
+{
+  if (bool (g->original_) == broken)
+    {
+      SCM tweaks = global_registry_->get_tweaks (g);
+      for (SCM s = tweaks; scm_is_pair (s); s = scm_cdr (s))
+       {
+         SCM proc = scm_caar (s);
+         SCM rest = scm_cdar (s);
+         scm_apply_1 (proc, g->self_scm(), rest);
+       }
+    }
+}
+
 void
 System::pre_processing ()
 {
@@ -275,7 +305,11 @@ System::pre_processing ()
     unsmob_grob (scm_car (s))->handle_prebroken_dependencies ();
   
   fixup_refpoints (get_property ("all-elements"));
+
   
+  for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
+    apply_tweaks (unsmob_grob (scm_car (s)), false);
+
   for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
     {
       Grob *sc = unsmob_grob (scm_car (s));
@@ -300,6 +334,9 @@ System::post_processing ()
   for (SCM s = get_property ("all-elements"); scm_is_pair (s); s = scm_cdr (s))
     {
       Grob *g = unsmob_grob (scm_car (s));
+      
+      apply_tweaks (g, true);
+
       g->calculate_dependencies (POSTCALCED, POSTCALCING,
           ly_symbol2scm ("after-line-breaking-callback"));
     }
@@ -336,8 +373,6 @@ System::get_line ()
 
      Start with layer 3, since scm_cons prepends to list.  */
   SCM all = get_property ("all-elements");
-  Interval staff_refpoints;
-  staff_refpoints.set_empty();
   
   for (int i = LAYER_COUNT; i--;)
     for (SCM s = all; scm_is_pair (s); s = scm_cdr (s))
@@ -345,20 +380,6 @@ System::get_line ()
        Grob *g = unsmob_grob (scm_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)
-           /*
-             UGH.
-            */
-           && !g->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
-           && !g->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))
-           )
-         {
-           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)
@@ -388,7 +409,17 @@ System::get_line ()
   Stencil sys_stencil (Box (x,y),
                       scm_cons (ly_symbol2scm ("combine-stencil"),
                                 exprs));
+
+  Interval staff_refpoints;
+  staff_refpoints.set_empty();
+  for (SCM s = get_property ("spaceable-staves");
+       scm_is_pair (s); s = scm_cdr (s))
+      {
+       Grob *g = unsmob_grob (scm_car (s));
+       staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS));
+      }
   
   Paper_system *pl = new Paper_system (sys_stencil, false);
   pl->staff_refpoints_ = staff_refpoints;
   Item * break_point =this->get_bound(LEFT);
@@ -453,4 +484,4 @@ System::columns () const
 ADD_INTERFACE (System,"system-interface",
               "This is the toplevel object: each object in a score "
               "ultimately has a System object as its X and Y parent. ",
-              "all-elements columns")
+              "all-elements spaceable-staves columns")