]> git.donarmstrong.com Git - lilypond.git/commitdiff
extend or shrink bar line if it's too short or long
authorBenkő Pál <benko.pal@gmail.com>
Wed, 15 Aug 2012 19:37:10 +0000 (21:37 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 19 Oct 2012 10:28:07 +0000 (12:28 +0200)
scm/bar-line.scm

index 30341439ad8ea5f8b7e278e5d6e970b18c3296bc..be43ce6d1190d0c23ff36a73d5a800cb5e9c0e0a 100644 (file)
        (if (ly:grob? staff-symbol)
            (let* ((bar-line-color (ly:grob-property grob 'color))
                   (staff-color (ly:grob-property staff-symbol 'color))
-                  (radius (ly:staff-symbol-staff-radius grob))
-                  (staff-line-thickness (ly:staff-symbol-line-thickness grob)))
-
-                 ;; Due to rounding problems, bar lines extending to the outermost edges
-                 ;; of the staff lines appear wrongly in on-screen display
-                 ;; (and, to a lesser extent, in print) - they stick out a pixel.
-                 ;; The solution is to extend bar lines only to the middle
-                 ;; of the staff line - unless they have different colors,
-                 ;;when it would be undesirable.
+                  (staff-line-thickness (ly:staff-symbol-line-thickness grob))
+                  (staff-space (ly:staff-symbol-staff-space grob)))
+
                  (set! staff-extent (ly:staff-symbol::height staff-symbol))
-                 (if (and (eq? bar-line-color staff-color)
-                          radius)
+
+                 (if (zero? staff-space)
+                     (set! staff-space 1.0))
+
+                 (if (< (interval-length staff-extent) staff-space)
+                     ;; staff is too small (perhaps consists of a single line);
+                     ;; extend the bar line to make it visible
                      (set! staff-extent
-                       (interval-scale staff-extent
-                                       (- 1 (* 1/2 (/ staff-line-thickness radius))))))))
+                           (interval-widen staff-extent staff-space))
+                     ;; Due to rounding problems, bar lines extending to the outermost edges
+                     ;; of the staff lines appear wrongly in on-screen display
+                     ;; (and, to a lesser extent, in print) - they stick out a pixel.
+                     ;; The solution is to extend bar lines only to the middle
+                     ;; of the staff line - unless they have different colors,
+                     ;; when it would be undesirable.
+                     ;;
+                     ;; This reduction should not influence whether bar is to be
+                     ;; expanded later, so length is not updated on purpose.
+                     (if (eq? bar-line-color staff-color)
+                         (set! staff-extent
+                               (interval-widen staff-extent
+                                               (* -1/2 staff-line-thickness)))))))
        staff-extent))
 
 (define (bar-line::bar-y-extent grob refpoint)