- if (ext.is_empty ())
- {
- programming_error ("I'm empty. Can't align on self");
- return gh_double2scm (0.0);
- }
- else
- {
- return gh_double2scm (- ext.linear_combination (gh_scm2double (align)));
- }
- }
- return gh_double2scm (0.0);
+SCM
+Self_alignment_interface::aligned_on_parent (Grob *me, Axis a)
+{
+ Grob *him = me->get_parent (a);
+ if (Paper_column::has_interface (him))
+ return scm_from_double (0.0);
+
+ Interval he = him->extent (him, a);
+
+ SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
+ : ly_symbol2scm ("self-alignment-Y");
+ SCM align_prop (me->internal_get_property (sym));
+
+ if (!scm_is_number (align_prop))
+ return scm_from_int (0);
+
+ Real x = 0.0;
+ Real align = scm_to_double (align_prop);
+
+ Interval ext (me->extent (me, a));
+ if (ext.is_empty ())
+ programming_error ("cannot align on self: empty element");
+ else
+ x -= ext.linear_combination (align);
+
+ if (!he.is_empty ())
+ x += he.linear_combination (align);
+
+ return scm_from_double (x);