]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4974/1: Add output-attributes grob property
authorPaul Morris <paulwmorris@gmail.com>
Sun, 18 Sep 2016 15:32:05 +0000 (11:32 -0400)
committerPaul Morris <paulwmorris@gmail.com>
Tue, 4 Oct 2016 15:07:04 +0000 (11:07 -0400)
It is used for setting multiple attributes on <g>
nodes in SVG output, specified as an alist. The id
grob property is no longer used for this.

lily/grob.cc
lily/stencil-integral.cc
lily/stencil-interpret.cc
scm/define-grob-properties.scm
scm/define-stencil-commands.scm
scm/output-ps.scm
scm/output-svg.scm

index 23a1cafae48730885fb7068346750e1f114ec35a..924c80e500221b2d7bcfc2a8fab0102fea2a7c3c 100644 (file)
@@ -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 "
index ee12c53f3668a951fbf4160b86f30fcf5e74f047..1b9aa5181b4e2426c915e7db3106e52052b003c5 100644 (file)
@@ -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
     {
index 87e6496de778e2f3bfe3ed03fdfacd6a094ed47a..25fad0d8429ef6c327ac2a08b57f959789015827 100644 (file)
@@ -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;
         }
index d55ab4c8c788449af838d45b2afd55b9b1e8247c..06358986b077bad2934e73eeac7fac2c4850c4af 100644 (file)
@@ -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 (<g>)
-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 (<g>) containing all of the
+stencils that comprise a given grob.  For example,
+@code{'((id . 123) (class . foo) (data-whatever . @qq{bar}))} will produce
+@code{<g id=@qq{123} class=@qq{foo} data-whatever=@qq{bar}> @dots{} </g>}.
+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
index 7eb31a9600432afd6f8bec6dc8b19e8a3cdff5d4..23c17abb9be42fabe29f8ef9584ced97dd2440d5 100644 (file)
@@ -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
index 6d3ab63c2fcf30dd78370cd7cb97e9b458abbe0e..97909da80cf6b8537ba39fcbc384825156361978 100644 (file)
        "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)
index 78bda3c35b8c88f376fadc6f9d471597ca1ba482..653664122cd5d20befb84ed84fa4147ec6690840 100644 (file)
   "c = close"
   (format #f "</~S>\n" entity))
 
-(define (start-enclosing-id-node s)
-  (string-append "<g id=\"" s "\">\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 "<g" attributes-string ">\n"))
+
+(define (end-group-node)
   "</g>\n")
 
 (define-public (comment s)