X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faxis-group-interface.cc;h=7f6d1ef6b527af167bd0941630f6dae90ec348ac;hb=5516a43e8bc85c3f58b3c004a9a7fde626408939;hp=e6b1e10f2cac60a9f502a254436ae03fc9fe5f5a;hpb=8e459799a3048b989067c0f2114b27f77d6cada1;p=lilypond.git diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index e6b1e10f2c..7f6d1ef6b5 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -61,9 +61,12 @@ Axis_group_interface::relative_group_extent (vector 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; } @@ -149,7 +152,7 @@ Axis_group_interface::relative_pure_height (Grob *me, for (vsize i = 0; i < elts.size (); i++) { - Interval_t rank_span = elts[i]->spanned_rank_iv (); + Interval_t rank_span = elts[i]->spanned_rank_interval (); Item *it = dynamic_cast (elts[i]); if (rank_span[LEFT] <= end && rank_span[RIGHT] >= start && (!it || it->pure_is_visible (start, end))) { @@ -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 (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); } @@ -283,7 +297,7 @@ Axis_group_interface::calc_pure_elts_and_common (Grob *me) return common; } -MAKE_SCHEME_CALLBACK(Axis_group_interface,calc_x_common, 1); +MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_x_common, 1); SCM Axis_group_interface::calc_x_common (SCM grob) { @@ -294,7 +308,7 @@ Axis_group_interface::calc_x_common (SCM grob) return common->self_scm (); } -MAKE_SCHEME_CALLBACK(Axis_group_interface,calc_y_common, 1); +MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_y_common, 1); SCM Axis_group_interface::calc_y_common (SCM grob) { @@ -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 *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))); } @@ -416,9 +437,7 @@ add_grobs_of_one_priority (Skyline_pair *const skylines, if (b[X_AXIS][LEFT] - 2*horizon_padding < last_affected_position[dir]) continue; - if (b[X_AXIS].is_empty () || b[Y_AXIS].is_empty ()) - warning (_f ("outside-staff object %s has an empty extent", elements[i]->name ().c_str ())); - else + if (!b[X_AXIS].is_empty () && !b[Y_AXIS].is_empty ()) { boxes.clear (); boxes.push_back (b); @@ -475,6 +494,21 @@ Axis_group_interface::skyline_spacing (Grob *me, vector 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 +518,8 @@ ADD_INTERFACE (Axis_group_interface, "Y-common " "axes " "elements " + "keep-fixed-while-stretching " + "max-stretch " "pure-Y-common " "pure-relevant-elements " "skylines "