- Note_column * rcol = rest_l_arr_[0];
-
- // try to be opposite of noteheads.
- Direction dir = - ncol_l_arr_[0]->dir();
-
- Interval restdim;
- for (int i=0; i < rcol->rest_l_arr_.size(); i++)
- restdim.unite (rcol->rest_l_arr_[i]->extent (Y_AXIS));
-
- if (restdim.empty_b ())
- return;
-
- // staff ref'd?
- Real staff_space = rcol->rest_l_arr_[0]->staff_line_leading_f ();
- Real internote_f = staff_space/2;
- Real minimum_dist = paper_l ()->get_var ("restcollision_minimum_dist")
- * internote_f;
-
+ while (flip (&d) != LEFT);
+
+ do
+ {
+ if (ordered_rests[d].size () < 1)
+ {
+ if (ordered_rests[-d].size () > 1)
+ ordered_rests[-d][0]->warning (_ ("too many colliding rests"));
+
+ return SCM_UNSPECIFIED;
+ }
+ }
+ while (flip (&d) != LEFT);
+
+ Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS);
+ common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS);
+
+ Real diff
+ = (ordered_rests[DOWN].top ()->extent (common, Y_AXIS)[UP]
+ - ordered_rests[UP].top ()->extent (common, Y_AXIS)[DOWN]) / staff_space;
+
+ if (diff > 0)
+ {
+ int amount_down = (int) ceil (diff / 2);
+ diff -= amount_down;
+ Note_column::translate_rests (ordered_rests[DOWN].top (),
+ -2 * amount_down);
+ if (diff > 0)
+ Note_column::translate_rests (ordered_rests[UP].top (),
+ 2 * int (ceil (diff)));
+ }
+
+ do
+ {
+ for (int i = ordered_rests[d].size () -1; i-- > 0;)
+ {
+ Real last_y = ordered_rests[d][i + 1]->extent (common, Y_AXIS)[d];
+ Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d];
+
+ Real diff = d * ((last_y - y) / staff_space);
+ if (diff > 0)
+ Note_column::translate_rests (ordered_rests[d][i], d * (int) ceil (diff) * 2);
+ }
+ }
+ while (flip (&d) != LEFT);
+ }
+ else
+ {