]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix 932.
authorJoe Neeman <joeneeman@gmail.com>
Sun, 20 Dec 2009 18:03:32 +0000 (10:03 -0800)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 20 Dec 2009 19:17:17 +0000 (11:17 -0800)
Add a more generic mechanism for dealing with non-pure
stencil callbacks.  (The previous mechanism required
adding dummy height callbacks, since we could only
convert from height callbacks to pure-height callbacks
and not from print callbacks to pure-height callbacks.)

lily/arpeggio.cc
lily/hairpin.cc
lily/include/arpeggio.hh
lily/include/hairpin.hh
scm/define-grobs.scm

index fe5ed02dcd48d5b66b41a3023470fe6d760bb271..a78d150e5313d1dc833f79bfd8f7a3614638f653 100644 (file)
@@ -196,13 +196,6 @@ Arpeggio::width (SCM smob)
   return ly_interval2scm (arpeggio.extent (X_AXIS));
 }
 
-MAKE_SCHEME_CALLBACK (Arpeggio, height, 1);
-SCM
-Arpeggio::height (SCM smob)
-{
-  return Grob::stencil_height (smob);
-}
-
 MAKE_SCHEME_CALLBACK (Arpeggio, pure_height, 3);
 SCM
 Arpeggio::pure_height (SCM smob, SCM, SCM)
@@ -211,7 +204,7 @@ Arpeggio::pure_height (SCM smob, SCM, SCM)
   if (to_boolean (me->get_property ("cross-staff")))
     return ly_interval2scm (Interval ());
 
-  return height (smob);
+  return Grob::stencil_height (smob);
 }
 
 ADD_INTERFACE (Arpeggio,
index e707655188c2cee6c0e72d51daad0059d3f9e113..af3565362910dfa53e4d50ab9f714205d9f6f52d 100644 (file)
 #include "note-column.hh"
 #include "warn.hh"
 
-MAKE_SCHEME_CALLBACK (Hairpin, height, 1);
-SCM
-Hairpin::height (SCM smob)
-{
-  return Grob::stencil_height (smob);
-}
-
 MAKE_SCHEME_CALLBACK (Hairpin, pure_height, 3);
 SCM
 Hairpin::pure_height (SCM smob, SCM, SCM)
index eab5a7db251c3742a5602a34aed1a89fc2ecb98f..a492e08edf5e6d2c7dfe3f978eee5746c467c252 100644 (file)
@@ -33,7 +33,6 @@ public:
   DECLARE_SCHEME_CALLBACK (brew_chord_bracket, (SCM));
   DECLARE_SCHEME_CALLBACK (brew_chord_slur, (SCM));
   DECLARE_SCHEME_CALLBACK (width, (SCM));
-  DECLARE_SCHEME_CALLBACK (height, (SCM));
   DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM));
   DECLARE_GROB_INTERFACE();
 };
index 61d22f4d8312c63a8f14f77ccfd5292e088a4454..5aecefed7c66fb2dd218070cfbb9fa8a92fa5a21 100644 (file)
@@ -27,7 +27,6 @@ struct Hairpin
 {
 public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
-  DECLARE_SCHEME_CALLBACK (height, (SCM));
   DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM));
   DECLARE_GROB_INTERFACE();
 };
index 802774e3f2caf15614d49fc3c719e87496fec366..3e8b65908a3d721e790b2c9984bbc7e1ff1c7158 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
 
 (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:text-interface::print
    ly:script-interface::print))
 
+;; 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: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)