2 output-property-engraver.cc -- implement Output_property_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "engraver.hh"
14 class Output_property_engraver : public Engraver
16 TRANSLATOR_DECLARATIONS (Output_property_engraver);
18 Link_array<Music> props_;
20 virtual void stop_translation_timestep ();
21 virtual void acknowledge_grob (Grob_info);
22 virtual bool try_music (Music*);
27 Output_property_engraver::try_music (Music* m)
29 if (m->is_mus_type ("layout-instruction"))
38 Output_property_engraver::acknowledge_grob (Grob_info inf)
40 for (int i = props_.size (); i--;)
42 Music * o = props_[i];
43 SCM pred = o->get_property ("predicate");
47 if (ly_c_procedure_p (pred))
50 should typecheck pred.
52 SCM result = scm_call_1 (pred, inf.grob ()->self_scm ());
53 if (to_boolean (result))
55 SCM sym = o->get_property ("grob-property");
56 SCM val = o->get_property ("grob-value");
57 inf.grob ()->internal_set_property (sym, val);
62 Context * d = inf.context ();
63 SCM proc = o->get_property ("procedure");
65 inf.grob ()->self_scm (),
67 context ()->self_scm ());
73 Output_property_engraver::stop_translation_timestep ()
78 Output_property_engraver::Output_property_engraver ()
82 ADD_TRANSLATOR (Output_property_engraver,
83 /* descr */ "Interpret Music of Output_property type, and apply a function "
84 " to any Graphic objects that satisfies the predicate.",
86 /* accepts */ "layout-instruction",
87 /* acks */ "grob-interface",