> What i would like: specify the reference grob in a property, for example > > \override LyricText #'align-to = #'Stem > > and then have one callback function that would be smart enough to find > appropriate grob to use and feed it to the method calculating > alignment.
Hi Janek, I think this would be a nice generalization of the existing interface. Unfortunately, I'm pretty busy right now, but here are a few quick thoughts. > The callback would probably look like this: > > MAKE_SCHEME_CALLBACK (Self_alignment_interface, x_aligned, 1) > SCM > Self_alignment_interface::x_aligned (SCM smob) > { > Grob *me = unsmob_grob (smob); > what_to_align_to = me->internal_get_property (ly_symbol2scm ("align-to")) > return general_alignment (me, me->get_grob (what_to_align_to), X_AXIS); > } > The magic lies in writing get_grob. I know that there is a function > called get_object, but i'll probably have to modify it. > The easiest way to define get_grob is to make 'align-to a list of symbols, which you interpret as a path from the current grob to the grob you want to align it to. For example, if me is NoteHead and 'align-to is '(X-parent, stem) then you go from "me" to me->get_object("X-parent")->get_object("stem"). The disadvantage of this approach is that you ask users to know about which grobs have references to which other grobs; IIRC, this is not in the user documentation right now. Another possible approach is to do something similar to how BreakAlignment works. The disadvantages with that are (1) it's more work and (2) you have to decide in advance on all valid values for 'align-to. Cheers, Joe
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel