]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dot-column.cc
release: 1.3.72
[lilypond.git] / lily / dot-column.cc
index a725998bcfc69462404eeaef29d9addd9a95bf88..5557790b33915819b77c26dc6b0bfbf23129514c 100644 (file)
 
 
 void
-Dot_column::add_head (Rhythmic_head *r)
+Dot_column::add_head (Score_element * me, Score_element *rh)
 {
-  if (!r->dots_l ())
-    return ;
-
-  Side_position_interface (this).add_support (r);
-  Item * d = r->dots_l ();
+  Score_element * d = unsmob_element (rh->get_elt_property ("dot"));
   if (d)
     {
-      Pointer_group_interface gi (this, "dots");
+      Side_position::add_support (me,rh);
+
+      Pointer_group_interface gi (me, "dots");
       gi.add_element (d);
       
       d->add_offset_callback (force_shift_callback , Y_AXIS);
-      Axis_group_interface (this).add_element (d);
+      Axis_group_interface::add_element (me, d);
     }
 }
 
 
-int
-Dot_column::compare (Score_element * const &d1, Score_element * const &d2)
-{
-  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)
+void
+Dot_column::set_interface (Score_element* me)
 {
-  this->set_elt_pointer  ("dots", SCM_EOL);
-  Directional_element_interface (this).set (RIGHT);
+  me->set_elt_property  ("dots", SCM_EOL);
+  Directional_element_interface (me).set (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);
 }
 
 /*
@@ -74,11 +64,11 @@ Dot_column::Dot_column (SCM s)
 
 
 Real
-Dot_column::force_shift_callback (Score_element const * dot, Axis a)
+Dot_column::force_shift_callback (Score_element * dot, Axis a)
 {
   assert (a == Y_AXIS);
   Score_element * me = dot->parent_l (X_AXIS);
-  SCM dots = me->get_elt_pointer ("dots");
+  SCM dots = me->get_elt_property ("dots");
   do_shifts (dots);
   return 0.0;
 }
@@ -93,10 +83,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 +94,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 +106,7 @@ Dot_column::do_shifts (SCM l)
     }
 
   if (!conflicts)
-    return SCM_UNDEFINED;
+    return SCM_UNSPECIFIED;
   
   int  middle = s.center ();
   /*
@@ -129,8 +119,14 @@ 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"));
 }