]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-grobs.scm
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / scm / define-grobs.scm
index 30ef5818fdb2c5d4c93ef96bc77a893f4aee2b7f..7c459a0bca6ed52c278723bd15c5e65fa0ff8b01 100644 (file)
        (stencil . ,ly:arpeggio::print)
        (X-extent . ,ly:arpeggio::width)
        (X-offset . ,ly:side-position-interface::x-aligned-side)
-       (Y-extent . ,ly:arpeggio::height)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
        (meta . ((class . Item)
                 (interfaces . (arpeggio-interface
        (stencil . ,ly:hairpin::print)
        (thickness . 1.0)
        (to-barline . #t)
-       (Y-extent . ,ly:hairpin::height)
        (Y-offset . ,ly:self-alignment-interface::y-aligned-on-self)
        (meta . ((class . Spanner)
                 (interfaces . (dynamic-interface
        (font-size . -2)
        (stem-attachment . (0.0 . 1.35))
        (stencil . ,ly:text-interface::print)
+       (whiteout . #t)
        (X-offset . ,ly:self-alignment-interface::x-aligned-on-self)
        (Y-offset . ,ly:staff-symbol-referencer::callback)
        (meta . ((class . Item)
                                   (padding . 0.25)
                                   (attach-dir . ,LEFT)
                                   ))
+                         (left-broken . ((end-on-note . #t)))
                          (right . ((Y . 0)
                                    (padding . 0.25)
                                    ))
        (font-encoding . fetaNumber)
        (font-size . -4)
        (stencil . ,ly:volta-bracket-interface::print)
-       (thickness . 1.6)  ;;  line-thickness
+       (thickness . 1.6) ;; line-thickness
        (word-space . 0.6)
        (meta . ((class . Spanner)
                 (interfaces . (font-interface
                                line-interface
                                side-position-interface
                                text-interface
-                               volta-bracket-interface))))))
+                               volta-bracket-interface
+                               volta-interface))))))
 
     (VoltaBracketSpanner
      . (
        (after-line-breaking . ,ly:side-position-interface::move-to-extremal-staff)
        (axes . (,Y))
        (direction . ,UP)
-       (no-alignment . ,#t)
+       (no-alignment . #t)
        (outside-staff-priority . 600)
        (padding . 1)
        (side-axis . ,Y)
        (Y-offset . ,ly:side-position-interface::y-aligned-side)
        (meta . ((class . Spanner)
                 (interfaces . (axis-group-interface
-                               side-position-interface))))))
+                               side-position-interface
+                               volta-interface))))))
 
 ))
 
 
 (set! all-grob-descriptions (sort all-grob-descriptions alist<?))
 
+(define (volta-bracket-interface::pure-height grob start end)
+  (let ((edge-height (ly:grob-property grob 'edge-height)))
+    (if (number-pair? edge-height)
+       (let ((smaller (min (car edge-height) (cdr edge-height)))
+             (larger (max (car edge-height) (cdr edge-height))))
+         (interval-union '(0 . 0) (cons smaller larger)))
+       '(0 . 0))))
+
 (define pure-print-callbacks
   (list
    fret-board::calc-stencil
+   note-head::brew-ez-stencil
    print-circled-text-callback
    lyric-text::print
-   ly:arpeggio::print
-   ly:arpeggio::brew-chord-bracket
    ly:bar-line::print
    ly:mensural-ligature::brew-ligature-primitive
    ly:note-head::print
    ly:text-interface::print
    ly:script-interface::print))
 
-;; ly:grob::stencil-extent is safe iff the print callback is safe too
+;; Sometimes we have grobs with (Y-extent . ,ly:grob::stencil-height)
+;; and the print function is not pure, but there is a easy way to
+;; figure out the Y-extent from the print function.
+(define pure-print-to-height-conversions
+  `(
+    (,ly:arpeggio::print . ,ly:arpeggio::pure-height)
+    (,ly:arpeggio::brew-chord-bracket . ,ly:arpeggio::pure-height)
+    (,ly:hairpin::print . ,ly:hairpin::pure-height)
+    (,ly:volta-bracket-interface::print . ,volta-bracket-interface::pure-height)))
+
+;; ly:grob::stencil-extent is safe if the print callback is safe too
 (define (pure-stencil-height grob start stop)
-  (let ((sten (ly:grob-property-data grob 'stencil)))
-    (if (or
-        (ly:stencil? sten)
-        (memq sten pure-print-callbacks))
-       (ly:grob::stencil-height grob)
-       '(0 . 0))))
+  (let* ((sten (ly:grob-property-data grob 'stencil))
+        (pure-height-callback (assoc-get sten pure-print-to-height-conversions)))
+    (cond ((or
+           (ly:stencil? sten)
+           (memq sten pure-print-callbacks))
+          (ly:grob::stencil-height grob))
+         ((procedure? pure-height-callback)
+          (pure-height-callback grob start stop))
+         (else
+          '(0 . 0)))))
 
 (define pure-conversions-alist
   `(
     (,ly:accidental-interface::height . ,ly:accidental-interface::pure-height)
-    (,ly:arpeggio::height . ,ly:arpeggio::pure-height)
     (,ly:slur::outside-slur-callback . ,ly:slur::pure-outside-slur-callback)
-    (,ly:hairpin::height . ,ly:hairpin::pure-height)
     (,ly:stem::height . ,ly:stem::pure-height)
     (,ly:rest::height . ,ly:rest::pure-height)
     (,ly:grob::stencil-height . ,pure-stencil-height)
               (memq extent-callback pure-functions)
               (and
                (pair? (assq extent-callback pure-conversions-alist))
-               (begin
+               (let ((stencil (ly:grob-property-data grob 'stencil)))
                  (or
                   (not (eq? extent-callback ly:grob::stencil-height))
-                  (memq (ly:grob-property-data grob 'stencil) pure-print-callbacks)
-                  (ly:stencil? (ly:grob-property-data grob 'stencil))
-
-                  ))))))))
+                  (memq stencil pure-print-callbacks)
+                  (assq stencil pure-print-to-height-conversions)
+                  (ly:stencil? stencil)))))))))
 
 (define-public (call-pure-function unpure args start end)
   (if (ly:simple-closure? unpure)