From 03be44b1a82407c0079f02d9f6b533982bebd714 Mon Sep 17 00:00:00 2001 From: Marc Hohl Date: Thu, 14 Jan 2010 23:56:23 +0000 Subject: [PATCH] Enhancement: Providing ly:grob-set-nested-property! 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 | 16 ++++++++++++++++ lily/grob-scheme.cc | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 input/regression/override-nest-scheme.ly diff --git a/input/regression/override-nest-scheme.ly b/input/regression/override-nest-scheme.ly new file mode 100644 index 0000000000..9253a07fb3 --- /dev/null +++ b/input/regression/override-nest-scheme.ly @@ -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 +} + diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 6e18c54278..67a4de0d81 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -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}." -- 2.39.5