X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fself-alignment-interface.cc;h=d1cb1bf50ca54e92295d13ef468b0e5580585936;hb=1d765020f867995879c761f2c9351c9dc74f1df8;hp=e0b7f00cb2887fc6e1c1e9afd194aa0045f86e5d;hpb=40aac0ae57ee113faa860ba221d83d9e6312173e;p=lilypond.git diff --git a/lily/self-alignment-interface.cc b/lily/self-alignment-interface.cc index e0b7f00cb2..d1cb1bf50c 100644 --- a/lily/self-alignment-interface.cc +++ b/lily/self-alignment-interface.cc @@ -79,27 +79,6 @@ 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_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 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) @@ -107,13 +86,6 @@ 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) @@ -132,10 +104,17 @@ SCM 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 + he = him->extent (him, a); SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X") : ly_symbol2scm ("self-alignment-Y"); @@ -166,18 +145,10 @@ Self_alignment_interface::aligned_on_parent (Grob *me, Axis a) } 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); }