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);
63 dynamic_cast<Context *> (inf.origin_trans_);
66 d = dynamic_cast<Context *> (inf.origin_trans_->context ());
68 SCM proc = o->get_property ("procedure");
70 inf.grob_->self_scm (),
72 context ()->self_scm ());
78 Output_property_engraver::stop_translation_timestep ()
83 Output_property_engraver::Output_property_engraver ()
87 ADD_TRANSLATOR (Output_property_engraver,
88 /* descr */ "Interpret Music of Output_property type, and apply a function "
89 " to any Graphic objects that satisfies the predicate.",
91 /* accepts */ "layout-instruction",
92 /* acks */ "grob-interface",