return centered_on_object (unsmob_grob (smob)->get_parent (X_AXIS), X_AXIS);
}
-MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_note_columns, 1);
-SCM
-Self_alignment_interface::centered_on_note_columns (SCM smob)
-{
- Item *it = unsmob_item (smob)->get_column ();
- if (!it)
- return scm_from_double (0.0);
-
- extract_grob_set (it, "elements", elts);
- vector<Grob *> ncs;
- Interval centers;
- for (vsize i = 0; i < elts.size (); i++)
- if (Note_column::has_interface (elts[i]))
- centers.add_point (scm_to_double (centered_on_object (elts[i], X_AXIS)));
-
- if (centers.is_empty ())
- return scm_from_double (0.0);
-
- return scm_from_double (centers.center ());
-}
-
MAKE_SCHEME_CALLBACK (Self_alignment_interface, centered_on_y_parent, 1);
SCM
Self_alignment_interface::centered_on_y_parent (SCM smob)
return centered_on_object (unsmob_grob (smob)->get_parent (Y_AXIS), Y_AXIS);
}
-MAKE_SCHEME_CALLBACK (Self_alignment_interface, x_centered_on_y_parent, 1);
-SCM
-Self_alignment_interface::x_centered_on_y_parent (SCM smob)
-{
- return centered_on_object (unsmob_grob (smob)->get_parent (Y_AXIS), X_AXIS);
-}
-
MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_x_parent, 1);
SCM
Self_alignment_interface::aligned_on_x_parent (SCM smob)
Self_alignment_interface::aligned_on_parent (Grob *me, Axis a)
{
Grob *him = me->get_parent (a);
+ Interval he;
if (Paper_column::has_interface (him))
- return scm_from_double (0.0);
-
- Interval he = him->extent (him, a);
+ /*
+ PaperColumn extents aren't reliable (they depend on size and alignment
+ of PaperColumn's children), so we align on NoteColumn instead.
+ This happens e.g. for lyrics without associatedVoice.
+ */
+ he = Paper_column::get_interface_extent
+ (him, ly_symbol2scm ("note-column-interface"), a);
+ else
+ {
+ if (ly_scm2bool(me->internal_get_property (ly_symbol2scm ("X-align-on-main-noteheads")))
+ && Note_column::has_interface (him))
+ he = Note_column::calc_main_heads_extent(him);
+ else
+ he = him->extent (him, a);
+ }
SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X")
: ly_symbol2scm ("self-alignment-Y");
}
void
-Self_alignment_interface::set_center_parent (Grob *me, Axis a)
-{
- add_offset_callback (me,
- (a == X_AXIS) ? centered_on_x_parent_proc : centered_on_y_parent_proc,
- a);
-}
-
-void
-Self_alignment_interface::set_align_self (Grob *me, Axis a)
+Self_alignment_interface::set_aligned_on_parent (Grob *me, Axis a)
{
add_offset_callback (me,
- (a == X_AXIS) ? x_aligned_on_self_proc : y_aligned_on_self_proc,
+ (a == X_AXIS) ? aligned_on_x_parent_proc : aligned_on_y_parent_proc,
a);
}
/* properties */
"self-alignment-X "
"self-alignment-Y "
+ "X-align-on-main-noteheads "
);