]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/slur.cc
release: 1.3.56
[lilypond.git] / lily / slur.cc
index 774a5dc13232b233c6ed8c206b533f8783e2debb..118bae506c2f3998a1457942e1906a752a89fe0c 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996,  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
@@ -29,8 +29,6 @@
 #include "cross-staff.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
-#include "lily-guile.icc"
-
 
 class Slur_bezier_bow : public Bezier_bow
 {
@@ -215,33 +213,25 @@ Slur_bezier_bow::fit_factor () const
   Slur
 */
 
-Slur::Slur ()
+Slur::Slur (SCM s)
+  : Spanner (s)
 {
   // URG
   dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = 0.0;
   dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0;
 
-  set_elt_property ("note-columns", SCM_EOL);
+  set_elt_pointer ("note-columns", SCM_EOL);
   set_elt_property ("control-points", SCM_EOL);
-
-#if 0
-  /*
-    I still don't understand the merits of this Group_interface.
-   */
-  Group_interface c (this, "control-points");
-  c.set_interface ();
-#endif
 }
 
 void
 Slur::add_column (Note_column*n)
 {
-  if (!gh_pair_p (n->get_elt_property ("note-heads")))
+  if (!gh_pair_p (n->get_elt_pointer ("note-heads")))
     warning (_ ("Putting slur over rest.  Ignoring."));
   else
     {
-      Group_interface gi (this, "note-columns");
-      gi.add_element (n);
+      Pointer_group_interface (this, "note-columns").add_element (n);
       add_dependency (n);
     }
 }
@@ -280,7 +270,7 @@ Direction
 Slur::get_default_dir () const
 {
   Link_array<Note_column> encompass_arr =
-    Group_interface__extract_elements (this, (Note_column*)0, "note-columns");
+    Pointer_group_interface__extract_elements (this, (Note_column*)0, "note-columns");
   
   Direction d = DOWN;
   for (int i=0; i < encompass_arr.size (); i ++) 
@@ -298,7 +288,7 @@ void
 Slur::do_add_processing ()
 {
   Link_array<Note_column> encompass_arr =
-    Group_interface__extract_elements (this, (Note_column*)0, "note-columns");
+    Pointer_group_interface__extract_elements (this, (Note_column*)0, "note-columns");
 
   if (encompass_arr.size ())
     {
@@ -320,12 +310,12 @@ Slur::encompass_offset (Note_column const* col) const
   if (!stem_l)
     {
       warning (_ ("Slur over rest?"));
-     o[X_AXIS] = col->hpos_f ();
+     o[X_AXIS] = col->relative_coordinate (0, X_AXIS);
       o[Y_AXIS] = col->extent (Y_AXIS)[dir];
       return o;  
     }
   Direction stem_dir = directional_element (stem_l).get ();
-  o[X_AXIS] = stem_l->hpos_f ();
+  o[X_AXIS] = stem_l->relative_coordinate (0, X_AXIS);
 
   /*
     Simply set x to middle of notehead
@@ -352,7 +342,7 @@ Slur::encompass_offset (Note_column const* col) const
 }
 
 void
-Slur::do_post_processing ()
+Slur::after_line_breaking ()
 {
   set_extremities ();
   set_control_points ();
@@ -366,13 +356,11 @@ void
 Slur::set_extremities ()
 {
   Link_array<Note_column> encompass_arr =
-    Group_interface__extract_elements (this, (Note_column*)0, "note-columns");
+    Pointer_group_interface__extract_elements (this, (Note_column*)0, "note-columns");
 
   if (!encompass_arr.size ())
     {
-      set_elt_property ("transparent", SCM_BOOL_T);
-      set_empty (X_AXIS);
-      set_empty (Y_AXIS);
+      suicide();
       return;
     }
 
@@ -444,7 +432,7 @@ Slur::set_extremities ()
          */
          else
            {
-             dx_f_drul_[d] = stem_l->hpos_f ()
+             dx_f_drul_[d] = stem_l->relative_coordinate (0, X_AXIS)
                - get_bound (d)->relative_coordinate (0, X_AXIS);
              /*
                side attached to beamed stem
@@ -526,7 +514,7 @@ int
 Slur::cross_staff_count ()const
 {
   Link_array<Note_column> encompass_arr =
-    Group_interface__extract_elements (this, (Note_column*)0, "note-columns");
+    Pointer_group_interface__extract_elements (this, (Note_column*)0, "note-columns");
 
   int k=0;
 
@@ -543,9 +531,10 @@ Array<Offset>
 Slur::get_encompass_offset_arr () const
 {
   Link_array<Note_column> encompass_arr =
-    Group_interface__extract_elements (this, (Note_column*)0, "note-columns");
+    Pointer_group_interface__extract_elements (this, (Note_column*)0, "note-columns");
   
   Array<Offset> offset_arr;
+
 #if 0
   /*
     check non-disturbed slur
@@ -603,9 +592,9 @@ Slur::get_rods () const
 {
   Array<Rod> a;
   Rod r;
+  
   r.item_l_drul_[LEFT] = get_bound (LEFT);
   r.item_l_drul_[RIGHT] = get_bound (RIGHT);
-  
   r.distance_f_ = paper_l ()->get_var ("slur_x_minimum");
 
   a.push (r);
@@ -614,6 +603,8 @@ Slur::get_rods () const
 
 
 
+MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Slur);
+
 /*
   Ugh should have dash-length + dash-period
  */
@@ -668,7 +659,12 @@ Slur::set_control_points ()
     }
 
   Bezier b = bb.get_bezier ();
-  SCM controls = array_to_scm (b.control_);
+
+
+  SCM controls = SCM_EOL;
+  for (int i= 4; i--;)
+    controls = gh_cons ( ly_offset2scm (b.control_[i]), controls);
+
   set_elt_property ("control-points", controls);
 }
   
@@ -677,9 +673,20 @@ Bezier
 Slur::get_curve () const
 {
   Bezier b;
-  Array<Offset> controls (4);
-  scm_to_array (get_elt_property ("control-points"), &controls);
-  b.control_ = controls;
+  int i = 0;
+
+  if (!directional_element (this).get ())
+    ((Slur*)this)->set_extremities ();
+  
+  if (!gh_pair_p (get_elt_property ("control-points")))
+    ((Slur*)this)->set_control_points ();
+  
+  
+  for (SCM s= get_elt_property ("control-points"); s != SCM_EOL; s = gh_cdr (s))
+    {
+      b.control_[i] = ly_scm2offset (gh_car (s));
+      i++;
+    }
   
   Array<Offset> enc (get_encompass_offset_arr ());
   Direction dir = directional_element (this).get ();