lilypond-devel
[Top][All Lists]
Advanced

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

Re: Instrument names


From: Phil Holmes
Subject: Re: Instrument names
Date: Fri, 27 Jul 2012 19:06:30 +0100

----- Original Message ----- From: "Keith OHara" <address@hidden>
To: <address@hidden>
Sent: Thursday, July 26, 2012 3:32 AM
Subject: Re: Instrument names


Phil Holmes <email <at> philholmes.net> writes:

I've done the looking into the code that I can manage. I know that indents are worked in output-def.cc:line_dimensions_int. This returns a linewidth
and an indent, with a normal indent when called with second parameter 0,
otherwise it's a short-indent. So it would be easy to add something to the
indent here to take account of intrument names.

The instrument name is created in instrument-name-engraver.cc. This makes a Spanner *text_spanner_; with text_spanner_ = make_spanner ("InstrumentName",
SCM_EOL);

So it appears that there is a Spanner called InstrumentName with the details
of the instrument name.  Is there any way of accessing this within
output-def.cc?

The InstrumentName spanners can change when an instrument changes, or
whenever the user feels like changing the text.  The short-indent will
affect line breaking, which could affect which instrument name goes at
the front of each line.  Even if output-def.cc can find all the
InstrumentName spanners, it is hard to know which ones to pull information
from.

Maybe each Instrument_name_engraver, one for each staff, could push
information to a central location.  I think there is some way for an
engraver to refer to its Output_def, and call its set_variable().

Whenever an engraver sees a new (short)instrumentName (or maybe just
once upon initialization based on instrumentNames set in \with{} blocks)
the engraver could estimate the length of the text, in paper units, compare
to a layout variable 'instrument_name_length' or 'short_name_length' as
appropriate, and overwrite that variable if the text they will be setting
is longer than the length posted so far.

The layout variable 'indent' might then be initialized to a Scheme
expression that returns the longer of 'instrument_name_length' and
'default_indent'.  That way a user can take control by explicitly setting
\layout{ indent = 8\mm }.

Other concerns are, any difference between 'indent' in \layout and \paper
blocks, and making 'default_indent' scale properly with paper size.


I've now worked out how I can pick up when instrument names change. What I now want to try to do is get the dimensions of the spanner that contains the instrument name. Could someone point me at some code that takes a spanner and delivers its dimensions in int or float form?

Thanks.

--
Phil Holmes



reply via email to

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