]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dot-column.cc
add 2007 to (c) year.
[lilypond.git] / lily / dot-column.cc
index f3e2af55f9104e963971705622a02aa1d5c632be..173a9ad981f3add800a0295f074f56a343b9bfc4 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "dot-column.hh"
 using namespace std;
 
 #include "dots.hh"
+#include "dot-column.hh"
 #include "rhythmic-head.hh"
 #include "staff-symbol-referencer.hh"
 #include "directional-element-interface.hh"
 #include "side-position-interface.hh"
 #include "axis-group-interface.hh"
 #include "stem.hh"
+#include "grob.hh"
 #include "pointer-group-interface.hh"
 
 /*
@@ -31,21 +33,27 @@ SCM
 Dot_column::side_position (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
-  Grob *stem = unsmob_grob (me->get_object ("stem"));
-  if (stem
-      && !Stem::get_beam (stem)
-      && Stem::duration_log (stem) > 2
-      && !Stem::is_invisible (stem))
+  extract_grob_set (me, "dots", dots);
+  
+  for (vsize i = 0; i  < dots.size (); i++)
     {
-      /*
-       trigger stem end & direction calculation.
-
-       This will add the stem to the support if a flag collision happens.
-      */
-      stem->get_property ("stem-end-position");
+      Grob *head = dots[i]->get_parent (Y_AXIS);
+      Grob *stem = head ? unsmob_grob (head->get_object ("stem")) : 0;
+      if (stem
+         && !Stem::get_beam (stem)
+         && Stem::duration_log (stem) > 2
+         && !Stem::is_invisible (stem))
+       {
+         /*
+           trigger stem end & direction calculation.
+           
+           This will add the stem to the support if a flag collision happens.
+         */
+         stem->get_property ("stem-end-position");
+       }
     }
-  
-  return Side_position_interface::x_aligned_side (smob);
+
+  return Side_position_interface::x_aligned_side (smob, SCM_EOL);
 }
 
 struct Dot_position
@@ -60,6 +68,7 @@ struct Dot_position
     dot_ = 0;
     pos_ = 0;
     dir_ = CENTER;
+    extremal_head_ = false;
   }
 };
 
@@ -204,7 +213,7 @@ SCM
 Dot_column::calc_positioning_done (SCM smob)
 {
   Grob *me = unsmob_grob (smob);  
-  Link_array__Grob_ dots
+  vector<Grob*> dots
     = extract_grob_array (me, "dots");
 
   { /*
@@ -227,7 +236,7 @@ Dot_column::calc_positioning_done (SCM smob)
       }
   }
 
-  vector_sort (dots, &compare_position);
+  vector_sort (dots, position_less);
   for (vsize i = dots.size (); i--;)
     if (!dots[i]->is_live ())
       dots.erase (dots.begin () + i);
@@ -247,6 +256,10 @@ Dot_column::calc_positioning_done (SCM smob)
        }
 
       int p = Staff_symbol_referencer::get_rounded_position (dp.dot_);
+
+      /* icky, since this should go via a Staff_symbol_referencer
+        offset callback but adding a dot overwrites Y-offset. */
+      p += (int) robust_scm2double (dp.dot_->get_property ("staff-position"), 0.0);
       dp.pos_ = p;
 
       if (dp.extremal_head_)
@@ -284,13 +297,13 @@ Dot_column::add_head (Grob *me, Grob *rh)
 }
 
 ADD_INTERFACE (Dot_column,
-              "dot-column-interface",
               
               "Groups dot objects so they form a column, and position dots so they do not "
               "clash with staff lines ",
 
               /* properties */
+              "dots "
               "positioning-done "
               "direction "
-              "stem");
+              );