-void
-Rest_collision::do_substitute_dependency (Score_element*o,Score_element*n)
-{
- if (Note_column *onl = dynamic_cast<Note_column *> (o))
- {
- Note_column *n_l = n?dynamic_cast<Note_column *> (n):0;
- rest_l_arr_.substitute (onl, n_l);
- ncol_l_arr_.substitute (onl, n_l);
+ Grob * r = unsmob_grob (rcol->get_grob_property ("rest"));
+ Interval restdim = r->extent (r, Y_AXIS); // ??
+
+ if (restdim.empty_b ())
+ return SCM_UNSPECIFIED;
+
+ // FIXME: staff ref'd?
+ Real staff_space = 1.0;
+
+ Real minimum_dist = gh_scm2double (me->get_grob_property ("minimum-distance")) * staff_space;
+
+ /*
+ assumption: ref points are the same.
+ */
+ Interval notedim;
+ for (int i = 0; i < notes.size (); i++)
+ {
+ Grob * stem = Note_column::stem_l (notes[i]);
+ Grob * head = Stem::first_head (stem);
+ notedim.unite (head->extent (commony, Y_AXIS));
+ }
+
+ Interval inter (notedim);
+ inter.intersect (restdim);
+
+ Real dist =
+ minimum_dist + dir * (notedim[dir] - restdim[-dir]) >? 0;
+
+
+ // FIXME
+ //int stafflines = 5; // rcol->rests[0]->line_count;
+ int stafflines = Staff_symbol_referencer::line_count (me);
+ // hurg?
+ stafflines = stafflines != 0 ? stafflines : 5;
+
+ // move discretely by half spaces.
+ int discrete_dist = int (ceil (dist / (0.5 *staff_space)));
+
+ // move by whole spaces inside the staff.
+ if (discrete_dist < stafflines+1)
+ discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
+
+ Note_column::translate_rests (rcol,dir * discrete_dist);