- SCM scm_width = ly_interval2scm (width);
- me->flush_extent_cache (X_AXIS);
- me->set_property ("X-extent", scm_width);
+ 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);
+ Real padding = robust_scm2double (me->get_property ("padding"), 0.2);