[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Align bracket not to notes but to enclosing bars
From: |
David Nalesnik |
Subject: |
Re: Align bracket not to notes but to enclosing bars |
Date: |
Mon, 4 Feb 2019 07:20:30 -0600 |
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). 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!
(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!)
Best,
David