+ The naturals should be left of the C as well; they should
+ be separate accs.
+
+ Note that this placement problem looks NP hard, so we just use a
+ simple strategy, not an optimal choice.
+*/
+
+/*
+ TODO: there should be more space in the following situation
+
+
+ Natural + downstem
+
+ *
+ * |_
+ * | | X
+ * |_| |
+ * | |
+ *
+
+*/
+
+MAKE_SCHEME_CALLBACK (Accidental_placement, calc_positioning_done, 1);
+SCM
+Accidental_placement::calc_positioning_done (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+ if (!me->is_live ())
+ return SCM_BOOL_T;
+
+ me->set_property ("positioning-done", SCM_BOOL_T);
+
+ SCM accs = me->get_object ("accidental-grobs");
+ if (!scm_is_pair (accs))
+ return SCM_BOOL_T;
+
+ vector<Accidental_placement_entry*> apes = build_apes (accs);
+
+ Grob *common[] = {me, 0};
+
+ vector<Grob*> heads_and_stems = extract_heads_and_stems (apes);
+
+ common[Y_AXIS] = common_refpoint_of_accidentals (apes, Y_AXIS);
+ common[Y_AXIS] = common_refpoint_of_array (heads_and_stems, common[Y_AXIS], Y_AXIS);
+ common[X_AXIS] = common_refpoint_of_array (heads_and_stems, me, X_AXIS);
+
+ for (vsize i = apes.size (); i--;)
+ set_ape_skylines (apes[i], common);
+ Skyline heads_skyline = build_heads_skyline (heads_and_stems, common);
+
+ stagger_apes (&apes);
+ Interval width = position_apes (me, apes, heads_skyline);