]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/dot-column.cc
release: 1.5.47
[lilypond.git] / lily / dot-column.cc
index d91e1b9de43f4365b3d0550d0f38d5ec4fa8955b..584b3616e64e4286abf7fa56aafff7a7ebb6f1ae 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "dots.hh"
 #include "directional-element-interface.hh"
 #include "side-position-interface.hh"
 #include "axis-group-interface.hh"
+#include "stem.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);
+  Axis a = (Axis) gh_scm2int (axis);
+  assert (a == Y_AXIS);
+  me = me->get_parent (X_AXIS);
+  SCM l = me->get_grob_property ("dots");
+  do_shifts (l);
+  return gh_double2scm (0.0);
+}
 
-
-
-void
-Dot_column::set_interface (Score_element* me)
+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);
+  assert (a == X_AXIS);
 
-  Directional_element_interface::set (me, RIGHT);
-  
-  Axis_group_interface::set_interface (me);
-  Axis_group_interface::set_axes (me, X_AXIS,X_AXIS);
+  Grob * stem = unsmob_grob (me->get_grob_property ("stem"));
+  if (stem
+      && !Stem::beam_l (stem)
+      && Stem::flag_i (stem))
+    {
+      /*
+       trigger stem end & direction calculation.
+
+       This will add the stem to the support if a flag collision happens.
+       */
+      Stem::stem_end_position (stem); 
+    }
+  return Side_position_interface::aligned_side (element_smob, axis);
 }
 
+
 /*
   Will fuck up in this case.
 
@@ -44,29 +72,14 @@ Dot_column::set_interface (Score_element* me)
 
    Should be smarter.
  */
-
-
-MAKE_SCHEME_CALLBACK(Dot_column,force_shift_callback,2);
-SCM
-Dot_column::force_shift_callback (SCM element_smob, SCM axis)
-{
-  Score_element *me = unsmob_element (element_smob);
-  Axis a = (Axis) gh_scm2int (axis);
-  assert (a == Y_AXIS);
- me = me->parent_l (X_AXIS);
-  SCM dots = me->get_elt_property ("dots");
-  do_shifts (dots);
-  return gh_double2scm (0.0);
-}
-
 SCM
 Dot_column::do_shifts (SCM l)
 {
-  Link_array<Score_element> dots;
+  Link_array<Grob> dots;
   while (gh_pair_p (l))
     {
-      dots.push (unsmob_element (gh_car (l)));
-      l = gh_cdr (l);
+      dots.push (unsmob_grob (ly_car (l)));
+      l = ly_cdr (l);
     }
   
   dots.sort (compare_position);
@@ -88,7 +101,7 @@ Dot_column::do_shifts (SCM l)
        }
       taken_posns.push ((int)p);
       s.unite (Slice ((int)p,
                    (int)p));      
+ (int)p));      
     }
 
   if (!conflicts)
@@ -99,12 +112,12 @@ Dot_column::do_shifts (SCM l)
     +1 -> off by one 
    */
   int pos = middle - dots.size () + 1;
-  if (!(pos % 2))
+  if (! (pos % 2))
     pos ++;                    // center () rounds down.
 
   for (int i=0; i < dots.size (); pos += 2, i++)
     {
-      Score_element * d = dots[i];
+      Grob * d = dots[i];
       Staff_symbol_referencer::set_position (d,pos);
     }
 
@@ -112,25 +125,30 @@ Dot_column::do_shifts (SCM l)
 }
 
 bool
-Dot_column::has_interface (Score_element*m)
+Dot_column::has_interface (Grob*m)
 {
   return m && m->has_interface (ly_symbol2scm ("dot-column-interface"));
 }
 
 
 void
-Dot_column::add_head (Score_element * me, Score_element *rh)
+Dot_column::add_head (Grob * me, Grob *rh)
 {
-  Score_element * d = unsmob_element (rh->get_elt_property ("dot"));
+  Grob * d = unsmob_grob (rh->get_grob_property ("dot"));
   if (d)
     {
-      Side_position::add_support (me,rh);
+      Side_position_interface::add_support (me,rh);
 
-      Pointer_group_interface gi (me, "dots");
-      gi.add_element (d);
-      
+      Pointer_group_interface::add_grob (me, ly_symbol2scm ("dots"), d);
       d->add_offset_callback (Dot_column::force_shift_callback_proc , Y_AXIS);
       Axis_group_interface::add_element (me, d);
     }
 }
 
+
+
+
+ADD_INTERFACE (Dot_column, "dot-column-interface",
+  "Interface that groups dots so they form a column",
+  "stem");
+