]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/axis-group-interface.cc
Fix page-count with systems-per-page.
[lilypond.git] / lily / axis-group-interface.cc
index 1ec518feff52bd95ed7ac0a7d5e86590539291d0..35ad189c13106673ee3e424a4509eb4a1ea22496 100644 (file)
@@ -143,14 +143,12 @@ Axis_group_interface::combine_pure_heights (Grob *me, SCM measure_extents, int s
   return ext;
 }
 
-
 // adjacent-pure-heights is a pair of vectors, each of which has one element
 // for every measure in the score. The first vector stores, for each measure,
 // the combined height of the elements that are present only when the bar
 // is at the beginning of a line. The second vector stores, for each measure,
 // the combined height of the elements that are present only when the bar
 // is not at the beginning of a line.
-
 MAKE_SCHEME_CALLBACK (Axis_group_interface, adjacent_pure_heights, 1)
 SCM
 Axis_group_interface::adjacent_pure_heights (SCM smob)
@@ -165,6 +163,8 @@ Axis_group_interface::adjacent_pure_heights (SCM smob)
 
   vector<Interval> begin_line_heights;
   vector<Interval> mid_line_heights;
+  vector<Interval> begin_line_staff_heights;
+  vector<Interval> mid_line_staff_heights;
   begin_line_heights.resize (ranks.size () - 1);
   mid_line_heights.resize (ranks.size () - 1);
 
@@ -178,6 +178,18 @@ Axis_group_interface::adjacent_pure_heights (SCM smob)
       bool outside_staff = scm_is_number (g->get_property ("outside-staff-priority"));
       Real padding = robust_scm2double (g->get_property ("outside-staff-padding"), 0.5);
 
+      // When we encounter the first outside-staff grob, make a copy
+      // of the current heights to use as an estimate for the staff heights.
+      // Note that the outside-staff approximation that we use here doesn't
+      // consider any collisions that might occur between outside-staff grobs,
+      // but only the fact that outside-staff grobs may need to be raised above
+      // the staff.
+      if (outside_staff && begin_line_staff_heights.empty ())
+       {
+         begin_line_staff_heights = begin_line_heights;
+         mid_line_staff_heights = mid_line_heights;
+       }
+
       // TODO: consider a pure version of get_grob_direction?
       Direction d = to_dir (g->get_property_data ("direction"));
       d = (d == CENTER) ? UP : d;
@@ -205,14 +217,16 @@ Axis_group_interface::adjacent_pure_heights (SCM smob)
                  if (rank_span[LEFT] <= start)
                    {
                      if (outside_staff)
-                       begin_line_heights[j].unite_disjoint (dims, padding, d);
+                       begin_line_heights[j].unite (
+                           begin_line_staff_heights[j].union_disjoint (dims, padding, d));
                      else
                        begin_line_heights[j].unite (dims);
                    }
                   if (rank_span[RIGHT] > start)
                    {
                      if (outside_staff)
-                       mid_line_heights[j].unite_disjoint (dims, padding, d);
+                       mid_line_heights[j].unite (
+                            mid_line_staff_heights[j].union_disjoint (dims, padding, d));
                      else
                        mid_line_heights[j].unite (dims);
                    }
@@ -350,7 +364,7 @@ Axis_group_interface::combine_skylines (SCM smob)
     }
   return ret.smobbed_copy ();
 }
-  
+
 SCM
 Axis_group_interface::generic_group_extent (Grob *me, Axis a)
 {
@@ -389,7 +403,7 @@ SCM
 Axis_group_interface::calc_pure_relevant_grobs (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
-  
+
   extract_grob_set (me, "elements", elts);
 
   vector<Grob*> relevant_grobs;
@@ -679,7 +693,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 + 1 < elements.size () 
+      while (i + 1 < elements.size ()
             && scm_eq_p (elements[i+1]->get_property ("outside-staff-priority"), priority))
        {
          if (!to_boolean (elements[i+1]->get_property ("cross-staff")))
@@ -712,28 +726,28 @@ Axis_group_interface::print (SCM smob)
   return ret.smobbed_copy ();
 }
 
-MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_pure_next_staff_spacing, 3)
+MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_pure_staff_staff_spacing, 3)
 SCM
-Axis_group_interface::calc_pure_next_staff_spacing (SCM smob, SCM start, SCM end)
+Axis_group_interface::calc_pure_staff_staff_spacing (SCM smob, SCM start, SCM end)
 {
-  return calc_maybe_pure_next_staff_spacing (unsmob_grob (smob),
-                                            true,
-                                            scm_to_int (start),
-                                            scm_to_int (end));
+  return calc_maybe_pure_staff_staff_spacing (unsmob_grob (smob),
+                                             true,
+                                             scm_to_int (start),
+                                             scm_to_int (end));
 }
 
-MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_next_staff_spacing, 1)
+MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_staff_staff_spacing, 1)
 SCM
-Axis_group_interface::calc_next_staff_spacing (SCM smob)
+Axis_group_interface::calc_staff_staff_spacing (SCM smob)
 {
-  return calc_maybe_pure_next_staff_spacing (unsmob_grob (smob),
-                                            false,
-                                            0,
-                                            INT_MAX);
+  return calc_maybe_pure_staff_staff_spacing (unsmob_grob (smob),
+                                             false,
+                                             0,
+                                             INT_MAX);
 }
 
 SCM
-Axis_group_interface::calc_maybe_pure_next_staff_spacing (Grob *me, bool pure, int start, int end)
+Axis_group_interface::calc_maybe_pure_staff_staff_spacing (Grob *me, bool pure, int start, int end)
 {
   Grob *grouper = unsmob_grob (me->get_object ("staff-grouper"));
 
@@ -741,11 +755,11 @@ Axis_group_interface::calc_maybe_pure_next_staff_spacing (Grob *me, bool pure, i
     {
       Grob *last_in_group = Staff_grouper_interface::get_maybe_pure_last_grob (grouper, pure, start, end);
       if (me == last_in_group)
-       return grouper->get_maybe_pure_property ("after-last-staff-spacing", pure, start, end);
+       return grouper->get_maybe_pure_property ("staffgroup-staff-spacing", pure, start, end);
       else
-       return grouper->get_maybe_pure_property ("between-staff-spacing", pure, start, end);
+       return grouper->get_maybe_pure_property ("staff-staff-spacing", pure, start, end);
     }
-  return me->get_maybe_pure_property ("default-next-staff-spacing", pure, start, end);
+  return me->get_maybe_pure_property ("default-staff-staff-spacing", pure, start, end);
 }
 
 Real
@@ -767,24 +781,24 @@ ADD_INTERFACE (Axis_group_interface,
               // VerticalAxisGroup. We should split off a
               // vertical-axis-group-interface.
               /* properties */
-              "X-common "
-              "Y-common "
               "adjacent-pure-heights "
               "axes "
-              "default-next-staff-spacing "
+              "default-staff-staff-spacing "
               "elements "
-              "inter-loose-line-spacing "
-              "inter-staff-spacing "
               "max-stretch "
-              "non-affinity-spacing "
-              "next-staff-spacing "
               "no-alignment "
-              "pure-Y-common "
+              "nonstaff-nonstaff-spacing "
+              "nonstaff-relatedstaff-spacing "
+              "nonstaff-unrelatedstaff-spacing "
               "pure-relevant-grobs "
               "pure-relevant-items "
               "pure-relevant-spanners "
+              "pure-Y-common "
               "staff-affinity "
               "staff-grouper "
+              "staff-staff-spacing "
               "system-Y-offset "
               "vertical-skylines "
+              "X-common "
+              "Y-common "
               );