]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/align-interface.cc
* The grand 2005-2006 replace.
[lilypond.git] / lily / align-interface.cc
index 5394a0dacbe62d5eb4b40cae2bc72778abb6a84c..dfccf028858eb5ded3eb133a73a64ccdc9e9a856 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "align-interface.hh"
   distance.
  */
 
-MAKE_SCHEME_CALLBACK (Align_interface, alignment_callback, 2);
+MAKE_SCHEME_CALLBACK (Align_interface, calc_positioning_done, 1);
 SCM
-Align_interface::alignment_callback (SCM element_smob, SCM axis)
+Align_interface::calc_positioning_done (SCM smob)
 {
-  Grob *me = unsmob_grob (element_smob);
+  Grob *me = unsmob_grob (smob);
+  SCM axis = scm_car (me->get_property ("axes"));
   Axis ax = (Axis)scm_to_int (axis);
-  Grob *par = me->get_parent (ax);
-  if (par && !to_boolean (par->get_property ("positioning-done")))
-    Align_interface::align_elements_to_extents (par, ax);
-  return scm_from_double (0.0);
-}
 
-MAKE_SCHEME_CALLBACK (Align_interface, fixed_distance_alignment_callback, 2);
-SCM
-Align_interface::fixed_distance_alignment_callback (SCM element_smob, SCM axis)
-{
-  Grob *me = unsmob_grob (element_smob);
-  Axis ax = (Axis)scm_to_int (axis);
-  Grob *par = me->get_parent (ax);
-  if (par && !to_boolean (par->get_property ("positioning-done")))
-    Align_interface::align_to_fixed_distance (par, ax);
-  return scm_from_double (0.0);
+  SCM force = me->get_property ("forced-distance");
+  if (scm_is_number (force))
+    Align_interface::align_to_fixed_distance (me, ax);
+  else
+    Align_interface::align_elements_to_extents (me, ax);
+
+  return SCM_BOOL_T;
 }
 
 /*
@@ -88,8 +81,6 @@ Align_interface::stretch_after_break (SCM grob)
 void
 Align_interface::align_to_fixed_distance (Grob *me, Axis a)
 {
-  me->set_property ("positioning-done", SCM_BOOL_T);
-
   Direction stacking_dir = robust_scm2dir (me->get_property ("stacking-dir"),
                                           DOWN);
 
@@ -151,6 +142,7 @@ Align_interface::align_to_fixed_distance (Grob *me, Axis a)
   The original function has been taken over by
   align_to_fixed_distance ().
 */
+
 void
 Align_interface::align_elements_to_extents (Grob *me, Axis a)
 {
@@ -159,9 +151,14 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a)
   if (a == Y_AXIS
       && me_spanner)
     {
+#if 0
+      /*
+       TODO: messes up for figured bass alignments. 
+       */
       if (me_spanner->get_bound (LEFT)->break_status_dir () == CENTER)
        me->warning (_ ("vertical alignment called before line-breaking. "
                        "Only do cross-staff spanners with PianoStaff."));
+#endif
 
       SCM details =  me_spanner->get_bound (LEFT)->get_property ("line-break-system-details");
       SCM extra_space_handle = scm_assoc (ly_symbol2scm ("alignment-extra-space"), details);
@@ -172,8 +169,6 @@ Align_interface::align_elements_to_extents (Grob *me, Axis a)
                                       extra_space);
     }
   
-  me->set_property ("positioning-done", SCM_BOOL_T);
-  
   Direction stacking_dir = robust_scm2dir (me->get_property ("stacking-dir"),
                                               DOWN);
 
@@ -266,16 +261,19 @@ Align_interface::axis (Grob *me)
 }
 
 void
-Align_interface::add_element (Grob *me, Grob *element, SCM call_back)
+Align_interface::add_element (Grob *me, Grob *element)
 {
-  element->add_offset_callback (call_back, Align_interface::axis (me));
+  Axis a = Align_interface::axis (me);
+  SCM sym = axis_offset_symbol (a);
+  SCM proc = axis_parent_positioning (a);
+    
+  element->internal_set_property (sym, proc);
   Axis_group_interface::add_element (me, element);
 }
 
 void
-Align_interface::set_axis (Grob *me, Axis a)
+Align_interface::set_ordered (Grob *me)
 {
-  Axis_group_interface::set_axes (me, a, a);
   SCM ga_scm = me->get_object ("elements");
   Grob_array *ga = unsmob_grob_array (ga_scm);
   if (!ga)