- Link_array<Note_column> rest_l_arr =
- Group_interface__extract_elements (this, (Note_column*) 0, "rests");
- Link_array<Note_column> ncol_l_arr =
- Group_interface__extract_elements (this, (Note_column*) 0, "notes");
-
+ me->add_dependency (p);
+ Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), p);
+
+ /*
+ only add callback for the rests, since we don't move anything else.
+
+ (not?)
+ */
+ p->add_offset_callback (Rest_collision::force_shift_callback_proc, Y_AXIS);
+ p->set_grob_property ("rest-collision", me->self_scm ());
+}
+
+
+/*
+ Combination of dot-count and duration-log.
+ */
+static SCM
+head_characteristic (Grob * col)
+{
+ Grob * s = unsmob_grob (col->get_grob_property ("rest"));
+
+ if (!s)
+ return SCM_BOOL_F;
+ else
+ return gh_cons (s->get_grob_property ("duration-log"),
+ gh_int2scm (Rhythmic_head::dot_count (s)));
+}
+
+/*
+ TODO: fixme, fucks up if called twice on the same set of rests.
+
+ TODO: look at horizontal-shift to determine ordering between rests
+ for more than two voices.
+
+ */
+SCM
+Rest_collision::do_shift (Grob *me, SCM elts)
+{
+ /*
+ ugh. -> score elt type
+ */
+ Link_array<Grob> rests;
+ Link_array<Grob> notes;
+ Grob * commony = 0;
+ for (SCM s = elts; gh_pair_p (s); s = ly_cdr (s))
+ {
+
+ Grob * e = unsmob_grob (ly_car (s));
+ if (!e)
+ continue;
+
+ if (!commony)
+ commony = e;
+ else
+ commony= commony->common_refpoint (e, Y_AXIS);
+
+ if (unsmob_grob (e->get_grob_property ("rest")))
+ rests.push (e);
+ else
+ notes.push (e);
+ }
+