]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dot-column.cc
* lily/include/transposed-music.hh (class Transposed_music): remove.
[lilypond.git] / lily / dot-column.cc
index cd95dfc0396acf5333d661cb764cb98c8af9a47a..8480362f1e8024a7cd337447c4464f2216a4021c 100644 (file)
@@ -3,24 +3,23 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include <set>
+#include "dot-column.hh"
+
+#include <cstdio>
+#include <math.h>
 #include <map>
 
 #include "dots.hh"
-#include "dot-column.hh"
 #include "rhythmic-head.hh"
-#include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "directional-element-interface.hh"
 #include "side-position-interface.hh"
 #include "axis-group-interface.hh"
 #include "stem.hh"
 
-using std::set;
-
 /*
   TODO: let Dot_column communicate with stem via Note_column.
  */
@@ -30,32 +29,32 @@ SCM
 Dot_column::force_shift_callback (SCM element_smob, SCM axis)
 {
   Grob *me = unsmob_grob (element_smob);
-  Axis a = (Axis) gh_scm2int (axis);
+  Axis a = (Axis) scm_to_int (axis);
   assert (a == Y_AXIS);
   me = me->get_parent (X_AXIS);
 
-  if (!to_boolean (me->get_grob_property ("collision-done")))
+  if (!to_boolean (me->get_property ("positioning-done")))
     {
-      me->set_grob_property ("collision-done", SCM_BOOL_T);
+      me->set_property ("positioning-done", SCM_BOOL_T);
   
       do_shifts (me);
     }
-  return gh_double2scm (0.0);
+  return scm_make_real (0.0);
 }
 
-MAKE_SCHEME_CALLBACK(Dot_column,side_position, 2);
+MAKE_SCHEME_CALLBACK (Dot_column,side_position, 2);
 SCM
 Dot_column::side_position (SCM element_smob, SCM axis)
 {
   Grob *me = unsmob_grob (element_smob);
-  Axis a = (Axis) gh_scm2int (axis);
+  Axis a = (Axis) scm_to_int (axis);
   assert (a == X_AXIS);
 
-  Grob * stem = unsmob_grob (me->get_grob_property ("stem"));
+  Grob * stem = unsmob_grob (me->get_property ("stem"));
   if (stem
       && !Stem::get_beam (stem)
       && Stem::duration_log (stem) > 2
-      && !Stem::invisible_b (stem)
+      && !Stem::is_invisible (stem)
       )
     {
       /*
@@ -81,7 +80,7 @@ struct Dot_position
   Dot_position ()
   {
     dot_ = 0;
-    pos_ =0;
+    pos_ = 0;
     dir_ = CENTER;
   }
 };
@@ -166,7 +165,7 @@ shift_one (Dot_configuration const &cfg,
            {
              if (new_cfg.find (p) == new_cfg.end ())
                {
-                 offset =0;
+                 offset = 0;
                }
              new_cfg[p + offset] = i->second;
            }
@@ -195,7 +194,7 @@ shift_one (Dot_configuration const &cfg,
            {
              if (new_cfg.find (p) == new_cfg.end ())
                {
-                 offset =0;
+                 offset = 0;
                }
 
              new_cfg[p + offset] = i->second;
@@ -233,14 +232,34 @@ Dot_column::do_shifts (Grob*me)
 {
   Link_array<Grob> dots =
     Pointer_group_interface__extract_grobs (me, (Grob*)0, "dots");
+
+  { /*
+      Trigger note collision resolution first, since that may kill off
+      dots when merging.
+     */
+    Grob * c = 0;
+    for (int i = dots.size (); i-- ; )
+      {
+       Grob * n = dots[i]->get_parent (Y_AXIS);
+       if (c)
+         c = n->common_refpoint (c, X_AXIS);
+       else
+         c = n;
+      }
+    for (int i = dots.size (); i-- ; )
+      {
+       Grob * n = dots[i]->get_parent (Y_AXIS);
+       n->relative_coordinate (c ,  X_AXIS);
+      }
+  }
   
   dots.sort (compare_position);
   for (int i = dots.size (); i--;)
-    if (!dots[i]->live ())
+    if (!dots[i]->is_live ())
       dots.del (i);
   
   Dot_configuration cfg;
-  for (int i =0;i < dots.size (); i++)
+  for (int i = 0;i < dots.size (); i++)
     {
       Dot_position dp;
       dp.dot_ = dots[i];
@@ -248,16 +267,16 @@ Dot_column::do_shifts (Grob*me)
       Grob * note = dots[i]->get_parent (Y_AXIS);
       if (note)
        {
-         Grob *stem = unsmob_grob (note->get_grob_property ("stem"));
+         Grob *stem = unsmob_grob (note->get_property ("stem"));
          if (stem)
            dp.extremal_head_ = Stem::first_head (stem) == note;
        }
       
-      int p = int (Staff_symbol_referencer::get_position (dp.dot_));
-      dp.pos_= p;
+      int p = Staff_symbol_referencer::get_rounded_position (dp.dot_);
+      dp.pos_ = p;
 
       if (dp.extremal_head_)
-       dp.dir_ = to_dir (dp.dot_->get_grob_property  ("direction"));
+       dp.dir_ = to_dir (dp.dot_->get_property  ("direction"));
 
       remove_collision (cfg, p);
       cfg[p] = dp;
@@ -277,7 +296,7 @@ Dot_column::do_shifts (Grob*me)
 void
 Dot_column::add_head (Grob * me, Grob *rh)
 {
-  Grob * d = unsmob_grob (rh->get_grob_property ("dot"));
+  Grob * d = unsmob_grob (rh->get_property ("dot"));
   if (d)
     {
       Side_position_interface::add_support (me,rh);
@@ -292,6 +311,8 @@ Dot_column::add_head (Grob * me, Grob *rh)
 
 
 ADD_INTERFACE (Dot_column, "dot-column-interface",
-  "Interface that groups dots so they form a column",
-  "direction stem");
+              "Groups dot objects so they form a column, and position dots so they do not "
+              "clash with staff lines "
+              ,
+              "positioning-done direction stem");