From 627d9721414b74af7f5a19c96e0ad08f7bf620a9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benk=C5=91=20P=C3=A1l?= Date: Fri, 7 Sep 2012 20:51:51 +0200 Subject: [PATCH] redesign dot placement of repeat sign refines6239ab9f01fcb31fbd6d5f7e81a98a7f58e663bf in that allow both dots in the same space only as last resort (for two-line staves or for exotic staves where all outer spaces are too narrow or asymmetric); put no lower limit on the space required between dot and staffline. an important example is TabStaff, which, for the present purposes, is equivalent to a Staff with line-count 6 and staff-space 1.5. --- scm/bar-line.scm | 65 +++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/scm/bar-line.scm b/scm/bar-line.scm index be43ce6d11..25cf20ea27 100644 --- a/scm/bar-line.scm +++ b/scm/bar-line.scm @@ -171,22 +171,17 @@ (dot (ly:font-get-glyph (ly:grob-default-font grob) "dots.dot")) (dot-y-length (interval-length (ly:stencil-extent dot Y))) (stencil empty-stencil) - ;; the two dots of the repeat sign should be centred at the middle of - ;; the staff and neither should collide with staff lines - ;; - ;; the default distance between centre of dots is composed of - ;; - a staffline (with width line-thickness) - ;; - some space below and above dot - ;; - two half-dots - ;; and we need to measure it as line positions, + ;; the two dots of the repeat sign should be centred at the + ;; middle of the staff and neither should collide with staff + ;; lines. + ;; the required space is measured in line positions, ;; i.e. in half staff spaces. - ;; - ;; space between dot and staffline should be comparable to staffline - ;; width so that a relatively common idiom - ;; (0.5 staff-size combined with set-layout-staff-size 10) works ok - - ;; that makes the choice of 1 staffline too big. - ;; 0.1 will be used if to be positioned between staff lines, - ;; dot diameter if outside staff. + + ;; dots are to fall into distict spaces, except when there's + ;; only one space (and it's big enough to hold two dots and + ;; some space between them) + + ;; choose defaults working without any staff (center 0.0) (dist (* 4 dot-y-length))) @@ -203,24 +198,20 @@ (set! center (interval-center (staff-symbol-line-span staff-symbol))) - ;; fold the staff into two at center and find the - ;; first gap big enough to hold a dot and some space - ;; below and above - (let* ((half-staff - (sort (append (map (lambda (lp) - (abs (- lp center))) - line-pos) - '(0.0)) <)) - (gap-to-find (/ (+ dot-y-length - (* 1.2 line-thickness)) + ;; fold the staff into two at center + (let* ((folded-staff + (sort (map (lambda (lp) (abs (- lp center))) + line-pos) <)) + (gap-to-find (/ (+ dot-y-length line-thickness) (/ staff-space 2))) + (first (car folded-staff)) (found #f)) - ;; initialize dist for the case when both dots should - ;; be outside the staff - (set! dist (+ (* 2 (car (reverse half-staff))) - (/ (* 4 dot-y-length) staff-space))) - + ;; find the first space big enough + ;; to hold a dot and a staff line + ;; (a space in the folded staff may be + ;; narrower but can't be wider than the + ;; corresponding original spaces) (reduce (lambda (x y) (if (and (> (- x y) gap-to-find) (not found)) (begin @@ -228,7 +219,19 @@ (set! dist (+ x y)))) x) "" - half-staff)))))))) + folded-staff) + + (if (not found) + (set! dist (if (< gap-to-find first) + ;; there's a central space big + ;; enough to hold both dots + first + + ;; dots should go outside + (+ (* 2 (car + (reverse folded-staff))) + (/ (* 4 dot-y-length) + staff-space)))))))))))) (set! staff-space 1.0)) (let* ((stencil empty-stencil) -- 2.39.2