From: Paul Morris Date: Sun, 18 Sep 2016 15:32:05 +0000 (-0400) Subject: Issue 4974/1: Add output-attributes grob property X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f80e0f5e69fa8ffb35b6d3b7d162ed4191586c0c;p=lilypond.git Issue 4974/1: Add output-attributes grob property It is used for setting multiple attributes on nodes in SVG output, specified as an alist. The id grob property is no longer used for this. --- diff --git a/lily/grob.cc b/lily/grob.cc index 23a1cafae4..924c80e500 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -189,11 +189,11 @@ Grob::get_print_stencil () const retval = Stencil (retval.extent_box (), expr); } - SCM id = get_property ("id"); - if (scm_is_string (id)) + SCM attributes = get_property ("output-attributes"); + if (scm_is_pair (attributes)) { - SCM expr = scm_list_3 (ly_symbol2scm ("id"), - id, + SCM expr = scm_list_3 (ly_symbol2scm ("output-attributes"), + attributes, retval.expr ()); retval = Stencil (retval.extent_box (), expr); @@ -816,16 +816,17 @@ ADD_INTERFACE (Grob, "cause " "color " "cross-staff " - "id " "extra-offset " "footnote-music " "forced-spacing " "horizontal-skylines " + "id " "interfaces " "layer " "meta " "minimum-X-extent " "minimum-Y-extent " + "output-attributes " "parenthesis-friends " "pure-Y-offset-in-progress " "rotation " diff --git a/lily/stencil-integral.cc b/lily/stencil-integral.cc index ee12c53f36..1b9aa5181b 100644 --- a/lily/stencil-integral.cc +++ b/lily/stencil-integral.cc @@ -944,7 +944,7 @@ stencil_traverser (PangoMatrix trans, SCM expr) return stencil_traverser (trans, scm_caddr (expr)); else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("transparent-stencil"))) return stencil_traverser (trans, scm_cadr (expr)); - else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("id"))) + else if (scm_is_eq (scm_car (expr), ly_symbol2scm ("output-attributes"))) return stencil_traverser (trans, scm_caddr (expr)); else { diff --git a/lily/stencil-interpret.cc b/lily/stencil-interpret.cc index 87e6496de7..25fad0d842 100644 --- a/lily/stencil-interpret.cc +++ b/lily/stencil-interpret.cc @@ -78,13 +78,14 @@ interpret_stencil_expression (SCM expr, return; } - else if (scm_is_eq (head, ly_symbol2scm ("id"))) + else if (scm_is_eq (head, ly_symbol2scm ("output-attributes"))) { - SCM id = scm_cadr (expr); + SCM attributes = scm_cadr (expr); - (*func) (func_arg, scm_list_2 (ly_symbol2scm ("start-enclosing-id-node"), id)); + (*func) (func_arg, scm_list_2 (ly_symbol2scm ("start-group-node"), + ly_quote_scm (attributes))); interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); - (*func) (func_arg, scm_list_1 (ly_symbol2scm ("end-enclosing-id-node"))); + (*func) (func_arg, scm_list_1 (ly_symbol2scm ("end-group-node"))); return; } diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index d55ab4c8c7..06358986b0 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -524,13 +524,7 @@ left and one to the right of this grob.") ;;; ;;; i ;;; - (id ,string? "An id string for the grob. Depending on the typestting -backend being used, this id will be assigned to a group containing all of -the stencils that comprise a given grob. For example, in the svg backend, -the string will be assigned to the @code{id} attribute of a group () -that encloses the stencils that comprise the grob. In the Postscript -backend, as there is no way to group items, the setting of the id property -will have no effect.") + (id ,string? "An id string for the grob.") (ignore-ambitus ,boolean? "If set, don't consider this notehead for ambitus calculation.") (ignore-collision ,boolean? "If set, don't do note collision @@ -720,6 +714,14 @@ different voices. Default value@tie{}1.") ;;; ;;; o ;;; + (output-attributes ,list? "An alist of attributes for the grob, to +be included in output files. When the SVG typesetting backend is used, +the attributes are assigned to a group () containing all of the +stencils that comprise a given grob. For example, +@code{'((id . 123) (class . foo) (data-whatever . @qq{bar}))} will produce +@code{ @dots{} }. +In the Postscript backend, where there is no way to group items, the +setting of the output-attributes property will have no effect.") (outside-staff-horizontal-padding ,number? "By default, an outside-staff-object can be placed so that is it very close to another grob horizontally. If this property is set, the outside-staff-object diff --git a/scm/define-stencil-commands.scm b/scm/define-stencil-commands.scm index 7eb31a9600..23c17abb9b 100644 --- a/scm/define-stencil-commands.scm +++ b/scm/define-stencil-commands.scm @@ -29,7 +29,7 @@ defined in the output modules (@file{output-*.scm})." ellipse embedded-ps embedded-svg - end-enclosing-id-node + end-group-node glyph-string grob-cause named-glyph @@ -46,7 +46,7 @@ defined in the output modules (@file{output-*.scm})." setcolor setrotation setscale - start-enclosing-id-node + start-group-node text unknown url-link @@ -63,7 +63,7 @@ are used internally in @file{lily/@/stencil-interpret.cc}." combine-stencil delay-stencil-evaluation footnote - id + output-attributes rotate-stencil scale-stencil translate-stencil diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 6d3ab63c2f..97909da80c 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -52,10 +52,10 @@ "false") radius thick)) -(define (start-enclosing-id-node s) +(define (start-group-node attributes) "") -(define (end-enclosing-id-node) +(define (end-group-node) "") (define (dashed-line thick on off dx dy phase) diff --git a/scm/output-svg.scm b/scm/output-svg.scm index 78bda3c35b..653664122c 100644 --- a/scm/output-svg.scm +++ b/scm/output-svg.scm @@ -61,10 +61,15 @@ "c = close" (format #f "\n" entity)) -(define (start-enclosing-id-node s) - (string-append "\n")) - -(define (end-enclosing-id-node) +(define (start-group-node attributes) + (define attributes-string + (string-concatenate + (map (lambda (item) + (ly:format " ~a=\"~a\"" (car item) (cdr item))) + attributes))) + (string-append "\n")) + +(define (end-group-node) "\n") (define-public (comment s)