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: David Kastrup
Subject: Re: cleanup: infinity, get property (issue 6310043)
Date: Fri, 15 Jun 2012 18:00:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux)

Janek Warchoł <address@hidden> writes:

> 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.

What makes you think LyricText is an Item?  Its definition is

class Lyric_text
{
public:
 DECLARE_SCHEME_CALLBACK (calc_x_offset, (SCM));
 DECLARE_GROB_INTERFACE ();
};

It is a class with one member function and an interface.  That does not
make it an Item.  If you want it to be an Item, you need to have it
inherit from Item in which case it will know its context (and
consequently how to get properties) from the way it has been created.

>>> 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.

So far, you don't have an Item that I can see.

-- 
David Kastrup



reply via email to

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