]> git.donarmstrong.com Git - lilypond.git/commitdiff
Enhancement: Providing ly:grob-set-nested-property!
authorMarc Hohl <marc@hohlart.de>
Thu, 14 Jan 2010 23:56:23 +0000 (23:56 +0000)
committerNeil Puttock <n.puttock@gmail.com>
Thu, 14 Jan 2010 23:58:41 +0000 (23:58 +0000)
This patch features a new function similar to the
already existing ly:grob-set-property! together with a
new regression test file.

input/regression/override-nest-scheme.ly [new file with mode: 0644]
lily/grob-scheme.cc

diff --git a/input/regression/override-nest-scheme.ly b/input/regression/override-nest-scheme.ly
new file mode 100644 (file)
index 0000000..9253a07
--- /dev/null
@@ -0,0 +1,16 @@
+\version "2.13.11"
+
+\header {
+  texidoc = "A sublist of grob property lists may be overridden within a callback.
+  This test uses a custom stencil callback which changes the Y coordinate
+  of the right bound of the glissando spanner."
+}
+
+\relative c' {
+  \override Glissando #'after-line-breaking =
+    #(lambda (grob)
+       (ly:grob-set-nested-property! grob '(bound-details right Y) 3))
+  c1 \glissando
+  d1
+}
+
index 6e18c54278c615028cf344948a306675d96a1721..67a4de0d819f2e9b5681056684a21fef0b894e3c 100644 (file)
@@ -56,6 +56,27 @@ LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!",
   return SCM_UNSPECIFIED;
 }
 
+LY_DEFINE (ly_grob_set_nested_property_x, "ly:grob-set-nested-property!",
+          3, 0, 0, (SCM grob, SCM symlist, SCM val),
+          "Set nested property @var{symlist} in grob @var{grob} to value @var{val}.")
+{
+  Grob *sc = unsmob_grob (grob);
+
+  LY_ASSERT_SMOB (Grob, grob, 1);
+
+  bool type_ok = ly_cheap_is_list (symlist);
+
+  if (type_ok)
+    for (SCM s = symlist; scm_is_pair (s) && type_ok; s = scm_cdr (s))
+      type_ok &= ly_is_symbol (scm_car (s));
+
+  SCM_ASSERT_TYPE (type_ok, symlist, SCM_ARG2, __FUNCTION__, "list of symbols");
+
+  set_nested_property (sc, symlist, val);
+  return SCM_UNSPECIFIED;
+}
+
+
 LY_DEFINE (ly_grob_property, "ly:grob-property",
           2, 1, 0, (SCM grob, SCM sym, SCM val),
           "Return the value for property @var{sym} of @var{grob}."