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).
void set_full ();
void unite_disjoint (Interval_t<T> h, T padding, Direction d);
void set_full ();
void unite_disjoint (Interval_t<T> h, T padding, Direction d);
+ Interval_t<T> union_disjoint (Interval_t<T> h, T padding, Direction d) const;
+template<class T>
+Interval_t<T>
+Interval_t<T>::union_disjoint (Interval_t<T> h, T padding, Direction d) const
+{
+ Interval_t<T> iv = *this;
+ iv.unite_disjoint (h, padding, d);
+ return iv;
+}
+
template<class T>
void
Interval_t<T>::intersect (Interval_t<T> h)
template<class T>
void
Interval_t<T>::intersect (Interval_t<T> h)
--- /dev/null
+\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}
+}
// 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.
// 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)
MAKE_SCHEME_CALLBACK (Axis_group_interface, adjacent_pure_heights, 1)
SCM
Axis_group_interface::adjacent_pure_heights (SCM smob)
vector<Interval> begin_line_heights;
vector<Interval> mid_line_heights;
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);
begin_line_heights.resize (ranks.size () - 1);
mid_line_heights.resize (ranks.size () - 1);
bool outside_staff = scm_is_number (g->get_property ("outside-staff-priority"));
Real padding = robust_scm2double (g->get_property ("outside-staff-padding"), 0.5);
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;
// TODO: consider a pure version of get_grob_direction?
Direction d = to_dir (g->get_property_data ("direction"));
d = (d == CENTER) ? UP : d;
if (rank_span[LEFT] <= start)
{
if (outside_staff)
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)
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);
}
else
mid_line_heights[j].unite (dims);
}