]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spanner.cc
''
[lilypond.git] / lily / spanner.cc
index 0fba92f847c3f3d753d63f1e7cfa8a46bba0934d..e45c74f7e2bf4c45b41dd935f00ccfa327f2fce4 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include <math.h>
 #include <libc-extension.hh>
@@ -16,8 +16,7 @@
 #include "molecule.hh"
 #include "paper-outputter.hh"
 #include "paper-column.hh"
-#include "line-of-score.hh"
-#include "break-align-item.hh"
+#include "system.hh"
 #include "group-interface.hh"
 
 void
@@ -36,7 +35,7 @@ Spanner::do_break_processing ()
    */
   for (int a = X_AXIS; a < NO_AXES; a ++)
     {
-      if (Spanner* parent = dynamic_cast<Spanner*> (parent_l ((Axis)a)))
+      if (Spanner* parent = dynamic_cast<Spanner*> (get_parent ((Axis)a)))
        {
          if (!parent->spanned_rank_iv ().contains_b (this->spanned_rank_iv ()))
            {
@@ -173,9 +172,9 @@ Spanner::set_bound (Direction d, Grob*s)
   spanned_drul_[d] =i;
 
   /**
-     We check for Line_of_score to prevent the column -> line_of_score
+     We check for System to prevent the column -> line_of_score
      -> column -> line_of_score -> etc situation */
-  if (d== LEFT && !dynamic_cast<Line_of_score*> (this))
+  if (d== LEFT && !dynamic_cast<System*> (this))
     {
       set_parent (i, X_AXIS);
     }
@@ -190,7 +189,7 @@ Spanner::set_bound (Direction d, Grob*s)
   */
   if (dynamic_cast<Paper_column*> (i))
     {
-      Pointer_group_interface::add_element (i, "bounded-by-me",this);  
+      Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this);  
     }
 }
 
@@ -199,6 +198,9 @@ Spanner::Spanner (SCM s)
 {
   spanned_drul_[LEFT]=0;
   spanned_drul_[RIGHT]=0;
+  Group_interface::add_thing (this, ly_symbol2scm ("interfaces"), ly_symbol2scm ("spanner-interface"));
+                    
+  
 }
 
 Spanner::Spanner (Spanner const &s)
@@ -219,7 +221,7 @@ Spanner::spanner_length () const
   return r-l;
 }
 
-Line_of_score *
+System *
 Spanner::line_l () const
 {
   if (!spanned_drul_[LEFT] || !spanned_drul_[RIGHT])
@@ -231,7 +233,7 @@ Spanner::line_l () const
 
 
 Grob*
-Spanner::find_broken_piece (Line_of_score*l) const
+Spanner::find_broken_piece (System*l) const
 {
   int idx = binsearch_link_array (broken_into_l_arr_, (Spanner*)l, Spanner::compare);
   
@@ -287,7 +289,7 @@ Spanner::do_derived_mark ()
 {
   /*
     We'd be fucked if this is called before spanned_drul_[] is inited.  */
-  if (status_i_ == ORPHAN)
+  if (status_c_ == ORPHAN)
     return SCM_EOL;
   
   Direction d = LEFT;
@@ -302,8 +304,15 @@ Spanner::do_derived_mark ()
   return SCM_EOL;
 }
 
+
+/*
+  Set left or right bound to IT.
+
+  Warning: caller should ensure that subsequent calls put in ITems
+  that are left-to-right ordered.
+ */
 void
-add_bound_item (Spanner* sp, Item*it)
+add_bound_item (Spanner* sp, Grob*it)
 {
   if (!sp->get_bound (LEFT))
     sp->set_bound (LEFT, it);
@@ -320,8 +329,8 @@ extend_spanner_over_item (Item *it, SCM extremal_pair)
   if (!it)
     return;
   Item * col = it->column_l ();
-  Item * i1 = dynamic_cast<Item*> (unsmob_grob (gh_car (extremal_pair)));
-  Item * i2 = dynamic_cast<Item*> (unsmob_grob (gh_cdr (extremal_pair)));
+  Item * i1 = dynamic_cast<Item*> (unsmob_grob (ly_car (extremal_pair)));
+  Item * i2 = dynamic_cast<Item*> (unsmob_grob (ly_cdr (extremal_pair)));
   int r = Paper_column::rank_i (col);
   if (!i1 || r < Paper_column::rank_i (i1->column_l ()))
     {
@@ -341,8 +350,8 @@ extend_spanner_over_elements (SCM value, SCM extremal_pair)
 {
   if (gh_pair_p (value))
     {
-      extend_spanner_over_elements (gh_car (value), extremal_pair);
-      extend_spanner_over_elements (gh_cdr (value), extremal_pair);
+      extend_spanner_over_elements (ly_car (value), extremal_pair);
+      extend_spanner_over_elements (ly_cdr (value), extremal_pair);
     }
   else if (unsmob_grob (value))
     {
@@ -362,7 +371,7 @@ extend_spanner_over_elements (SCM value, SCM extremal_pair)
   points to.
 
   TODO: maybe be more specific. Most probably fucks up if someone sets
-  a pointer to the staffsymbol in S
+  a pointer to the staff symbol in S
 */
 void
 extend_spanner_over_elements (Grob*s)
@@ -375,8 +384,8 @@ extend_spanner_over_elements (Grob*s)
   SCM pair = gh_cons (s1,s2);
   extend_spanner_over_elements (sp->mutable_property_alist_, pair);
 
-  Grob *p1 =  unsmob_grob (gh_car (pair));
-  Grob* p2 = unsmob_grob (gh_cdr (pair));
+  Grob *p1 =  unsmob_grob (ly_car (pair));
+  Grob* p2 = unsmob_grob (ly_cdr (pair));
   sp->set_bound (LEFT,p1);
   sp->set_bound (RIGHT, p2);
 }
@@ -399,3 +408,15 @@ Spanner::set_spacing_rods (SCM smob)
   r.add_to_cols ();
   return SCM_UNSPECIFIED;
 }
+
+
+Spanner*
+unsmob_spanner (SCM s )
+{
+  return dynamic_cast<Spanner*> (unsmob_grob (s));
+}
+
+ADD_INTERFACE(Spanner,
+             "spanner-interface",
+             "",
+             "minimum-length");