]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/axis-group-interface.cc
Merge branch 'master' into lilypond/translation
[lilypond.git] / lily / axis-group-interface.cc
index 3c428bca226f989f361826abf1d7eb8da385acda..ac778b05364b44ef269dddb48261d2adc2e97737 100644 (file)
@@ -74,6 +74,13 @@ Axis_group_interface::has_axis (Grob *me, Axis a)
 Interval
 Axis_group_interface::relative_group_extent (vector<Grob *> const &elts,
                                              Grob *common, Axis a)
+{
+  return relative_maybe_bound_group_extent (elts, common, a, false);
+}
+
+Interval
+Axis_group_interface::relative_maybe_bound_group_extent (vector<Grob *> const &elts,
+                                                        Grob *common, Axis a, bool bound)
 {
   Interval r;
   for (vsize i = 0; i < elts.size (); i++)
@@ -81,7 +88,9 @@ Axis_group_interface::relative_group_extent (vector<Grob *> const &elts,
       Grob *se = elts[i];
       if (!to_boolean (se->get_property ("cross-staff")))
         {
-          Interval dims = se->extent (common, a);
+          Interval dims = (bound && has_interface (se)
+                           ? generic_bound_extent (se, common, a)
+                           : se->extent (common, a));
           if (!dims.is_empty ())
             r.unite (dims);
         }
@@ -89,6 +98,32 @@ Axis_group_interface::relative_group_extent (vector<Grob *> const &elts,
   return r;
 }
 
+Interval
+Axis_group_interface::generic_bound_extent (Grob *me, Grob *common, Axis a)
+{
+  /* trigger the callback to do skyline-spacing on the children */
+  if (a == Y_AXIS)
+    (void) me->get_property ("vertical-skylines");
+
+  extract_grob_set (me, "elements", elts);
+  vector<Grob *> new_elts;
+
+  SCM interfaces = me->get_property ("bound-alignment-interfaces");
+
+  for (vsize i = 0; i < elts.size (); i++)
+    for (SCM l = interfaces; scm_is_pair (l); l = scm_cdr (l))
+      if (elts[i]->internal_has_interface (scm_car (l)))
+        new_elts.push_back (elts[i]);
+
+  if (!new_elts.size ())
+    return robust_relative_extent (me, common, a);
+
+  if (!common)
+    common = common_refpoint_of_array (new_elts, me, a);
+
+  return relative_maybe_bound_group_extent (new_elts, common, a, true);
+}
+
 Interval
 Axis_group_interface::sum_partial_pure_heights (Grob *me, int start, int end)
 {
@@ -808,6 +843,7 @@ ADD_INTERFACE (Axis_group_interface,
                /* properties */
                "adjacent-pure-heights "
                "axes "
+               "bound-alignment-interfaces "
                "default-staff-staff-spacing "
                "elements "
                "max-stretch "