lilypond-devel
[Top][All Lists]
Advanced

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

Re: cleanup: infinity, get property (issue 6310043)


From: Janek Warchoł
Subject: Re: cleanup: infinity, get property (issue 6310043)
Date: Fri, 15 Jun 2012 17:52:29 +0200

On Fri, Jun 15, 2012 at 5:04 PM, David Kastrup <address@hidden> wrote:
> Janek Warchoł <address@hidden> writes:
>
>> I'm trying to define a new context property lyricDefaultAlignment
>> similarly to how lyricMelismaAlignment is defined.
>> (did i use the right name? lyricMelismaAlignment is a context
>> property, i.e. a property that doesn't belong to a specific grob?)
>> Look at Lyric_engraver, lines 76-77:
>>
>> last_text_->set_property ("self-alignment-X",
>>                                       get_property 
>> ("lyricMelismaAlignment"));
>>
>> unless i'm totally wrong, last_text_ is a pointer to a LyricText item.
>>  These two lines set that LyricText's self-alignment-X to what is
>> inside lyricMelismaAlignment.
>
> But this is inside of a member function of an _Engraver_.  An engraver
> has an associated context, and get_property inside of an engraver will
> access the respective context property.

Ah, indeed - silly me!

>>> What makes you think Lyric_text has properties?
>>
>> Does it need any?  I'm trying to read a context property (or at least
>> that's what i think i'm trying), i thought that they don't need to be
>> "owned".
>
> What do you think the word "context" in "context property" means?  How
> should the C++ compiler guess what context you are talking about when
> you just write get_property ("lyricMelismaAlignment") ?

I thought that since i have a pointer to a LyricText Item, which is
placed in some context, that context would be used.  From what i see
in Context::internal_get_property, i can start from a child context of
the context i need (i.e. if MyProperty isn't set for Staff, but it is
set for Score, i can start from Staff and it will go up to Score).

>>> It is a class you defined yourself.
>>
>> I've looked at other class definitions (in particular, flag.cc) and
>> tried to define Lyric_text accordingly to what i saw.  Apparently i
>> missed something, but i don't know what :(
>
> You call a member function get_property (or rather via a macro
> definition internal_get_property) but don't define it.

Should i #include context.hh then?

>> I thought that ADD_INTERFACE is responsible for connecting my class
>> with the rest of the code, and MAKE_SCHEME_CALLBACK makes a method
>> available in Scheme "layer".  I don't have any idea what else is
>> necessary...
>> I'd be grateful for an explanation.
>
> Again: how should LilyPond guess the context from which you want the
> property read?  The code will, of course, depend on the answer to that
> question.

I'd like to use the parent context of the Item that i have.  Can it be
done this way?  Could you point me to an example?

thanks,
Janek



reply via email to

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