]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dot-column.cc
* scm/define-context-properties.scm
[lilypond.git] / lily / dot-column.cc
index 2b0e59494c1802f0566c74cb8e12babe31e195fd..6a1cc7ef029ea4398baacf1460b981e0411d075d 100644 (file)
@@ -9,8 +9,9 @@
 #include "dot-column.hh"
 
 #include <cstdio>
-#include <math.h>
+#include <cmath>
 #include <map>
+using namespace std;
 
 #include "dots.hh"
 #include "rhythmic-head.hh"
 #include "side-position-interface.hh"
 #include "axis-group-interface.hh"
 #include "stem.hh"
+#include "pointer-group-interface.hh"
 
 /*
   TODO: let Dot_column communicate with stem via Note_column.
 */
 
-MAKE_SCHEME_CALLBACK (Dot_column, force_shift_callback, 2);
-SCM
-Dot_column::force_shift_callback (SCM element_smob, SCM axis)
-{
-  Grob *me = unsmob_grob (element_smob);
-  (void) axis;
-  assert (scm_to_int (axis) == Y_AXIS);
-  me = me->get_parent (X_AXIS);
-
-  if (!to_boolean (me->get_property ("positioning-done")))
-    {
-      me->set_property ("positioning-done", SCM_BOOL_T);
-
-      do_shifts (me);
-    }
-  return scm_make_real (0.0);
-}
-
 MAKE_SCHEME_CALLBACK (Dot_column, side_position, 2);
 SCM
 Dot_column::side_position (SCM element_smob, SCM axis)
@@ -50,7 +34,7 @@ Dot_column::side_position (SCM element_smob, SCM axis)
   (void) axis;
   assert (scm_to_int (axis) == X_AXIS);
 
-  Grob *stem = unsmob_grob (me->get_property ("stem"));
+  Grob *stem = unsmob_grob (me->get_object ("stem"));
   if (stem
       && !Stem::get_beam (stem)
       && Stem::duration_log (stem) > 2
@@ -61,8 +45,9 @@ Dot_column::side_position (SCM element_smob, SCM axis)
 
        This will add the stem to the support if a flag collision happens.
       */
-      Stem::stem_end_position (stem);
+      stem->get_property ("stem-end-position");
     }
+  
   return Side_position_interface::aligned_side (element_smob, axis);
 }
 
@@ -81,7 +66,7 @@ struct Dot_position
   }
 };
 
-typedef std::map<int, Dot_position> Dot_configuration;
+typedef map<int, Dot_position> Dot_configuration;
 
 /*
   Value CFG according.
@@ -158,9 +143,7 @@ shift_one (Dot_configuration const &cfg,
          else
            {
              if (new_cfg.find (p) == new_cfg.end ())
-               {
-                 offset = 0;
-               }
+               offset = 0;
              new_cfg[p + offset] = i->second;
            }
        }
@@ -187,9 +170,7 @@ shift_one (Dot_configuration const &cfg,
          else
            {
              if (new_cfg.find (p) == new_cfg.end ())
-               {
-                 offset = 0;
-               }
+               offset = 0;
 
              new_cfg[p + offset] = i->second;
            }
@@ -221,11 +202,13 @@ remove_collision (Dot_configuration &cfg, int p)
     }
 }
 
+MAKE_SCHEME_CALLBACK(Dot_column, calc_positioning_done, 1);
 SCM
-Dot_column::do_shifts (Grob *me)
+Dot_column::calc_positioning_done (SCM smob)
 {
+  Grob *me = unsmob_grob (smob);  
   Link_array<Grob> dots
-    = extract_grob_array (me, ly_symbol2scm ("dots"));
+    = extract_grob_array (me, "dots");
 
   { /*
       Trigger note collision resolution first, since that may kill off
@@ -261,7 +244,7 @@ Dot_column::do_shifts (Grob *me)
       Grob *note = dots[i]->get_parent (Y_AXIS);
       if (note)
        {
-         Grob *stem = unsmob_grob (note->get_property ("stem"));
+         Grob *stem = unsmob_grob (note->get_object ("stem"));
          if (stem)
            dp.extremal_head_ = Stem::first_head (stem) == note;
        }
@@ -280,29 +263,33 @@ Dot_column::do_shifts (Grob *me)
 
   for (Dot_configuration::const_iterator i (cfg.begin ());
        i != cfg.end (); i++)
-    {
-      Staff_symbol_referencer::set_position (i->second.dot_, i->first);
-    }
+    Staff_symbol_referencer::set_position (i->second.dot_, i->first);
 
-  return SCM_UNSPECIFIED;
+  return SCM_BOOL_T;
 }
 
 void
 Dot_column::add_head (Grob *me, Grob *rh)
 {
-  Grob *d = unsmob_grob (rh->get_property ("dot"));
+  Grob *d = unsmob_grob (rh->get_object ("dot"));
   if (d)
     {
       Side_position_interface::add_support (me, rh);
 
       Pointer_group_interface::add_grob (me, ly_symbol2scm ("dots"), d);
-      d->add_offset_callback (Dot_column::force_shift_callback_proc, Y_AXIS);
+      d->add_offset_callback (Grob::other_axis_parent_positioning_proc, Y_AXIS);
       Axis_group_interface::add_element (me, d);
     }
 }
 
-ADD_INTERFACE (Dot_column, "dot-column-interface",
+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 ",
-              "positioning-done direction stem");
+
+              /* properties */
+              "positioning-done "
+              "direction "
+              "stem");