From: Joe Neeman Date: Fri, 1 Oct 2010 23:10:54 +0000 (-0700) Subject: Fix drastic overestimation of staff heights. X-Git-Tag: release/2.13.36-1~71^2~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=bd815715c3aa550810f75529a8c0bfb092856668;p=lilypond.git Fix drastic overestimation of staff heights. The outside-staff simulation in f530eeb5bba has severe problems when there many outside-staff objects per bar. This patch mitigates the problems by assuming that outside-staff objects don't intersect with each other (but only with the staff). --- diff --git a/flower/include/interval.hh b/flower/include/interval.hh index 4a08e27813..512200f6cf 100644 --- a/flower/include/interval.hh +++ b/flower/include/interval.hh @@ -73,6 +73,7 @@ struct Interval_t : public Drul_array void set_full (); void unite_disjoint (Interval_t h, T padding, Direction d); + Interval_t union_disjoint (Interval_t h, T padding, Direction d) const; bool is_empty () const { diff --git a/flower/include/interval.tcc b/flower/include/interval.tcc index 7a1440a319..35dd8ebb29 100644 --- a/flower/include/interval.tcc +++ b/flower/include/interval.tcc @@ -123,6 +123,15 @@ Interval_t::unite_disjoint (Interval_t h, T padding, Direction d) unite (h); } +template +Interval_t +Interval_t::union_disjoint (Interval_t h, T padding, Direction d) const +{ + Interval_t iv = *this; + iv.unite_disjoint (h, padding, d); + return iv; +} + template void Interval_t::intersect (Interval_t h) diff --git a/input/regression/page-breaking-outside-staff-estimation2.ly b/input/regression/page-breaking-outside-staff-estimation2.ly new file mode 100644 index 0000000000..6a33ca7e39 --- /dev/null +++ b/input/regression/page-breaking-outside-staff-estimation2.ly @@ -0,0 +1,12 @@ +\version "2.13.35" + +\header { + texidoc = "The height-estimation routine doesn't get confused +by multiple outside-staff grobs in the same measure." +} + +#(set-default-paper-size "a7") + +\book { + \repeat unfold 4 { \repeat unfold 4 {g'''4^"Text"} \break} +} diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 1ec518feff..85d2d36588 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -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 begin_line_heights; vector mid_line_heights; + vector begin_line_staff_heights; + vector 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); }