lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: API for getting various kinds of grobs


From: Joe Neeman
Subject: Re: API for getting various kinds of grobs
Date: Tue, 12 Mar 2013 16:27:11 -0700


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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]