From 932d08864d51ed34e4dc58b42303d6a29954aef7 Mon Sep 17 00:00:00 2001 From: Carl Sorensen Date: Sat, 14 Aug 2010 06:53:31 -0600 Subject: [PATCH] Woodwind diagrams -- change syntax Add graphical to list of grob properties Add graphical to instrument-specific-markup interface Move size, thickness, graphic to props. Update regression files, add convert-ly rule --- input/regression/woodwind-diagrams-empty.ly | 18 ++-- .../regression/woodwind-diagrams-key-lists.ly | 2 +- python/convertrules.py | 8 ++ scm/define-grob-interfaces.scm | 2 +- scm/define-grob-properties.scm | 1 + scm/display-woodwind-diagrams.scm | 86 ++++++++++--------- 6 files changed, 64 insertions(+), 53 deletions(-) diff --git a/input/regression/woodwind-diagrams-empty.ly b/input/regression/woodwind-diagrams-empty.ly index b534b634fa..a58009adbb 100644 --- a/input/regression/woodwind-diagrams-empty.ly +++ b/input/regression/woodwind-diagrams-empty.ly @@ -9,7 +9,7 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'piccolo - #'(1.0 0.1 #t ()) + #'() } } @@ -17,7 +17,7 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'flute - #'(1.0 0.1 #t ()) + #'() } } @@ -25,7 +25,7 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'oboe - #'(1.0 0.1 #t ()) + #'() } } @@ -33,7 +33,7 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'clarinet - #'(1.0 0.1 #t ()) + #'() } } @@ -41,7 +41,7 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'bass-clarinet - #'(1.0 0.1 #t ()) + #'() } } @@ -49,7 +49,7 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'saxophone - #'(1.0 0.1 #t ()) + #'() } } @@ -57,7 +57,7 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'bassoon - #'(1.0 0.1 #t ()) + #'() } } @@ -65,6 +65,6 @@ in woodwind-diagrams.scm." c1^\markup { \woodwind-diagram #'contrabassoon - #'(1.0 0.1 #t ()) + #'() } -} \ No newline at end of file +} diff --git a/input/regression/woodwind-diagrams-key-lists.ly b/input/regression/woodwind-diagrams-key-lists.ly index d5bfd54950..1105010e62 100644 --- a/input/regression/woodwind-diagrams-key-lists.ly +++ b/input/regression/woodwind-diagrams-key-lists.ly @@ -15,4 +15,4 @@ woodwind-diagrams.scm" #(print-keys-verbose 'saxophone) #(print-keys-verbose 'baritone-saxophone) #(print-keys-verbose 'bassoon) -#(print-keys-verbose 'contrabassoon) \ No newline at end of file +#(print-keys-verbose 'contrabassoon) diff --git a/python/convertrules.py b/python/convertrules.py index 05bdbd8137..1e2ce6752d 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -3044,6 +3044,14 @@ def conv(str): stderr_write(UPDATE_MANUALLY) return str +@rule ((2, 13, 31), + _ ("Woodwind diagrams: Move size, thickness, and graphic from argument list to properties.")) +def conv(str): + if re.search(r'woodwind-diagram', str): + stderr_write("\n") + stderr_write(NOT_SMART % _("woodwind-diagrams. Move size, thickness, and graphic to properties. Argument should be just the key list.\n")) + stderr_write(UPDATE_MANUALLY) + return str # Guidelines to write rules (please keep this at the end of this file) # # - keep at most one rule per version; if several conversions should be done, diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm index 2949afcfbc..22316b5886 100644 --- a/scm/define-grob-interfaces.scm +++ b/scm/define-grob-interfaces.scm @@ -90,7 +90,7 @@ note)." (ly:add-interface 'instrument-specific-markup-interface "Instrument-specific markup (like fret boards or harp pedal diagrams)." - '(fret-diagram-details harp-pedal-details size thickness)) + '(fret-diagram-details graphical harp-pedal-details size thickness)) (ly:add-interface 'key-cancellation-interface diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 8fc2db4904..59b50a8b9e 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -411,6 +411,7 @@ typeset. Valid choices depend on the function that is reading this property.") (glyph-name ,string? "The glyph name within the font.") (glyph-name-alist ,list? "An alist of key-string pairs.") + (graphical ,boolean? "Display in graphical (vs. text) form.") (grow-direction ,ly:dir? "Crescendo or decrescendo?") diff --git a/scm/display-woodwind-diagrams.scm b/scm/display-woodwind-diagrams.scm index 51e239235e..3468e863e9 100644 --- a/scm/display-woodwind-diagrams.scm +++ b/scm/display-woodwind-diagrams.scm @@ -1863,13 +1863,16 @@ (key-list-loop key-list))) (define-markup-command - (woodwind-diagram layout props instrument input-list) + (woodwind-diagram layout props instrument user-draw-commands) (symbol? list?) #:category instrument-specific-markup ; markup category + #:properties ((size 1) + (thickness 0.1) + (graphical #t)) "Make a woodwind-instrument diagram. For example, say @example -\\markup \\woodwind-diagram #'oboe #'(1.4 0.1 #t ((lh . (d ees)) (cc . (five3qT1q)) (rh . (gis)))) +\\markup \\woodwind-diagram #'oboe #'((lh . (d ees)) (cc . (five3qT1q)) (rh . (gis))) @end example @noindent @@ -1944,44 +1947,43 @@ Lastly, substituting an empty list for the pressed-key alist will result in a diagram with all of the keys drawn but none filled. ie... @example -\\markup \\woodwind-diagram #'oboe #'(1.4 0.1 #t ()) +\\markup \\woodwind-diagram #'oboe #'() @end example" - (let* ((radius (car input-list)) - (thick (cadr input-list)) - (display-graphic (caddr input-list)) - (xy-stretch `(1.0 . 2.5)) - (chosen-instrument (assoc-get instrument woodwind-data-alist)) - (chosen-instrument - (if (not chosen-instrument) - (ly:error "~a is not a valid woodwind instrument." - instrument) - chosen-instrument)) - (stencil-info - (assoc-get - (if display-graphic 'graphical-commands 'text-commands) - chosen-instrument)) - (user-draw-commands (cadddr input-list)) - (pressed-info - (if (null? user-draw-commands) - (uniform-draw-instructions (assoc-get 'keys chosen-instrument)) - (translate-draw-instructions - (append '((hd . ())) user-draw-commands) - (assoc-get 'keys chosen-instrument)))) - (draw-info - (function-chain - pressed-info - (assoc-get 'draw-instructions stencil-info))) - (extra-offset-info - (function-chain - pressed-info - (assoc-get 'extra-offset-instructions stencil-info)))) - (assemble-stencils - (assoc-get 'stencil-alist stencil-info) - (assoc-get 'keys chosen-instrument) - draw-info - extra-offset-info - radius - thick - xy-stretch - layout - props))) \ No newline at end of file + (let* ((radius size) + (thick (* size thickness)) + (display-graphic graphical) + (xy-stretch `(1.0 . 2.5)) + (chosen-instrument (assoc-get instrument woodwind-data-alist)) + (chosen-instrument + (if (not chosen-instrument) + (ly:error "~a is not a valid woodwind instrument." + instrument) + chosen-instrument)) + (stencil-info + (assoc-get + (if display-graphic 'graphical-commands 'text-commands) + chosen-instrument)) + (pressed-info + (if (null? user-draw-commands) + (uniform-draw-instructions (assoc-get 'keys chosen-instrument)) + (translate-draw-instructions + (append '((hd . ())) user-draw-commands) + (assoc-get 'keys chosen-instrument)))) + (draw-info + (function-chain + pressed-info + (assoc-get 'draw-instructions stencil-info))) + (extra-offset-info + (function-chain + pressed-info + (assoc-get 'extra-offset-instructions stencil-info)))) + (assemble-stencils + (assoc-get 'stencil-alist stencil-info) + (assoc-get 'keys chosen-instrument) + draw-info + extra-offset-info + radius + thick + xy-stretch + layout + props))) -- 2.39.2