]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dot-column.cc
release: 1.3.72
[lilypond.git] / lily / dot-column.cc
index 61d1c771f248dc675c01dd022e75de28c8195ffe..5557790b33915819b77c26dc6b0bfbf23129514c 100644 (file)
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "directional-element-interface.hh"
+#include "side-position-interface.hh"
+#include "axis-group-interface.hh"
 
-void
-Dot_column::add_dots (Dots *d)
-{
-  Group_interface gi (this, "dots");
-  gi.add_element (d);
 
-  add_dependency (d);
-  add_element (d);
-}
 
 void
-Dot_column::add_head (Rhythmic_head *r)
+Dot_column::add_head (Score_element * me, Score_element *rh)
 {
-  if (!r->dots_l ())
-    return ;
+  Score_element * d = unsmob_element (rh->get_elt_property ("dot"));
+  if (d)
+    {
+      Side_position::add_support (me,rh);
 
-  add_support (r);
-  add_dots (r->dots_l ());
+      Pointer_group_interface gi (me, "dots");
+      gi.add_element (d);
+      
+      d->add_offset_callback (force_shift_callback , Y_AXIS);
+      Axis_group_interface::add_element (me, d);
+    }
 }
 
 
-int
-Dot_column::compare (Dots * const &d1, Dots * 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 ()
+void
+Dot_column::set_interface (Score_element* me)
 {
-  Group_interface gi (this, "dots");
-  gi.set_interface ();
+  me->set_elt_property  ("dots", SCM_EOL);
+  Directional_element_interface (me).set (RIGHT);
   
-  directional_element (this).set (RIGHT);
-  set_axes(X_AXIS,X_AXIS);
+  Axis_group_interface::set_interface (me);
+  Axis_group_interface::set_axes (me, X_AXIS,X_AXIS);
 }
 
 /*
@@ -69,14 +61,32 @@ Dot_column::Dot_column ()
 
    Should be smarter.
  */
-void
-Dot_column::do_post_processing ()
+
+
+Real
+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_property ("dots");
+  do_shifts (dots);
+  return 0.0;
+}
+
+SCM
+Dot_column::do_shifts (SCM l)
 {
-  Link_array<Dots> dots = Group_interface__extract_elements (this, (Dots*)0 , "dots"); 
-  dots.sort (Dot_column::compare);
+  Link_array<Score_element> dots;
+  while (gh_pair_p (l))
+    {
+      dots.push (unsmob_element (gh_car (l)));
+      l = gh_cdr (l);
+    }
+  
+  dots.sort (compare_position);
   
   if (dots.size () < 2)
-    return;
+    return SCM_UNSPECIFIED;
   Slice s;
   s.set_empty ();
 
@@ -84,7 +94,7 @@ Dot_column::do_post_processing ()
   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)
@@ -96,7 +106,7 @@ Dot_column::do_post_processing ()
     }
 
   if (!conflicts)
-    return;
+    return SCM_UNSPECIFIED;
   
   int  middle = s.center ();
   /*
@@ -106,8 +116,17 @@ Dot_column::do_post_processing ()
   if (!(pos % 2))
     pos ++;                    // center () rounds down.
 
-  for (int i=0; i  <dots.size (); pos += 2, i++)
+  for (int i=0; i dots.size (); pos += 2, i++)
     {
-      staff_symbol_referencer (dots[i]).set_position(pos);
+      Score_element * d = dots[i];
+      Staff_symbol_referencer::set_position (d,pos);
     }
+
+  return SCM_UNSPECIFIED;
+}
+
+bool
+Dot_column::has_interface (Score_element*m)
+{
+  return m && m->has_interface (ly_symbol2scm ("dot-column-interface"));
 }