]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dot-column.cc
release: 1.3.96
[lilypond.git] / lily / dot-column.cc
index a725998bcfc69462404eeaef29d9addd9a95bf88..a9838ae13b25609a68a41bbdde03ab62c0443896 100644 (file)
 
 
 
-void
-Dot_column::add_head (Rhythmic_head *r)
-{
-  if (!r->dots_l ())
-    return ;
-
-  Side_position_interface (this).add_support (r);
-  Item * d = r->dots_l ();
-  if (d)
-    {
-      Pointer_group_interface gi (this, "dots");
-      gi.add_element (d);
-      
-      d->add_offset_callback (force_shift_callback , Y_AXIS);
-      Axis_group_interface (this).add_element (d);
-    }
-}
 
 
-int
-Dot_column::compare (Score_element * const &d1, Score_element * const &d2)
+void
+Dot_column::set_interface (Score_element* me)
 {
-  Staff_symbol_referencer_interface s1(d1);
-  Staff_symbol_referencer_interface s2(d2);  
-  
-  return int (s1.position_f () - s2.position_f ());
-}
 
-
-Dot_column::Dot_column (SCM s)
-  : Item (s)
-{
-  this->set_elt_pointer  ("dots", SCM_EOL);
-  Directional_element_interface (this).set (RIGHT);
+  Directional_element_interface::set (me, RIGHT);
   
-  Axis_group_interface (this).set_interface ();
-  Axis_group_interface (this).set_axes(X_AXIS,X_AXIS);
+  Axis_group_interface::set_interface (me);
+  Axis_group_interface::set_axes (me, X_AXIS,X_AXIS);
 }
 
 /*
@@ -73,14 +46,17 @@ Dot_column::Dot_column (SCM s)
  */
 
 
-Real
-Dot_column::force_shift_callback (Score_element const * dot, Axis a)
+MAKE_SCHEME_CALLBACK(Dot_column,force_shift_callback,2);
+SCM
+Dot_column::force_shift_callback (SCM element_smob, SCM axis)
 {
+  Score_element *me = unsmob_element (element_smob);
+  Axis a = (Axis) gh_scm2int (axis);
   assert (a == Y_AXIS);
 Score_element * me = dot->parent_l (X_AXIS);
-  SCM dots = me->get_elt_pointer ("dots");
me = me->parent_l (X_AXIS);
+  SCM dots = me->get_elt_property ("dots");
   do_shifts (dots);
-  return 0.0;
+  return gh_double2scm (0.0);
 }
 
 SCM
@@ -93,10 +69,10 @@ Dot_column::do_shifts (SCM l)
       l = gh_cdr (l);
     }
   
-  dots.sort (Dot_column::compare);
+  dots.sort (compare_position);
   
   if (dots.size () < 2)
-    return SCM_UNDEFINED;
+    return SCM_UNSPECIFIED;
   Slice s;
   s.set_empty ();
 
@@ -104,7 +80,7 @@ Dot_column::do_shifts (SCM l)
   int conflicts = 0;
   for (int i=0; i < dots.size (); i++)
     {
-      Real p = Staff_symbol_referencer_interface (dots[i]).position_f ();
+      Real p = Staff_symbol_referencer::position_f (dots[i]);
       for (int j=0; j < taken_posns.size (); j++)
        {
          if (taken_posns[j] == (int) p)
@@ -116,7 +92,7 @@ Dot_column::do_shifts (SCM l)
     }
 
   if (!conflicts)
-    return SCM_UNDEFINED;
+    return SCM_UNSPECIFIED;
   
   int  middle = s.center ();
   /*
@@ -129,8 +105,30 @@ Dot_column::do_shifts (SCM l)
   for (int i=0; i < dots.size (); pos += 2, i++)
     {
       Score_element * d = dots[i];
-      Staff_symbol_referencer_interface (d).set_position(pos);
+      Staff_symbol_referencer::set_position (d,pos);
     }
 
-  return SCM_UNDEFINED;
+  return SCM_UNSPECIFIED;
 }
+
+bool
+Dot_column::has_interface (Score_element*m)
+{
+  return m && m->has_interface (ly_symbol2scm ("dot-column-interface"));
+}
+
+
+void
+Dot_column::add_head (Score_element * me, Score_element *rh)
+{
+  Score_element * d = unsmob_element (rh->get_elt_property ("dot"));
+  if (d)
+    {
+      Side_position::add_support (me,rh);
+
+      Pointer_group_interface ::add_element (me, "dots",d);
+      d->add_offset_callback (Dot_column::force_shift_callback_proc , Y_AXIS);
+      Axis_group_interface::add_element (me, d);
+    }
+}
+