]> git.donarmstrong.com Git - lilypond.git/commitdiff
Updated patch for issue 155
authorCarl Sorensen <carl.d.sorensen@gmail.com>
Wed, 15 Apr 2015 02:04:50 +0000 (20:04 -0600)
committerCarl Sorensen <carl.d.sorensen@gmail.com>
Mon, 27 Apr 2015 17:37:12 +0000 (11:37 -0600)
Use Joe Neeman's code to enclose dots and accidentals inside parentheses
around note heads.

Eliminate pure-Y-extent (no longer needed)
Improve documentation string for parenthesis friends
Improve regression test

input/regression/parenthesize-notes-accidentals.ly [new file with mode: 0644]
lily/grob.cc
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/output-lib.scm

diff --git a/input/regression/parenthesize-notes-accidentals.ly b/input/regression/parenthesize-notes-accidentals.ly
new file mode 100644 (file)
index 0000000..f1a15fb
--- /dev/null
@@ -0,0 +1,13 @@
+\version "2.19.19"
+
+\header {
+  texidoc = "Parentheses around notes also include accidentals and dots;
+they are centered on the vertical center of the combined enclosed items."
+}
+
+\score {
+  \new Staff {
+    \parenthesize ais'4. \parenthesize des''4
+  }
+}
+
index 99d027f2f3bbbc521e67c0865953375eb480803d..435a6faff3a92447ad67c637678a89129f5a09dd 100644 (file)
@@ -818,6 +818,7 @@ ADD_INTERFACE (Grob,
                "meta "
                "minimum-X-extent "
                "minimum-Y-extent "
+               "parenthesis-friends "
                "pure-Y-offset-in-progress "
                "rotation "
                "skyline-horizontal-padding "
index 3914cf459db9b490ecead8b57cce8cd1156c2427..bbd24055415bdc4cb931a0db3b897ae6a1ad6aca 100644 (file)
@@ -777,6 +777,10 @@ If unset, the value from @code{self-alignment-X} property will be
 used.")
      (parent-alignment-Y ,number? "Like @code{parent-alignment-X}
 but for the Y@tie{}axis.")
+     (parenthesis-friends ,list? "A list of Grob types, as symbols.
+When parentheses enclose a Grob that has 'parenthesis-friends, the
+parentheses widen to include any child Grobs with type among
+'parenthesis-friends.")
      (parenthesized ,boolean? "Parenthesize this grob.")
      (positions ,number-pair? "Pair of staff coordinates
 @code{(@var{left} . @var{right})}, where both @var{left} and
index f82f27cec3bc7d9fd135b1af8f154dbc3f539ca2..cdae45dd17bb976d8263bd3ca1b404af4dd4282f 100644 (file)
         (extra-spacing-height . ,ly:note-head::include-ledger-line-height)
         (glyph-name . ,note-head::calc-glyph-name)
         (ligature-flexa . #f)
+        (parenthesis-friends . (accidental-grob dot))
         (stem-attachment . ,ly:note-head::calc-stem-attachment)
         (stencil . ,ly:note-head::print)
         (X-offset . ,ly:note-head::stem-x-shift)
         ;; horizontal attachment.  ParenthesesItem does not reserve
         ;; space of its own, however.
         (X-extent . (0 . 0))
+        (Y-extent . ,parentheses-item::y-extent)
         (meta . ((class . Item)
                  (interfaces . (font-interface
                                 parentheses-interface))))))
         (cross-staff . ,ly:rest::calc-cross-staff)
         (duration-log . ,stem::calc-duration-log)
         (minimum-distance . 0.25)
+        (parenthesis-friends . (dot))
         (stencil . ,ly:rest::print)
         (voiced-position . 4)
         (X-extent . ,ly:rest::width)
         (duration-log . ,note-head::calc-duration-log)
         (font-series . bold)
         (font-size . -2)
+        (parenthesis-friends . (dot))
         (stem-attachment . (0.0 . 1.35))
         (stencil . ,tab-note-head::print)
         (whiteout . #t)
index a73e2c0324977e6046d45c8cfb736bd59ec4c644..33ad81ae50405053fe015197c7a85fa40d32697b 100644 (file)
@@ -905,12 +905,25 @@ and duration-log @var{log}."
     (list (stencil-whiteout lp)
           (stencil-whiteout rp))))
 
+(define-public (parentheses-item::y-extent grob) (ly:grob::stencil-height grob))
+
 (define (parenthesize-elements grob . rest)
   (let* ((refp (if (null? rest)
                    grob
                    (car rest)))
-         (elts (ly:grob-object grob 'elements))
-         (x-ext (ly:relative-group-extent elts refp X))
+         (elts (ly:grob-array->list (ly:grob-object grob 'elements)))
+         (get-friends
+           (lambda (g)
+             (let ((syms (ly:grob-property g 'parenthesis-friends '()))
+                   (get-friend (lambda (s)
+                                 (let ((f (ly:grob-object g s)))
+                                   (cond
+                                     ((ly:grob? f) (list f))
+                                     ((ly:grob-array? f) (ly:grob-array->list f))
+                                     (else '()))))))
+               (apply append (map get-friend syms)))))
+         (friends (apply append elts (map get-friends elts)))
+         (x-ext (ly:relative-group-extent friends refp X))
          (stencils (ly:grob-property grob 'stencils))
          (lp (car stencils))
          (rp (cadr stencils))