X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftweak-engraver.cc;h=560cabfc4f2f50f21b5305e19cc373a3cb4959a8;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=1879697bc34a7b5e51d0e852563ede377ac3a3ed;hpb=2909349bdbefbf880fa9c8c47ba2eddf9f9855ca;p=lilypond.git diff --git a/lily/tweak-engraver.cc b/lily/tweak-engraver.cc index 1879697bc3..560cabfc4f 100644 --- a/lily/tweak-engraver.cc +++ b/lily/tweak-engraver.cc @@ -1,10 +1,21 @@ /* - tweak-engraver.cc -- implement Tweak_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2015 Han-Wen Nienhuys - (c) 2005--2007 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "engraver.hh" @@ -28,28 +39,60 @@ Tweak_engraver::Tweak_engraver () void Tweak_engraver::acknowledge_grob (Grob_info info) { - if (Stream_event *ev = info.event_cause ()) + Stream_event *ev = info.event_cause (); + bool direct = ev; + SCM grobname = SCM_UNDEFINED; + if (!direct) + ev = info.ultimate_event_cause (); + if (ev) { + // Each tweak conses an address and a value. + // The address has one of the following forms: + // symbol -> direct tweak + // (grob . symbol) -> targeted tweak + // (#t . symbol-path) -> direct nested tweak + // (grob . symbol-path) -> targeted nested tweak for (SCM s = ev->get_property ("tweaks"); - scm_is_pair (s); s = scm_cdr (s)) - { - info.grob ()->set_property (scm_caar (s), scm_cdar (s)); - } + scm_is_pair (s); s = scm_cdr (s)) + { + if (scm_is_pair (scm_caar (s))) + { + if (scm_is_symbol (scm_caaar (s))) + { + if (SCM_UNBNDP (grobname)) + grobname = scm_from_locale_symbol + (info.grob ()->name ().c_str ()); + if (scm_is_eq (scm_caaar (s), grobname)) + { + if (scm_is_symbol (scm_cdaar (s))) + info.grob ()->set_property (scm_cdaar (s), scm_cdar (s)); + else + set_nested_property (info.grob (), scm_cdaar (s), + scm_cdar (s)); + } + } + else if (direct) + set_nested_property (info.grob (), scm_cdaar (s), + scm_cdar (s)); + } + else if (direct) + info.grob ()->set_property (scm_caar (s), scm_cdar (s)); + } } } ADD_ACKNOWLEDGER (Tweak_engraver, grob); ADD_TRANSLATOR (Tweak_engraver, - /* doc */ - "Read the @code{tweaks} property from the originating event," - " and set properties.", - - /* create */ - "", - - /* read */ - "", - - /* write */ - "" - ); + /* doc */ + "Read the @code{tweaks} property from the originating event," + " and set properties.", + + /* create */ + "", + + /* read */ + "", + + /* write */ + "" + );