lilypond-user
[Top][All Lists]
Advanced

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

Re: New member - Bar numbers placement problem


From: David Nalesnik
Subject: Re: New member - Bar numbers placement problem
Date: Thu, 23 Oct 2014 09:41:47 -0500

Hi Kieren,

On Thu, Oct 23, 2014 at 8:31 AM, Kieren MacMillan <address@hidden> wrote:
Hi David,

> I think that if you want automation your best approach would be to look at modifying the position of BarNumber.

I thought of that at first, but rather hoped the InstrumentName thing would work out…  =\

Question: Can the BarNumber *position* be set from the “expected position” of InstrumentName?
If so, maybe you could apply an after-line-break callback function to move system-initiating BarNumbers to where the InstrumentName would normally be?


Querying Y-position of objects tends to have disastrous results.

The following routine gets at the InstrumentName grob from BarNumber, and asking for details of Y-positioning (relative to System) gives answers, but destroys the layout:

\version "2.19.15"

#(define (Y-pos-of-InstrumentName-from-BarLine grob)
   (let* ((refp (ly:grob-system grob))
          (all-grobs (ly:grob-array->list (ly:grob-object refp 'all-elements)))
          (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
          (IN (filter (lambda (x) (eq? (grob-name x) 'InstrumentName)) all-grobs)))
     (if (pair? IN)
         (begin
          (format #t "~a Y-coord: ~a Y-offset: ~a~%"
            (grob-name (car IN))
            (ly:grob-relative-coordinate (car IN) refp Y) ; destroys vertical spacing
            (ly:grob-property (car IN) 'Y-offset) ; destroys vertical spacing
            )))))

music = \repeat unfold 20 {
  c4 d e f
}

\score {
  \new PianoStaff \with { shortInstrumentName = "pno." } <<
    \new Staff {
      \relative c'' {
        \music
      }
    }
    \new Staff {
      \clef bass
      \music
    }
  >>
  \layout {
    \context {
      \Score
      \override BarNumber.after-line-breaking = #Y-pos-of-InstrumentName-from-BarLine
    }
  }
}

[Currently pursuing another line of inquiry suggested to me--will report back.]

Best,
David

reply via email to

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