lilypond-user
[Top][All Lists]
Advanced

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

Re: system separator markup position


From: David Nalesnik
Subject: Re: system separator markup position
Date: Fri, 9 Jan 2015 11:07:08 -0600

Hi Neil,

On Wed, Jan 7, 2015 at 4:01 PM, Neil Thornock <address@hidden> wrote:
Thanks for the suggestion. While it does avoid the collision, it doesn't center the separator between staves. I believe the separator is spaced evenly between the vertical midpoint of each surrounding staff (line-position 0), and so when the bottom staff is that tall, it encroaches on the separator.

I believe you are right about the method of calculation.  Looking at the file scm/page.scm, at the function called "make-page-stencil," we see that the system-separator stencil is placed using the function "paper-system-staff-extents" which reads a property called 'staff-refpoint-extent (which I would guess is a pair representing the midlines of top/bottom staves.)

As an experiment, I replaced calls to paper-system-staff-extents with another function (from paper-system.scm) which looks at the _stencil_, namely paper-system-extent.

I'll quote the function with my (tiny) alterations.  Sorry, it's a long function!   I suppose you could patch the file yourself if you like what you see.  (See the attached image.)

;;;; from scm/page.scm:

(define (make-page-stencil page)
  "Construct a stencil representing the page from PAGE."


  (page-translate-systems page)
  (let*
      ((paper-book (page-property page 'paper-book))
       (prop (lambda (sym) (page-property page sym)))
       (layout (ly:paper-book-paper paper-book))
       (scopes (ly:paper-book-scopes paper-book))
       (lines (page-lines page))
       (number (page-page-number page))

       ;; TODO: naming paper-height/paper-width not analogous to TeX.

       (system-xoffset (ly:output-def-lookup layout 'horizontal-shift 0.0))
       (system-separator-markup (ly:output-def-lookup layout 'system-separator-markup))
       (system-separator-stencil (if (markup? system-separator-markup)
                                     (interpret-markup layout
                                                       (layout-extract-page-properties layout)
                                                       system-separator-markup)
                                     #f))

       (page-stencil (ly:make-stencil '()))

       (last-system #f)
       (last-y 0.0)
       (add-to-page (lambda (stencil x y)
                      (set! page-stencil
                            (ly:stencil-add page-stencil
                                            (ly:stencil-translate stencil
                                                                  (cons
                                                                   (+ system-xoffset x)
                                                                   (- 0 y (prop 'top-margin)))

                                                                  )))))
       (add-system
        (lambda (system)
          (let* ((stencil (paper-system-stencil system))
                 (y (ly:prob-property system 'Y-offset 0))
                 (is-title (paper-system-title?
                            system)))
            (add-to-page stencil
                         (ly:prob-property system 'X-offset 0.0)
                         y)
            (if (and (ly:stencil? system-separator-stencil)
                     last-system
                     (not (paper-system-title? system))
                     (not (paper-system-title? last-system)))
                (add-to-page
                 system-separator-stencil
                 0
                 (average (- last-y
                             (car (paper-system-extent last-system Y))) ;; NB
                          (- y
                             (cdr (paper-system-extent system Y)))))) ;; NB
            (set! last-system system)
            (set! last-y y))))
       (head (prop 'head-stencil))
       (foot (prop 'foot-stencil))
       )

    (if (and
         (ly:stencil? head)
         (not (ly:stencil-empty? head)))
        (begin
          ;; Ensure that the top of the header just touches the top margin.
          (set! head (ly:stencil-translate-axis head
                                                (- 0 (cdr (ly:stencil-extent head Y)) (prop 'top-margin)) Y))
          (set! page-stencil (ly:stencil-add page-stencil head))))

    (if (and
         (annotate? layout)
         (pair? lines))

        (begin
          (set! page-stencil (annotate-top-space (car lines) layout head page-stencil))

          (for-each (lambda (sys next-sys)
                      (paper-system-annotate sys next-sys layout))
                    lines
                    (append (cdr lines) (list #f)))
          (paper-system-annotate-last (car (last-pair lines)) layout)))

    (for-each add-system lines)


    (ly:prob-set-property! page 'bottom-system-edge
                           (car (ly:stencil-extent page-stencil Y)))
    (ly:prob-set-property! page 'space-left
                           (+ (prop 'bottom-edge)
                              (prop 'bottom-system-edge)
                              (if (and (ly:stencil? foot)
                                       (not (ly:stencil-empty? foot)))
                                  (car (ly:stencil-extent foot Y))
                                  0.0)))

    (if (annotate? layout)
        (set! page-stencil
              (ly:stencil-add page-stencil
                              (annotate-space-left page))))

    (if (and (ly:stencil? foot)
             (not (ly:stencil-empty? foot)))
        (set! page-stencil
              (ly:stencil-add
               page-stencil
               (ly:stencil-translate
                foot
                (cons 0
                      (+ (- (prop 'bottom-edge))
                         (- (car (ly:stencil-extent foot Y)))))))))

    (if (ly:output-def-lookup layout 'two-sided #f)
        (set! page-stencil
              (ly:stencil-translate page-stencil
                                    (cons (prop (if (even? number)
                                                    'left-margin
                                                    'right-margin))
                                          0)))
        (set! page-stencil
              (ly:stencil-translate page-stencil (cons (prop 'left-margin) 0))))

    ;; annotation.
    (if (annotate? layout)
        (set! page-stencil (annotate-page layout page-stencil)))

    page-stencil))

;;;;;;

 
It would be better if the separator were centered between the bottom line of the staff above it and the top line of the staff below it, or maybe calculated from the staves's actual Y-extent.



(The above uses stencil extents, which--I suppose--could lead to some visual irregularity depending on what hangs below/sticks above an extremal staff.)

--David

Attachment: separator-test.pdf
Description: Adobe PDF document


reply via email to

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