]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/spanner.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / spanner.cc
index 590c4d9473678009630ea353dc503f99632daa22..bb6f743a24d5034eab9a0e6cb76805b11308a071 100644 (file)
@@ -3,12 +3,11 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "spanner.hh"
 
-#include <math.h>
 
 #include "pointer-group-interface.hh"
 #include "libc-extension.hh"
@@ -46,8 +45,8 @@ Spanner::do_break_processing ()
          if (!parent->spanned_rank_iv ().superset (this->spanned_rank_iv ()))
            {
              programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner `%s'.",
-                                           name ().to_str0 (),
-                                           parent->name ().to_str0 ()));
+                                           name ().c_str (),
+                                           parent->name ().c_str ()));
            }
        }
     }
@@ -74,19 +73,20 @@ Spanner::do_break_processing ()
 
              assert (span->get_system ());
              span->get_system ()->typeset_grob (span);
-             broken_intos_.push (span);
+             broken_intos_.push_back (span);
            }
        }
       while ((flip (&d)) != LEFT);
     }
   else
     {
-      Link_array<Item> break_points = pscore_->root_system ()->broken_col_range (left, right);
+      System *root  = get_root_system (this);
+      vector<Item*> break_points = root->broken_col_range (left, right);
 
-      break_points.insert (left, 0);
-      break_points.push (right);
+      break_points.insert (break_points.begin () + 0, left);
+      break_points.push_back (right);
 
-      for (int i = 1; i < break_points.size (); i++)
+      for (vsize i = 1; i < break_points.size (); i++)
        {
          Drul_array<Item *> bounds;
          bounds[LEFT] = break_points[i - 1];
@@ -120,16 +120,16 @@ Spanner::do_break_processing ()
          else
            {
              bounds[LEFT]->get_system ()->typeset_grob (span);
-             broken_intos_.push (span);
+             broken_intos_.push_back (span);
            }
        }
     }
-  broken_intos_.sort (Spanner::compare);
-  for (int i = broken_intos_.size ();i--;)
+  vector_sort (broken_intos_, Spanner::compare);
+  for (vsize i = broken_intos_.size (); i--;)
     broken_intos_[i]->break_index_ = i;
 }
 
-int
+vsize
 Spanner::get_break_index () const
 {
   return break_index_;
@@ -185,9 +185,7 @@ Spanner::set_bound (Direction d, Grob *s)
      We check for System to prevent the column -> line_of_score
      -> column -> line_of_score -> etc situation */
   if (d == LEFT && !dynamic_cast<System *> (this))
-    {
-      set_parent (i, X_AXIS);
-    }
+    set_parent (i, X_AXIS);
 
   /*
     Signal that this column needs to be kept alive. They need to be
@@ -198,9 +196,7 @@ Spanner::set_bound (Direction d, Grob *s)
 
   */
   if (dynamic_cast<Paper_column *> (i))
-    {
-      Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this);
-    }
+    Pointer_group_interface::add_grob (i, ly_symbol2scm ("bounded-by-me"), this);
 }
 
 Spanner::Spanner (SCM s, Object_key const *key)
@@ -242,18 +238,16 @@ Spanner::get_system () const
 Grob *
 Spanner::find_broken_piece (System *l) const
 {
-  int idx = binsearch_links (broken_intos_, (Spanner *)l, Spanner::compare);
-
-  if (idx < 0)
-    return 0;
-  else
+  vsize idx = binary_search (broken_intos_, (Spanner *)l, Spanner::compare);
+  if (idx != VPOS)
     return broken_intos_ [idx];
+  return 0;
 }
 
 int
 Spanner::compare (Spanner *const &p1, Spanner *const &p2)
 {
-  return p1->get_system ()->get_rank() - p2->get_system ()->get_rank();
+  return p1->get_system ()->get_rank () - p2->get_system ()->get_rank ();
 }
 
 bool
@@ -298,7 +292,7 @@ Spanner::derived_mark () const
   while (flip (&d) != LEFT)
     ;
 
-  for (int i = broken_intos_.size (); i--;)
+  for (vsize i = broken_intos_.size (); i--;)
     scm_gc_mark (broken_intos_[i]->self_scm ());
 }
 
@@ -335,13 +329,13 @@ Spanner::set_spacing_rods (SCM smob)
 }
 
 /*
-  Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I].
+  Return I such that SP == SP->ORIGINAL ()->BROKEN_INTOS_[I].
 */
 int
 broken_spanner_index (Spanner *sp)
 {
-  Spanner *parent = dynamic_cast<Spanner *> (sp->original_);
-  return parent->broken_intos_.find_index (sp);
+  Spanner *parent = dynamic_cast<Spanner *> (sp->original ());
+  return find (parent->broken_intos_, sp) - parent->broken_intos_.begin ();
 }
 
 Spanner *