+MAKE_SCHEME_CALLBACK (Self_alignment_interface, x_aligned_on_self, 1);
+SCM
+Self_alignment_interface::x_aligned_on_self (SCM element)
+{
+ return aligned_on_self (unsmob_grob (element), X_AXIS);
+}
+
+SCM
+Self_alignment_interface::aligned_on_self (Grob *me, Axis a)
+{
+ SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
+ : ly_symbol2scm ("self-alignment-Y");
+
+ SCM align (me->internal_get_property (sym));
+ if (scm_is_number (align))
+ {
+ Interval ext (me->extent (me, a));
+ if (ext.is_empty ())
+ programming_error ("cannot align on self: empty element");
+ else
+ return scm_from_double (- ext.linear_combination (scm_to_double (align)));
+ }
+ return scm_from_double (0.0);
+}
+
+
+
+SCM
+Self_alignment_interface::centered_on_object (Grob *him, Axis a)
+{
+ return scm_from_double (robust_relative_extent (him, him, a).center ());
+}
+
+
+MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_x_parent, 1);
+SCM
+Self_alignment_interface::centered_on_x_parent (SCM smob)
+{
+ return centered_on_object (unsmob_grob (smob)->get_parent (X_AXIS), X_AXIS);
+}
+
+
+MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_y_parent, 1);