]> 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 e6b1e10f2cac60a9f502a254436ae03fc9fe5f5a..8c3ca97607c7873b789a661ad190ba03b07048cb 100644 (file)
@@ -61,9 +61,12 @@ Axis_group_interface::relative_group_extent (vector<Grob*> const &elts,
   for (vsize i = 0; i < elts.size (); i++)
     {
       Grob *se = elts[i];
-      Interval dims = se->extent (common, a);
-      if (!dims.is_empty ())
-       r.unite (dims);
+      if (!to_boolean (se->get_property ("cross-staff")))
+       {
+         Interval dims = se->extent (common, a);
+         if (!dims.is_empty ())
+           r.unite (dims);
+       }
     }
   return r;
 }
@@ -185,6 +188,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);
 }
 
@@ -344,6 +358,12 @@ staff_priority_less (Grob * const &g1, Grob * const &g2)
   else if (priority_1 > priority_2)
     return false;
 
+  /* if neither grob has an outside-staff priority, the ordering will have no
+     effect -- we just need to choose a consistent ordering. We do this to
+     avoid the side-effect of calculating extents. */
+  if (isinf (priority_1))
+    return g1 < g2;
+
   /* if there is no preference in staff priority, choose the left-most one */
   Grob *common = g1->common_refpoint (g2, X_AXIS);
   Real start_1 = g1->extent (common, X_AXIS)[LEFT];
@@ -360,7 +380,8 @@ add_boxes (Grob *me, Grob *x_common, Grob *y_common, vector<Box> *const boxes)
       for (vsize i = 0; i < elements->size (); i++)
        add_boxes (elements->grob (i), x_common, y_common, boxes);
     }
-  else if (!scm_is_number (me->get_property ("outside-staff-priority")))
+  else if (!scm_is_number (me->get_property ("outside-staff-priority"))
+          && !to_boolean (me->get_property ("cross-staff")))
     boxes->push_back (Box (me->extent (x_common, X_AXIS),
                           me->extent (y_common, Y_AXIS)));
 }
@@ -475,6 +496,21 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements)
   return skylines;
 }
 
+MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_max_stretch, 1)
+SCM
+Axis_group_interface::calc_max_stretch (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  Real ret = 0;
+  extract_grob_set (me, "elements", elts);
+
+  for (vsize i = 0; i < elts.size (); i++)
+    if (Axis_group_interface::has_interface (elts[i]))
+      ret += robust_scm2double (elts[i]->get_property ("max-stretch"), 0.0);
+
+  return scm_from_double (ret);
+}
+
 ADD_INTERFACE (Axis_group_interface,
 
               "An object that groups other layout objects.",
@@ -484,6 +520,8 @@ ADD_INTERFACE (Axis_group_interface,
               "Y-common "
               "axes "
               "elements "
+              "keep-fixed-while-stretching "
+              "max-stretch "
               "pure-Y-common "
               "pure-relevant-elements "
               "skylines "