]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/axis-group-interface.cc
Merge branch 'master' of git+ssh://jneem@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / axis-group-interface.cc
index 9fbfdf3193f29fb1c3329b880ddb55296cc4eabc..23c30872474d31267c92d093122dd1be452d6a1b 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2000--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "axis-group-interface.hh"
@@ -68,6 +68,14 @@ Axis_group_interface::relative_group_extent (vector<Grob*> const &elts,
   return r;
 }
 
+
+/*
+  FIXME: pure extent handling has a lot of ad-hoc caching.
+  This should be done with grob property callbacks.
+
+  --hwn
+*/
+
 Interval
 Axis_group_interface::cached_pure_height (Grob *me,
                                          vector<Grob*> const &elts,
@@ -101,7 +109,7 @@ Axis_group_interface::cached_pure_height (Grob *me,
   if (!scm_is_vector (extents))
     {
       extents = scm_c_make_vector (breaks.size () - 1, SCM_EOL);
-      for (vsize i = 0; i < breaks.size () - 1; i++)
+      for (vsize i = 0; i + 1 < breaks.size (); i++)
        {
          int st = Paper_column::get_rank (cols[breaks[i]]);
          int ed = Paper_column::get_rank (cols[breaks[i+1]]);
@@ -177,6 +185,17 @@ Axis_group_interface::pure_height (SCM smob, SCM start_scm, SCM end_scm)
   int end = robust_scm2int (end_scm, INT_MAX);
   Grob *me = unsmob_grob (smob);
 
+  /* Maybe we are in the second pass of a two-pass spacing run. In that
+     case, the Y-extent of a system is already given to us */
+  System *system = dynamic_cast<System*> (me);
+  if (system)
+    {
+      SCM line_break_details = system->column (start)->get_property ("line-break-system-details");
+      SCM system_y_extent = scm_assq (ly_symbol2scm ("system-Y-extent"), line_break_details);
+      if (scm_is_pair (system_y_extent))
+       return scm_cdr (system_y_extent);
+    }
+
   return pure_group_height (me, start, end);
 }
 
@@ -275,6 +294,17 @@ Axis_group_interface::calc_pure_elts_and_common (Grob *me)
   return common;
 }
 
+MAKE_SCHEME_CALLBACK(Axis_group_interface,calc_x_common, 1);
+SCM
+Axis_group_interface::calc_x_common (SCM grob)
+{
+  Grob *me = unsmob_grob (grob);
+
+  extract_grob_set (me, "elements", elts);
+  Grob *common = common_refpoint_of_array (elts, me, X_AXIS);
+  return common->self_scm ();
+}
+
 MAKE_SCHEME_CALLBACK(Axis_group_interface,calc_y_common, 1);
 SCM
 Axis_group_interface::calc_y_common (SCM grob)
@@ -282,7 +312,8 @@ Axis_group_interface::calc_y_common (SCM grob)
   Grob *me = unsmob_grob (grob);
 
   extract_grob_set (me, "elements", elts);
-  return common_refpoint_of_array (elts, me, Y_AXIS)->self_scm ();
+  Grob *common = common_refpoint_of_array (elts, me, Y_AXIS);
+  return common->self_scm ();
 }
 
 SCM
@@ -446,7 +477,7 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements)
       SCM priority = elements[i]->get_property ("outside-staff-priority");
       vector<Grob*> current_elts;
       current_elts.push_back (elements[i]);
-      while (i < elements.size () - 1
+      while (i + 1 < elements.size () 
             && scm_eq_p (elements[i+1]->get_property ("outside-staff-priority"), priority))
        current_elts.push_back (elements[++i]);