From 5824899210e6d05e3b8767ffff25c79dca6b038e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benk=C5=91=20P=C3=A1l?= Date: Wed, 15 Aug 2012 21:37:10 +0200 Subject: [PATCH] extend or shrink bar line if it's too short or long --- scm/bar-line.scm | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/scm/bar-line.scm b/scm/bar-line.scm index 30341439ad..be43ce6d11 100644 --- a/scm/bar-line.scm +++ b/scm/bar-line.scm @@ -397,21 +397,32 @@ (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) -- 2.39.5