2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "engraver.hh"
24 #include "stream-event.hh"
25 #include "translator.icc"
27 class Tweak_engraver : public Engraver
29 TRANSLATOR_DECLARATIONS (Tweak_engraver);
32 DECLARE_ACKNOWLEDGER (grob);
35 Tweak_engraver::Tweak_engraver ()
40 Tweak_engraver::acknowledge_grob (Grob_info info)
42 Stream_event *ev = info.event_cause ();
44 SCM grobname = SCM_UNDEFINED;
46 ev = info.ultimate_event_cause ();
49 // Each tweak conses an address and a value.
50 // The address has one of the following forms:
51 // symbol -> direct tweak
52 // (grob . symbol) -> targeted tweak
53 // (#t . symbol-path) -> direct nested tweak
54 // (grob . symbol-path) -> targeted nested tweak
55 for (SCM s = ev->get_property ("tweaks");
56 scm_is_pair (s); s = scm_cdr (s))
58 if (scm_is_pair (scm_caar (s)))
60 if (scm_is_symbol (scm_caaar (s)))
62 if (SCM_UNBNDP (grobname))
63 grobname = scm_from_locale_symbol
64 (info.grob ()->name ().c_str ());
65 if (scm_is_eq (scm_caaar (s), grobname))
67 if (scm_is_symbol (scm_cdaar (s)))
68 info.grob ()->set_property (scm_cdaar (s), scm_cdar (s));
70 set_nested_property (info.grob (), scm_cdaar (s),
75 set_nested_property (info.grob (), scm_cdaar (s),
79 info.grob ()->set_property (scm_caar (s), scm_cdar (s));
84 ADD_ACKNOWLEDGER (Tweak_engraver, grob);
85 ADD_TRANSLATOR (Tweak_engraver,
87 "Read the @code{tweaks} property from the originating event,"
88 " and set properties.",