]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/output-lib.scm
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / scm / output-lib.scm
index b2d7bea66b5e52867d7e7b0a7d752708e72f4672..68c338dfb8cc3e28fe6e8e3e6db72b5a9a985659 100644 (file)
     (ly:text-interface::interpret-markup layout props text)))
 
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; tablature
-
-;; The TabNoteHead tablatureFormat callback.
-;; Compute the text grob-property
-(define-public (fret-number-tablature-format string context event)
-  (let* ((tuning (ly:context-property context 'stringTunings))
-        (pitch (ly:event-property event 'pitch))
-        (is-harmonic (apply
-                      functional-or
-                      (map
-                       (lambda (ev)
-                         (eq? 'harmonic-event (ly:event-property ev 'class)))
-                       (ly:event-property event 'articulations)))))
-
-    (make-whiteout-markup
-     (make-vcenter-markup
-      (format
-       "~a"
-       (- (ly:pitch-semitones pitch)
-         (list-ref tuning
-                   ;; remove 1 because list index starts at 0
-                   ;;and guitar string at 1.
-                   (1- string))))))))
-
-;; The 5-string banjo has got a extra string, the fifth (duh), which
-;; starts at the fifth fret on the neck.  Frets on the fifth string
-;; are referred to relative to the other frets:
-;;   the "first fret" on the fifth string is really the sixth fret
-;;   on the banjo neck.
-;; We solve this by defining a new fret-number-tablature function:
-(define-public (fret-number-tablature-format-banjo string context event)
-  (let* ((tuning (ly:context-property context 'stringTunings))
-        (pitch (ly:event-property event 'pitch)))
-
-    (make-whiteout-markup
-     (make-vcenter-markup
-      (let ((fret (- (ly:pitch-semitones pitch) (list-ref tuning (1- string)))))
-       (number->string (cond
-                        ((and (> fret 0) (= string 5))
-                         (+ fret 5))
-                        (else fret))))))))
-
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; note heads
 
        (if (< log 0)
           (string-append (number->string log) "neomensural")
           (number->string log)))
+      ((altdefault)
+       ;; Like default, but brevis is drawn with double vertical lines
+       (if (= log -1)
+          (string-append (number->string log) "double")
+          (number->string log)))
       ((mensural)
        (string-append (number->string log) (symbol->string style)))
       ((petrucci)
           (string-append (number->string (max 0 log))
                          (symbol->string style)))))))
 
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; bar numbers
-
-(define-public ((every-nth-bar-number-visible n) barnum)
-  (= 0 (modulo barnum n)))
-
-(define-public ((modulo-bar-number-visible n m) barnum) (and (> barnum 1) (= m (modulo barnum n))))
-
-(define-public ((set-bar-number-visibility n) tr)
-  (let ((bn (ly:context-property tr 'currentBarNumber)))
-    (ly:context-set-property! tr 'barNumberVisibility
-                             (modulo-bar-number-visible n (modulo bn n)))))
-
-(define-public (first-bar-number-invisible barnum) (> barnum 1))
-
-(define-public (all-bar-numbers-visible barnum) #t)
-
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; percent repeat counters
-
-(define-public ((every-nth-repeat-count-visible n) count context)
-  (= 0 (modulo count n)))
-
-(define-public (all-repeat-counts-visible count context) #t)
-
+(define-public (note-head::brew-ez-stencil grob)
+  (let* ((log (ly:grob-property grob 'duration-log))
+        (pitch (ly:event-property (event-cause grob) 'pitch))
+        (pitch-index (ly:pitch-notename pitch))
+        (note-names (ly:grob-property grob 'note-names))
+        (pitch-string (if (vector? note-names)
+                          (vector-ref note-names pitch-index)
+                          (string
+                           (integer->char
+                            (+ (modulo (+ pitch-index 2) 7)
+                               (char->integer #\A))))))
+        (staff-space (ly:staff-symbol-staff-space grob))
+        (line-thickness (ly:staff-symbol-line-thickness grob))
+        (stem (ly:grob-object grob 'stem))
+        (stem-thickness (* (if (ly:grob? stem)
+                               (ly:grob-property stem 'thickness)
+                               1.3)
+                           line-thickness))
+        (radius (/ (+ staff-space line-thickness) 2))
+        (letter (markup #:center-align #:vcenter pitch-string))
+        (filled-circle (markup #:draw-circle radius 0 #t)))
+
+    (grob-interpret-markup
+     grob
+     (if (>= log 2)
+        (make-combine-markup
+         filled-circle
+         (make-with-color-markup white letter))
+        (make-combine-markup
+         (make-combine-markup
+          filled-circle
+          (make-with-color-markup white (make-draw-circle-markup
+                                         (- radius stem-thickness) 0 #t)))
+         letter)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; break visibility
 
     (if (and (pair? live-elts)
             (interval-sane? (ly:grob-extent grob system Y)))
-       (begin
-         (let get-extent ((lst live-elts))
-           (if (pair? lst)
-               (let ((axis-group (car lst)))
-
-                 (if (and (ly:spanner? axis-group)
-                          (equal? (ly:spanner-bound axis-group LEFT)
-                                  left-bound))
-                     (set! extent (add-point extent
-                                             (ly:grob-relative-coordinate
-                                              axis-group system Y))))
-                 (get-extent (cdr lst)))))
-         (+
-          (ly:self-alignment-interface::y-aligned-on-self grob)
-          (interval-center extent)))
+       (let get-extent ((lst live-elts))
+         (if (pair? lst)
+             (let ((axis-group (car lst)))
+
+               (if (and (ly:spanner? axis-group)
+                        (equal? (ly:spanner-bound axis-group LEFT)
+                                left-bound))
+                   (set! extent (add-point extent
+                                           (ly:grob-relative-coordinate
+                                            axis-group system Y))))
+               (get-extent (cdr lst)))))
        ;; no live axis group(s) for this instrument name -> remove from system
-       (ly:grob-suicide! grob))))
+       (ly:grob-suicide! grob))
+
+    (+
+     (ly:self-alignment-interface::y-aligned-on-self grob)
+     (interval-center extent))))
 
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; ambitus
+
+(define-public (ambitus::print grob)
+  (let ((heads (ly:grob-object grob 'note-heads)))
+
+    (if (and (ly:grob-array? heads)
+            (= (ly:grob-array-length heads) 2))
+       (let* ((common (ly:grob-common-refpoint-of-array grob heads Y))
+              (head-down (ly:grob-array-ref heads 0))
+              (head-up (ly:grob-array-ref heads 1))
+              (gap (ly:grob-property grob 'gap 0.35))
+              (point-min (+ (interval-end (ly:grob-extent head-down common Y))
+                            gap))
+              (point-max (- (interval-start (ly:grob-extent head-up common Y))
+                            gap)))
+
+         (if (< point-min point-max)
+             (let* ((layout (ly:grob-layout grob))
+                    (line-thick (ly:output-def-lookup layout 'line-thickness))
+                    (blot (ly:output-def-lookup layout 'blot-diameter))
+                    (grob-thick (ly:grob-property grob 'thickness 2))
+                    (width (* line-thick grob-thick))
+                    (x-ext (symmetric-interval (/ width 2)))
+                    (y-ext (cons point-min point-max))
+                    (line (ly:round-filled-box x-ext y-ext blot))
+                    (y-coord (ly:grob-relative-coordinate grob common Y)))
+
+               (ly:stencil-translate-axis line (- y-coord) Y))
+             empty-stencil))
+       (begin
+         (ly:grob-suicide! grob)
+         (list)))))