lilypond-user
[Top][All Lists]
Advanced

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

Re: Align bracket not to notes but to enclosing bars


From: Urs Liska
Subject: Re: Align bracket not to notes but to enclosing bars
Date: Mon, 4 Feb 2019 16:05:59 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

Hi David,

Am 04.02.19 um 14:20 schrieb David Nalesnik:
Hi Urs,

On Mon, Feb 4, 2019 at 6:12 AM Urs Liska <address@hidden> wrote:
I have created a command that uses \startGroup and \stopGroup to print 
annotated horizontal brackets:

% Create a horizontal bracket with included text.
% If no text is desired an empty string has to be given.
% By default the bracket is above the staff, otherwise
% #DOWN has to be given as optional argument.

\layout {
   \context {
     \Voice
     \consists "Horizontal_bracket_engraver"
     \override HorizontalBracket.bracket-flare = #'(0 . 0)
     \override HorizontalBracket.staff-padding = 4.5
   }
}

startBracket =
#(define-event-function (direction text)((ly:dir? UP) markup?)
    #{
      -\tweak HorizontalBracketText.text #text
      -\tweak HorizontalBracketText.direction #(* -1 direction)
      -\tweak HorizontalBracketText.Y-offset #(if (= direction UP) -2.5 1)
      -\tweak direction #direction
      \startGroup
    #})

stopBracket = \stopGroup

\relative {
   g'4 g e d
   c \startBracket "Hello" d e f |
   g1 \stopBracket
}

(results attached as document.png).

However, in addition to that I need a way to align the start and end of that 
bracket not to the notes like in the example but to the enclosing measures, and 
optionally the whole staffline.

Is there any reasonable approach to doing that short of custom-printing a 
stencil by searching the current staff to find the neighbouring barlines (it is 
guaranteed that there are no line breaks)? The only advantage of going that way 
would be to have more control over how it actually looks like ...

I believe you will need to look for the bar lines (or the containing
NonMusicalPaperColumns).


What I was afraid of :-(

Fortunately I have collected some experience with that through a past project, and looking into its code base may get me up to (some) speed again.


  Here's a (still-working as of 2.19.82)
example which uses the MeasureCounter and a custom stencil:
http://lists.gnu.org/archive/html/lilypond-user/2014-10/msg00446.html.
It may be usable as a source of code for your task.  At the moment I
unfortunately can't devote time to a more thorough-going
recommendation!


Thank you, I will look into that ASAP.



(I do have an old patch which actually creates a
MeasureAttachedSpanner which I held off submitting until after a new
major release.  If I can get it to apply to current master I could
send it to you.  It does what you want without "co-opting" other
spanners, and has the ability to align endpoints in different ways.
This will give me a LilyPond task to get me back going after a long
hiatus!)


I'm a bit undecided about this. I assume (from your wording) that this is a C++ patch that requires compiling LilyPond? If so I will probably be unable to use it because my code has to be publicly shareable. OTOH it can't wait until it works with a released LilyPond (which may take some time).

But if you'd be willing to work on this I'd be happy to test and comment, as my current project shows me there's a need for this, and it's really hard to make LilyPond do it ...

Best
Urs


Best,
David



reply via email to

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