]> git.donarmstrong.com Git - lilypond.git/commitdiff
redesign dot placement of repeat sign
authorBenkő Pál <benko.pal@gmail.com>
Fri, 7 Sep 2012 18:51:51 +0000 (20:51 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 19 Oct 2012 10:59:35 +0000 (12:59 +0200)
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

index be43ce6d1190d0c23ff36a73d5a800cb5e9c0e0a..25cf20ea27f13cf8bb9934a3f0417678dc8f9bc7 100644 (file)
          (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)))
 
                         (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
                                                       (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)