lilypond-devel
[Top][All Lists]
Advanced

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

Re: centering of instrument names


From: Neil Puttock
Subject: Re: centering of instrument names
Date: Fri, 22 May 2009 23:46:59 +0100

2009/5/20 Francisco Vila <address@hidden>:
> 2009/5/20 Francisco Vila <address@hidden>:
>> The key code is this. Given a (big) amount of time I could figure out
>> how it works and try to improve it.
>>
>> http://git.savannah.gnu.org/gitweb/?p=lilypond.git;a=blobdiff;f=lily/system-start-text.cc;h=c99f150fed;hp=494ab1;hb=b12cf254;hpb=4d0abb92
>
> Maybe it's not that easy. If the right padding is intended to put the
> stencil to the rightmost side, the problem is that the extent of the
> brace (if any) is unknown at this moment.

The InstrumentName has to be attached to the left edge of the
VerticalAxisGroup (i.e., the Staff), so the only way to position it is
to apply padding on its right hand side; this moves it away from the
system.  In order to prevent collisions between instrument names and
PianoStaff braces, the system start delimiters are added as
side-support-elements of each InstrumentName, thus leading to a
variation in support extents depending on where each InstrumentName is
attached to the system.

I think the simplest way to deal with this is to split it into two parts:

1. Remove the side-support-elements so every InstrumentName has the
same alignment anchor in the X-axis (i.e., the left edge of each
stave).

This is a simple matter of removing the acknowledger for
system-start-text in the System_start_delimiter_engraver.

2. Calculate the combined extents of all the system start delimiters
in a system, then apply an X-offset correction to each InstrumentName.
 This ensures that there wil be no collisions between any
InstrumentName and SystemStartBrace/Bracket/Bar/Square.

Since we can access the System grob from the InstrumentName (via
ly:grob-system), it's possible to retrieve the grob-array 'elements
which will include all the system start delimiter grobs.  From the
array we can cherry pick the delimiters by checking the interfaces
list for system-start-delimiter-interface.  By uniting their
horizontal extents it's possible to get an offset which represents the
width of the set of delimiters attached to the most deeply nested
stave.

I've attached a proof of concept patch together with an image
demonstrating left-, centre- and right-aligned instrument names.

Regards,
Neil

Attachment: instrument-name-test.png
Description: PNG image

Attachment: 0001-Correctly-aligned-instrument-names.patch
Description: Text Data


reply via email to

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