(staff_eligible): new function.
[lilypond.git] / lily / output-property-engraver.cc
blob4f7c3a0e2018cb9e311fc5e6231c93aaee62f4f2
1 /*
2 output-property-engraver.cc -- implement Output_property_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "engraver.hh"
11 #include "grob.hh"
12 #include "output-property-music-iterator.hh"
13 #include "translator-group.hh"
15 class Output_property_engraver : public Engraver
17 TRANSLATOR_DECLARATIONS(Output_property_engraver);
18 protected:
19 Link_array<Music> props_;
21 virtual void stop_translation_timestep ();
22 virtual void acknowledge_grob (Grob_info);
23 virtual bool try_music (Music*);
27 bool
28 Output_property_engraver::try_music (Music* m)
30 if (m->is_mus_type ("layout-instruction"))
32 props_.push (m);
33 return true;
35 return false;
38 void
39 Output_property_engraver::acknowledge_grob (Grob_info inf)
41 for (int i=props_.size (); i--;)
43 Music * o = props_[i];
44 SCM pred = o->get_mus_property ("predicate");
48 if (gh_procedure_p (pred))
51 should typecheck pred.
53 SCM result=scm_call_1 (pred, inf.grob_->self_scm ());
54 if (to_boolean (result))
56 SCM sym = o->get_mus_property ("grob-property");
57 SCM val = o->get_mus_property ("grob-value");
58 inf.grob_->internal_set_grob_property (sym, val);
61 else
63 Translator_group * d =
64 dynamic_cast<Translator_group*> (inf.origin_trans_);
66 if (!d)
67 d = dynamic_cast<Translator_group*> (inf.origin_trans_->daddy_trans_);
69 SCM proc = o->get_mus_property ("procedure");
70 scm_call_3 (proc,
71 inf.grob_->self_scm(),
72 d->self_scm(),
73 daddy_trans_->self_scm());
78 void
79 Output_property_engraver::stop_translation_timestep ()
81 props_.clear ();
84 Output_property_engraver::Output_property_engraver()
88 ENTER_DESCRIPTION(Output_property_engraver,
89 /* descr */ "Interpret Music of Output_property type, and apply a function "
90 " to any Graphic objects that satisfies the predicate.",
91 /* creats*/ "",
92 /* accepts */ "layout-instruction",
93 /* acks */ "grob-interface",
94 /* reads */ "",
95 /* write */ "");