+ // make callback for rest from this.
+ Real beam_dy = 0;
+ Real beam_y = 0;
+
+
+ // todo: make sure this calced already.
+ SCM s = beam->get_elt_property ("height");
+ if (gh_number_p (s))
+ beam_dy = gh_scm2double (s);
+
+ s = beam->get_elt_property ("y-position");
+ if (gh_number_p (s))
+ beam_y = gh_scm2double (s);
+
+ // ugh -> use commonx
+ Real x0 = first_visible_stem(beam)->relative_coordinate (0, X_AXIS);
+ Real dx = last_visible_stem(beam)->relative_coordinate (0, X_AXIS) - x0;
+ Real dydx = beam_dy && dx ? beam_dy/dx : 0;
+
+ Direction d = Stem::get_direction (stem);
+ Real beamy = (stem->relative_coordinate (0, X_AXIS) - x0) * dydx + beam_y;
+
+ Real staff_space = Staff_symbol_referencer::staff_space (rest);
+
+
+ Real rest_dim = rest->extent (rest, Y_AXIS)[d]*2.0 / staff_space ; // refp??
+
+ Real minimum_dist
+ = gh_scm2double (rest->get_elt_property ("minimum-beam-collision-distance"));
+ Real dist =
+ minimum_dist + -d * (beamy - rest_dim) >? 0;
+
+ int stafflines = Staff_symbol_referencer::line_count (rest);
+
+ // move discretely by half spaces.
+ int discrete_dist = int (ceil (dist));
+
+ // move by whole spaces inside the staff.
+ if (discrete_dist < stafflines+1)
+ discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
+
+ return gh_double2scm (-d * discrete_dist);